عملت أداة مفتوحة المصدر (gpumask) بتمنع تطبيقات الـ Electron من تشغيل كرت الشاشة المنفصل (dGPU) على لينكس 🐧⚡

لكل حدا معاه لابتوب بكرتين شاشة (Hybrid Graphics) على لينكس، أكيد بتعاني من نفس القصة مع صرف البطارية:

مجرد ما تفتح أي Electron app أو برامج معتمدة على Chromium، بتلاقي كرت الشاشة المنفصل (dGPU) صحي واشتغل فجأة بس عشان يفحص الشاشات أو يعمل GPU enumeration أول ما يفتح. والنتيجة؟ حرارة وصرف بطارية عالفاضي لبرامج أصلاً ما بتحتاج غير معالجة 2D عادية.

تغيير إعدادات الـ Environment variables على مستوى النظام كامل ممكن يخرب الـ offload للألعاب، والتعديل اليدوي على ملفات الـ .desktop قروشة وبيروح مع كل تحديث.

لهيك عملت أداة CLI خفيفة اسمها gpumask.

كيف شغالة من جوا؟

  • بتعزل التطبيق بساندبوكس خفيف باستخدام bubblewrap (bwrap)، بحيث تخفي مسارات الـ dGPU المنفصل عنه تماماً.
  • التطبيق بيتراجع تلقائياً وبيشتغل على الكرت المدمج (iGPU) بدون أي مشاكل.
  • بتعمل Overrides نظيفة بمجلد المستخدم ~/.local/share/applications/ بدون ما تلمس ملفات الروت أو النظام الأساسية.

أهم الميزات:

  • الألعاب والشغل الثقيل ما بتأثروا نهائياً: ألعاب Steam، برامج الـ 3D، والريندرينغ بيضلوا شغالين على كرت الـ dGPU بكامل قوتهم.
  • إلغاء بأمر واحد: بتقدر ترجع كل إشي لأصله بأمر سريع: gpumask <app> --undo.
  • CLI سريع ومريح: فيه Batch patching، فحص التطبيقات الشغالة (--status)، ومعاينة قبل التطبيق (Dry-run).
  • خفيف وبدون Daemons: معتمد كلياً على الـ Linux namespaces المدمجة بالنواة بدون أي عمليات شغالة بالخلفية.

الكود والتنزيل: المشروع مفتوح المصدر بالكامل (MIT). بتقدروا تشوفوا الريبو على GitHub بالبحث عن: zeroxuf/gpumask

جربوها على أجهزتكم وأعطوني رأيكم وملاحظاتكم!

reddit.com
u/zeruxuf — 1 day ago

I built gpumask — a lightweight CLI tool to stop Electron apps from waking up the dGPU on Linux

On hybrid Intel/NVIDIA Linux laptops, launching standard Electron, Chromium-based applications frequently wakes up the discrete GPU just to perform initial device enumeration. This causes unnecessary battery drain and fan spin-up for lightweight apps that only need basic 2D rendering.

Setting global environment variables can break PRIME offloading for games and CUDA workloads, while manually modifying root-level .desktop files in /usr/share/applications gets overwritten whenever packages update.

To solve this cleanly, I built a lightweight CLI tool called gpumask.

How it works under the hood:

  • Isolates targeted applications inside a lightweight bubblewrap (bwrap) sandbox.
  • Masks NVIDIA device nodes (/dev/nvidia*, /dev/nvidia-uvm*) and discrete GPU PCI sysfs entries (/sys/bus/pci/devices/...) for the specified process only.
  • Forces the app to transparently fall back to the integrated Intel iGPU.
  • Leaves system directories untouched by writing standard XDG local overrides to ~/.local/share/applications/.

Key features:

  • Zero Gaming Impact: Steam, Lutris, Vulkan offload, and CUDA compute tasks continue using the NVIDIA dGPU normally.
  • Non-Destructive: Single-flag instant revert via gpumask <app> --undo.
  • Ergonomic CLI: Supports batch patching (gpumask app1 app2 --apply), status checking (--status), and dry-run previews before making changes.
  • Zero Background Daemons: Runs purely on native Linux kernel namespaces via bwrap with zero ongoing overhead.

Source code & installation: The project is fully open source (MIT). You can find the repository on GitHub under: zeroxuf/gpumask

Feedback on the sandboxing implementation or any specific edge cases is welcome!

reddit.com
u/zeruxuf — 1 day ago

I built gpumask — a lightweight CLI tool to stop Electron apps from waking up the dGPU on Linux

On hybrid Intel/NVIDIA Linux laptops, launching standard Electron, Chromium-based applications frequently wakes up the discrete GPU just to perform initial device enumeration. This causes unnecessary battery drain and fan spin-up for lightweight apps that only need basic 2D rendering.

Setting global environment variables can break PRIME offloading for games and CUDA workloads, while manually modifying root-level .desktop files in /usr/share/applications gets overwritten whenever packages update.

To solve this cleanly, I built a lightweight CLI tool called gpumask.

How it works under the hood:

  • Isolates targeted applications inside a lightweight bubblewrap (bwrap) sandbox.
  • Masks NVIDIA device nodes (/dev/nvidia*, /dev/nvidia-uvm*) and discrete GPU PCI sysfs entries (/sys/bus/pci/devices/...) for the specified process only.
  • Forces the app to transparently fall back to the integrated Intel iGPU.
  • Leaves system directories untouched by writing standard XDG local overrides to ~/.local/share/applications/.

Key features:

  • Zero Gaming Impact: Steam, Lutris, Vulkan offload, and CUDA compute tasks continue using the NVIDIA dGPU normally.
  • Non-Destructive: Single-flag instant revert via gpumask <app> --undo.
  • Ergonomic CLI: Supports batch patching (gpumask app1 app2 --apply), status checking (--status), and dry-run previews before making changes.
  • Zero Background Daemons: Runs purely on native Linux kernel namespaces via bwrap with zero ongoing overhead.

Source code & installation: The project is fully open source (MIT). You can find the repository on GitHub under: zeroxuf/gpumask

Feedback on the sandboxing implementation or any specific edge cases is welcome!

reddit.com
u/zeruxuf — 1 day ago

انترنت بلا شركات كبرى

صارلي فترة بفكر بوضعنا مع شركات التكنولوجيا الكبيرة. احنا حرفياً مجرد "ضيوف" عندهم، بيقرأوا بياناتنا، بيتحكموا باللي بنشوفه، وبكبسة زر بيقدروا يحظروا حسابك ويمسحوا وجودك كله.

طيب ليه ما نبني إحنا منصاتنا وإنترنت موازي خاص فينا؟
ترا الفكرة مش خيال، هي موجودة وبتكبر بسرعة (الويب اللامركزي P2P). عشان تتخيلوها، الموضوع بيشبه التورنت بالزبط: بدل ما يكون في سيرفر مركزي لشركة وحدة مخزن كل إشي، البيانات بتتوزع علينا كلنا.

كيف** حيصير هذا **كله؟

بياناتك** إلك:** ما في داتابيس لشركة تسجل فيها. حسابك وبوستاتك بتتخزن على جهازك إنت وبس.

لا** إيميل ولا باسوورد:** انسى قصة "تسجيل الدخول بجوجل". هويتك عبارة عن كي (Key) مشفر خاص فيك، وبتسجل دخول ببصمتك (Face ID أو Touch ID) بكل بساطة، وهيك استحالة تتهكر.

ما** في **زر "حذف أو حظر": لما تنزل بوست، بيروح من جهازك لأجهزة أصحابك دايركت. ما في جهة أو خوارزمية بتقدر تحذف بوستك أو تمنعك تتواصل مع مجتمعك.

حرية** مطلقة:** لأن البيانات مفصولة عن الشركات، أي حدا بيقدر يصمم واجهة التطبيق (UI) بالشكل والنظام اللي بيعجبه، والكل لسا بيقدر يتواصل مع بعض على نفس الشبكة!

هسا** وين المشكلة وليه ما نقلنا لهاد **العالم؟

الأكواد والبروتوكولات موجودة (زي Nostr و IPFS)، بس المشكلة إنه اللي بيبنوها مهندسين شبكات، فبتطلع التطبيقات معقدة جداً للشخص العادي.

اللي ناقص الفكرة عنجد هو واجهات مستخدم (UI/UX) بسيطة ونظيفة تكسر هالحاجز وتخلي الموضوع سلس زي أي تطبيق بنستعمله كل يوم.

بعرف ان البوست ما اله اي علاقة ب لينكس، بس شفت هذا الصب المكان الوحيد اللي ممكن الناس تهتم فيه بالفكرة، بحكم انه كثير منا مهتم فعلا بالاستغناء عن الشركات الكبرى.

reddit.com
u/zeruxuf — 2 months ago
▲ 1 r/ASUS

When will ASUS start taking Linux seriously?

Hey everyone,

I’ve been running Linux exclusively on my ASUS TUF Gaming laptop for a long time now. While the hardware performance is absolute top-tier, the official software support for the Linux ecosystem feels like it’s stuck in the past.

With the massive rise in the Linux user base over the last few years partly accelerated by the Steam Deck, Wayland finally maturing, and modern compositors making the desktop experience smoother than ever more and more power users, developers, and gamers are leaving Windows behind.

Yet, when it comes to ASUS, we are completely reliant on the incredible, unpaid work of open-source community developers (shoutout to the asus linux team for tools like `asusctl` and `supergfxctl`) just to handle basic things like power profiles, GPU switching, and matrix displays. If a small group of independent developers can make this hardware sing on Linux, why can’t a multi-billion dollar tech giant provide official, upstreamed support?

We shouldn't have to fight with kernel regressions, ACPI quirks, or custom patches just to get a premium laptop working the way it was advertised. ASUS produces some of the best engineering on the market, but ignoring the growing Linux demographic feels like a massive missed opportunity.

Are there any official plans from ASUS to actively contribute to upstream Linux support, or at least collaborate more closely with community developers? What’s keeping ASUS from giving Linux users the first-class experience they deserve?

Would love to hear your thoughts, especially if you're running a dual-boot or full Linux setup on modern ASUS hardware.

reddit.com
u/zeruxuf — 3 months ago
▲ 24 r/Asustuf

When will ASUS start taking Linux seriously?

Hey everyone,

I’ve been running Linux exclusively on my ASUS TUF Gaming laptop for a long time now. While the hardware performance is absolute top-tier, the official software support for the Linux ecosystem feels like it’s stuck in the past.

With the massive rise in the Linux user base over the last few years partly accelerated by the Steam Deck, Wayland finally maturing, and modern compositors making the desktop experience smoother than ever more and more power users, developers, and gamers are leaving Windows behind.

Yet, when it comes to ASUS, we are completely reliant on the incredible**,** unpaid work of open-source community developers (shoutout to the asus linux team for tools like `asusctl` and `supergfxctl`) just to handle basic things like power profiles, GPU switching, and matrix displays. If a small group of independent developers can make this hardware sing on Linux, why can’t a multi-billion dollar tech giant provide official, upstreamed support?

We shouldn't have to fight with kernel regressions, ACPI quirks, or custom patches just to get a premium laptop working the way it was advertised. ASUS produces some of the best engineering on the market, but ignoring the growing Linux demographic feels like a massive missed opportunity.

Are there any official plans from ASUS to actively contribute to upstream Linux support, or at least collaborate more closely with community developers? What’s keeping ASUS from giving Linux users the first-class experience they deserve?

Would love to hear your thoughts, especially if you're running a dual-boot or full Linux setup on modern ASUS hardware.

reddit.com
u/zeruxuf — 3 months ago
▲ 2 r/linux

GPU Switching situation

After using Linux for over 5 months completely Windows-free and relying on it for everything, I'm very satisfied with the experience and I'm never going back to Windows.

But there is exactly one thing that, no matter how hard I tried, I couldn't get to work like Windows: switching between GPUs. On Windows, if your laptop has more than one GPU, you can seamlessly switch between them whenever you want without logging out or restarting. On Linux, there are many tools to switch GPUs that work perfectly fine, but they are nowhere near Windows level.

For example, with a tool like supergfxctl, you can switch between: Integrated only, Dedicated only, or Hybrid mode which allows both to run together. The problem is that in all these cases, you have to at least log out of the entire system for the switch to happen, and this is driving me crazy…

Some might ask, "Why not just leave it on Hybrid mode and let it handle things automatically?" The problem with Hybrid mode is that the simplest, most trivial tasks can wake up the dedicated GPU for absolutely no reason. As a power user, I really care about these tiny details and it bothers me to see the GPU activate unnecessarily.

No matter what I did or tried to configure, it all comes down to one thing: the login manager. Honestly, I don't know if this is an issue just for me or if others suffer from the exact same thing. But the question is, can this be fixed if it gets more attention? Or is it a lost cause?

reddit.com
u/zeruxuf — 3 months ago

GPU Switching situation

After using Linux for over 5 months completely Windows-free and relying on it for everything, I'm very satisfied with the experience and I'm never going back to Windows.

But there is exactly one thing that, no matter how hard I tried, I couldn't get to work like Windows: switching between GPUs. On Windows, if your laptop has more than one GPU, you can seamlessly switch between them whenever you want without logging out or restarting. On Linux, there are many tools to switch GPUs that work perfectly fine, but they are nowhere near Windows level.

For example, with a tool like supergfxctl, you can switch between: Integrated only, Dedicated only, or Hybrid mode which allows both to run together. The problem is that in all these cases, you have to at least log out of the entire system for the switch to happen, and this is driving me crazy…

Some might ask, "Why not just leave it on Hybrid mode and let it handle things automatically?" The problem with Hybrid mode is that the simplest, most trivial tasks can wake up the dedicated GPU for absolutely no reason. As a power user, I really care about these tiny details and it bothers me to see the GPU activate unnecessarily.

No matter what I did or tried to configure, it all comes down to one thing: the login manager. Honestly, I don't know if this is an issue just for me or if others suffer from the exact same thing. But the question is, can this be fixed if it gets more attention? Or is it a lost cause?

reddit.com
u/zeruxuf — 3 months ago

التبديل بين كروت الشاشة في لينكس

بعد استخدام لـ لينكس لمدة فوق الـ 5 أشهر بدون ويندوز تماما والاعتماد الكامل عليه بكل شي، أنا جدا راضي عن التجربة ومارح أرجع لـ ويندوز أبدا.

لكن في شي واحد فقط مهما حاولت ما قدرت أخليه يشتغل زي ويندوز، ألا وهو التحويل بين كروت الشاشة. في ويندوز إذا كان لابتوبك فيه أكثر من كرت شاشة فـ أنت بتقدر تحول بينهم متى ما بدك بشكل طبيعي بدون تسجيل خروج أو ريستارت، بينما بـ لينكس في أدوات كثيرة للتحويل وشغالة كويس فعلا بس مش بمستوى ويندوز أبدا.

مثلا في عندك أداة supergfxctl اللي من خلالها بتحول بين الكروت: يا الكرت الداخلي فقط، أو الخارجي فقط، أو وضع الـ Hybrid mode اللي بيخلي الكرتين يشتغلوا مع بعض. المشكلة إنه بكل الحالات لازم على الأقل تسجل خروج من النظام ككل عشان يحول بين الكروت، وهذا الشي اللي مجنني.

مهما عملت ومهما حاولت أزبط الموضوع، بالنهاية كل ده معتمد على شي واحد ألا وهو الـ login manager. بصراحة أنا مش عارف هي مشكلة بالنسبة لي أنا فقط ولا في ناس ثانية بتعاني من نفس الموضوع، بس السؤال هل ممكن الموضوع ده يتصلح لو وصل لعدد أكبر من الناس؟ ولا مفيش أمل؟

reddit.com
u/zeruxuf — 3 months ago