Category: linux

  • Stop GNOME from Opening Duplicate Windows Across Workspaces

    If you use Virtual Desktops (Workspaces) in Linux GNOME (Debian/Ubuntu), you have likely run into this frustrating issue:

    You have Firefox open on Workspace 1 and your Email open on Workspace 2. While checking your email on Workspace 2, you click the Firefox dock icon to look something up. Instead of jumping you back to your open browser, GNOME spawns a brand-new, duplicate Firefox window.


    🔍 Why This Happens

    This happens due to a setting called Workspace Isolation.

    When active, your Dock treats each workspace like an isolated room. If you are on Workspace 2, the Dock completely ignores apps running on Workspace 1. Because it cannot “see” your open Firefox, clicking the icon makes the Dock act like a fresh application launcher rather than a window switcher—resulting in annoying duplicate windows.


    🛠️ The Fix: Run These Commands

    You can fix this instantly without restarting. Open your Terminal and copy-paste these commands:

    1. Fix the Dock (Dash to Dock)

    This forces the dock to track apps globally across all workspaces instead of isolating them:

    bash

    gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces false
    

    Use code with caution.

    (If you are on standard Ubuntu, run this instead: gsettings set org.gnome.shell.extensions.ubuntu-dock isolate-workspaces false)

    2. Fix the App Switcher (Alt + Tab)

    This ensures your Alt + Tab menu also lets you see and switch to apps living on other workspaces:

    bash

    gsettings set org.gnome.desktop.interface alt-tab-window-filter 'all-workspaces'
    

    Use code with caution.


    🎉 The Result

    The changes apply immediately. Clicking an app icon will now seamlessly slide your desktop back and forth between workspaces to show your already-opened apps, completely eliminating accidental duplicates.

  • Pin a Folder -Dash to Dock

    Step 1: Generate the Folder Launcher via Terminal

    Instead of manually navigating hidden system directories, we can use a quick terminal command to generate a custom application shortcut.

    Open your terminal and paste the following block of code:

    bash

    cat << 'EOF' > ~/.local/share/applications/dock-folder-kids.desktop
    [Desktop Entry]
    Name=Kids Documents
    Comment=Open Kids folder directly from the dock
    Exec=nautilus /home/sumnima/Documents/kids
    Icon=folder-documents
    Terminal=false
    Type=Application
    Categories=GNOME;Utility;
    EOF
    
    chmod +x ~/.local/share/applications/dock-folder-kids.desktop
    

    Use code with caution.

    How It Works:

    • Name= This is the display title that appears when you search your system.
    • Exec= This tells your system to launch Nautilus and automatically target your designated folder path (/home/sumnima/Documents/kids).
    • Icon= Assigns a clean system folder icon to the shortcut.
    • chmod +x Makes the file executable so GNOME recognizes it as an active system app launcher.

    Step 2: Search and Pin It to the Dock

    Now that your system recognizes the folder path as an application, pinning it takes just a few clicks:

    1. Press the Super key (the Windows or Command key) to pull up the GNOME Activities Overview.
    2. Type “Kids Documents” into the search bar.
    3. Right-click on the folder icon that appears in your search results.
    4. Click Add to Favorites (or Pin to Dash depending on your GNOME version).

    Your custom folder will instantly appear on your Dash to Dock, giving you single-click access to your files from anywhere!

  • Maxing Out an Older Intel Laptop GPU for a Stutter-Free Linux Desktop (Debian GNOME)

    If you are running a modern Linux desktop environment like GNOME on an older laptop—such as a 6th Generation Intel Core i5 (Skylake architecture) with Intel HD Graphics 520—you might notice that window animations, overview blurs, and folder browsing can feel sluggish or micro-stutter.

    Worse yet, many users experience a frustrating, random screen flickering on their built-in laptop display, even though an external HDMI monitor works perfectly.

    By default, Linux prioritizes battery life by keeping your CPU and integrated GPU (iGPU) in deep sleep states. However, this causes noticeable lag when rendering modern desktop effects. Here is the ultimate step-by-step guide to unlocking 100% of your hardware’s power for a completely smooth, lag-free desktop experience—without disabling any visual features.

    The Core Hardware Details

    This guide is specifically tailored for:

    • CPU: Intel Core i5 6th Gen (Skylake / Gen9 Graphics architecture)
    • GPU: Intel HD Graphics 520 (Integrated)
    • OS: Debian Linux (running GNOME on X11/Xorg)

    Step 1: Fix Built-in Screen Flickering & Stutters

    Older Intel chips feature aggressive power-saving protocols that conflict with modern Linux kernels, causing the built-in screen to flash or stutter. We fix this by updating the kernel boot parameters.

    Open your terminal and run this command to safely update your GRUB configuration:

    bash

    sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.enable_psr=0 i915.enable_dc=0 i915.enable_fbc=0 intel_idle.max_cstate=2"/' /etc/default/grub
    

    Use code with caution.

    Why we do this:

    • i915.enable_psr=0: Disables Panel Self Refresh. PSR drops the screen refresh rate to save power when the image is static, but on Skylake chips, it causes massive screen flickering.
    • i915.enable_dc=0: Disables Display C-states (power-saving display sleep modes), ensuring stable voltage to the internal laptop monitor.
    • i915.enable_fbc=0: Disables Framebuffer Compression to prevent visual artifacts and blinking on older panels.
    • intel_idle.max_cstate=2: Prevents the CPU from entering deep sleep states that make the system lag when it tries to wake up for an animation.

    Apply the changes:

    bash

    sudo update-grub
    

    Use code with caution.

    Reboot your laptop:

    bash

    sudo reboot
    

    Use code with caution.


    Step 2: Force the GPU to Wake Up (Boost Clock Speeds)

    By default, your Intel GPU sits idle at a tiny 39 MHz and rests in a deep sleep state (99% RC6 power saving). When you trigger a desktop animation or open a heavy folder, the time it takes the GPU to ramp its clocks up causes a split-second lag.

    We can force the GPU to step up out of its sleep state and run at higher frequencies (like 425+ MHz) for snappy rendering.

    Create the optimization script file:

    bash

    sudo nano /usr/local/bin/boost-gpu.sh
    

    Use code with caution.

    Paste these exact commands inside the file script:

    bash

    #!/bin/bash
    MAX_FREQ=$(cat /sys/class/drm/card0/gt_max_freq_mhz)
    echo $MAX_FREQ > /sys/class/drm/card0/gt_min_freq_mhz
    echo $MAX_FREQ > /sys/class/drm/card0/gt_boost_freq_mhz
    

    Use code with caution.

    Save, exit, and make it executable:
    (Press Ctrl+O, Enter, then Ctrl+X to save and exit nano before running this)

    bash

    sudo chmod +x /usr/local/bin/boost-gpu.sh
    

    Use code with caution.

    Automate it on Every Boot

    Because graphics hardware entries reset when you restart, we create a system service configuration to apply this automatically on boot.

    Create the system automation service file:

    bash

    sudo nano /etc/systemd/system/boost-gpu.service
    

    Use code with caution.

    Paste this text configuration profile inside:

    ini

    [Unit]
    Description=Maximize Intel GPU Clock Frequencies
    After=multi-user.target
    
    [Service]
    Type=oneshot
    ExecStart=/usr/local/bin/boost-gpu.sh
    RemainAfterExit=true
    
    [Install]
    WantedBy=multi-user.target
    

    Use code with caution.

    Reload the system daemon:
    (Press Ctrl+O, Enter, then Ctrl+X to save and exit nano before running this)

    bash

    sudo systemctl daemon-reload
    

    Use code with caution.

    Enable and run the service execution:

    bash

    sudo systemctl enable --now boost-gpu.service
    

    Use code with caution.


    Step 3: Unbottle the CPU for Instant Folder Loading

    Even with a fast GPU, opening directories, generating folder layouts, and parsing system indexes relies heavily on the CPU cores. If the CPU is stuck in an aggressive “powersave” governor, folder clicks will feel delayed.

    Force all CPU cores into high-responsiveness mode by running:

    bash

    echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    

    Use code with caution.

    Why we do this:

    This instantly shifts the Intel i5 cores into Performance Mode, meaning they will instantly handle background processing tasks without waiting to scale up their clock speeds.


    The Verdict: Check Your Results!

    Open a terminal and monitor your hardware performance live:

    bash

    sudo intel_gpu_top
    

    Use code with caution.

    You will immediately see that the GPU clock speed has jumped from 39 MHz to 425+ MHz, power draw has significantly increased to handle complex visuals, and the Render/3D engine will actively scale up past 15%+ to render GNOME’s beautiful blurs fluidly.


    How to Undo Everything (Restore Battery Power Mode)

    If you ever need to travel or rely purely on your laptop battery, you can revert these tweaks back to Debian’s original power-saving defaults with these quick steps.

    Revert the GRUB parameters to restore the basic boot line:

    bash

    sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/' /etc/default/grub
    

    Use code with caution.

    bash

    sudo update-grub
    

    Use code with caution.

    Disable the GPU Boost Service to stop the GPU from locking onto highest clock rates:

    bash

    sudo systemctl disable --now boost-gpu.service
    

    Use code with caution.

    bash

    sudo rm /etc/systemd/system/boost-gpu.service
    

    Use code with caution.

    bash

    sudo rm /usr/local/bin/boost-gpu.sh
    

    Use code with caution.

    Reset the CPU Governor back to native dynamic power scaling setup:

    bash

    echo "powersave" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    

    Use code with caution.

    Reboot your system to finalize the return to battery-saving modes:

    bash

    sudo reboot
    

    Use code with caution.

    Enjoy a completely smooth, full-featured Linux desktop on your classic laptop!

  • Project: Ultra-Light YouTube Music Player

    A “Zero-Bloat” Linux Implementation

    1. Overview

    Most music streaming on Linux is done via web browsers (Chrome/Firefox) or Electron apps (Spotify). These methods consume massive amounts of RAM and CPU.

    This project implements a headless audio engine approach. It uses a Python wrapper to trigger a high-performance media engine (mpv) which streams audio via yt-dlp. To ensure the user has a visual interface, it uses the MPRIS (Media Player Remote Interfacing Specification) protocol to broadcast song metadata (title, artist, cover art) directly to the Linux Desktop Environment (GNOME, KDE, etc.).

    Key Benefits:

    • RAM Usage: ~40MB (vs 600MB+ for a browser).
    • CPU Usage: Near 0% (audio-only decoding).
    • UI: Native system-level controls in your top bar or dock.
    • Automation: Starts automatically on login without any terminal windows.

    2. The Architecture

    1. The Fetcher (yt-dlp): Extracts the raw audio stream from YouTube URLs.
    2. The Engine (mpv): A lightweight, command-line media player that handles the audio playback.
    3. The Bridge (mpv-mpris): A plugin that “speaks” to your Linux Desktop.
    4. The Controller (Python): A tiny script to launch the engine and manage the playlist.
    5. The Interface (Desktop Environment): The actual buttons you click in your dock/bar.

    3. Installation Guide

    Step 1: Install System Dependencies

    Open your terminal and install the core requirements.

    For Debian/Ubuntu/Mint:

    code Bash

    sudo apt update
    sudo apt install mpv python3 wget

    Crucial: Install the latest yt-dlp
    The version in the standard Linux repositories is often outdated, which breaks YouTube compatibility. We must install the latest version directly from GitHub:

    code Bash

    sudo apt remove yt-dlp
    sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
    sudo chmod a+rx /usr/local/bin/yt-dlp

    Install the MPRIS Bridge:
    This allows the player to talk to your system bar.

    code Bash

    sudo apt install mpv-mpris

    Step 2: Create the Python Controller

    Create a directory for your scripts and create the player file.

    code Bash

    mkdir -p ~/Documents/py
    nano ~/Documents/py/yt-music-player.py

    Paste the following code:
    (Replace the PLAYLIST_URL with your own YouTube Music playlist link)

    code Python

    import subprocess
    import sys
    
    # Replace with your YouTube Music Playlist URL
    PLAYLIST_URL = "https://music.youtube.com/playlist?list=YOUR_PLAYLIST_ID_HERE"
    
    def start_player():
        command = [
            "mpv",
            "--no-video",                      # Only play audio (saves CPU/RAM)
            "--input-ipc-server=/tmp/mpvsocket", # Enables control
            "--ytdl-format=bestaudio",         # Forces highest quality audio
            PLAYLIST_URL
        ]
    
        try:
            print("--- Ultra-Light YT Player Active ---")
            subprocess.run(command, check=True)
        except subprocess.CalledProcessError:
            print("Error: mpv exited unexpectedly.")
        except KeyboardInterrupt:
            print("\nPlayer stopped by user.")
        except Exception as e:
            print(f"Error: {e}")
    
    if __name__ == "__main__":
        start_player()

    Save and exit (Ctrl+O, Enter, Ctrl+X).


    Step 3: Enable “No-Terminal” Autostart

    To make the player start automatically when you log in without any windows popping up:

    1. Create the autostart directory: code Bashmkdir -p ~/.config/autostart
    2. Create the desktop entry: code Bashnano ~/.config/autostart/yt-music.desktop
    3. Paste the following (ensure paths are correct):
      (Replace sumnima with your actual Linux username)

    code Ini

    [Desktop Entry]
    Type=Application
    Name=YT Music Tiny Player
    Comment=Starts YouTube Music in background
    Exec=/usr/bin/python3 /home/sumnima/Documents/py/yt-music-player.py
    Terminal=false
    X-GNOME-Autostart-enabled=true

    Save and exit (Ctrl+O, Enter, Ctrl+X).


    4. Setting Up the Visual UI (Desktop Specific)

    The player is now running, but your Desktop needs a “receiver” to show the buttons.

    For GNOME Users (Default Debian)

    GNOME does not show media controls by default. You must install an extension:

    1. Install the browser connector: sudo apt install chrome-gnome-shell
    2. Go to: Media Controls GNOME Extension
    3. Switch the toggle to ON.

    For KDE Plasma Users

    KDE handles this natively.

    1. Right-click your Taskbar/Panel.
    2. Select “Add Widgets”.
    3. Search for “Media Player” and drag it onto your bar.

    5. Management & Troubleshooting

    How to stop the player

    Since there is no window, you cannot click “X”. Use the terminal to kill the process:

    code Bash

    pkill -f yt-music-player.py

    Troubleshooting

    • “Empty Playlist” error: Your yt-dlp is likely outdated. Run the update commands in Step 1 again.
    • No controls in bar: Ensure mpv-mpris is installed and that you have installed the GNOME Extension or KDE Widget as described in Section 4.
    • Music not playing: Ensure your playlist is set to Public or Unlisted on YouTube. Private playlists cannot be accessed by yt-dlp without complex authentication.

    The Philosophy of Efficiency:

    A Comparative Analysis of Linux Media Playback Architectures

    Introduction: The Problem of “Software Bloat”

    In modern computing, there is a growing trend toward Software Bloat. To make software easier to build, developers often bundle massive, unnecessary libraries into every application. This results in “heavy” software that consumes excessive system resources (RAM and CPU) even when performing simple tasks like playing music.

    This document compares the three primary ways to play YouTube Music on Linux, highlighting why the Modular/Unix Approach is the superior choice for performance and stability.


    1. The “Browser-Centric” Approach (The Heavy Way)

    Method: Opening music.youtube.com in a web browser (Chrome, Firefox, Edge).

    • The Motivation: Extreme ease of use. No installation required; just a URL and a click.
    • The Technical Cost:
      • Resource Hogging: Browsers are multi-process environments. A single YouTube tab requires the browser to manage the DOM (Document Object Model), JavaScript engines, GPU acceleration, and hundreds of background processes.
      • Consumption: It is common for a single tab to consume 500MB to 1GB of RAM.
      • Inefficiency: You are running an entire operating system (the browser) just to play a single audio stream.
    • The UI Limitation: Controls are “trapped” inside the tab. You must switch focus to the browser to change a song.

    2. The “Electron” Approach (The Bloated Way)

    Method: Using desktop apps like Spotify, Discord, or specialized YouTube Music wrappers.

    • The Secret: Most “Desktop Apps” today are actually Electron Apps. Electron is a framework that wraps a web browser (Chromium) inside a desktop window.
    • The Technical Cost:
      • The Lie of the “App”: When you install an Electron app, you aren’t installing a lightweight program; you are installing a second web browser that only knows how to do one thing.
      • Overhead: It inherits all the RAM and CPU costs of the Browser Approach but adds the extra overhead of a desktop window wrapper.
    • The UI Limitation: While it looks like a “real” app, it remains a heavy, isolated silo of resources.

    3. The “Modular” Approach (The Power User Way)

    Method: Combining specialized, single-purpose tools via the command line (The project you just built).

    This method follows the Unix Philosophy: “Write programs that do one thing and do it well. Write programs to work together.”

    The Modular Breakdown:

    ComponentRoleWhy it’s efficient
    yt-dlpThe FetcherIt does one thing: Extracts the raw audio stream. It does not render images, ads, or comments.
    mpvThe EngineIt does one thing: Decodes audio. By using the –no-video flag, it ignores all visual data, saving massive amounts of CPU.
    mprisThe TranslatorIt does one thing: Sends metadata to your system. It acts as a lightweight bridge between the engine and your UI.
    • The Result: You achieve the exact same functional result (streaming music) but with 95% less resource consumption. You are using roughly 40MB of RAM instead of 1000MB.
    • The UI Advantage: Because you used the MPRIS protocol, the interface is System-Native. The controls live in your taskbar/dock, meaning you never have to “open” an app to control your music.

    Summary Comparison Table

    FeatureBrowser MethodElectron MethodYour Modular Method
    RAM UsageVery HighExtremely HighUltra-Low
    CPU UsageModerate/HighModerate/HighMinimal
    ComplexityVery LowLowMedium (Requires Setup)
    ControlTab-LockedApp-LockedSystem-Wide (Native)
    PhilosophyConveniencePackagingEfficiency & Modularism

    Conclusion: Engineering vs. Installation

    Most users install software. Power users engineer environments.

    By combining yt-dlp, mpv, and mpris, you have not just installed a player; you have engineered a custom-tailored, invisible service that respects your hardware. This is the “Right Way” to use Linux—turning a general-purpose computer into a highly optimized, specialized machine.