Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

mem

output.mp4

mem is a blazing fast, lightweight RAM usage checker for Linux.

It is specifically optimized to parse the Linux /proc filesystem instantly, accurately accounting for shared memory while easily handling hundreds of processes in a fraction of a second.

🧠 How it Works

  1. Instantly filters all running processes to find those matching your target query.
  2. Safely verifies read-access to each process's /proc/[pid]/smaps_rollup. If the kernel denies access (e.g., when checking a root process as a standard user), it seamlessly falls back to /proc/[pid]/status for VmRSS.
  3. Rapidly sums up the memory values across all matched processes.
  4. Converts the total memory (in Kilobytes) to Megabytes (MB) using integer arithmetic.

📦 Dependencies

  • Bash (For the core script logic)
  • grep & awk (Standard POSIX tools for high-speed calculation)
  • procps / pgrep (Standard Linux utility for process matching)
  • libnotify / notify-send (Required for desktop notifications in --gui mode)
  • An Application Launcher (Required for --gui mode). Supported out-of-the-box:
    • fuzzel
    • rofi
    • wofi
    • tofi
    • bemenu
    • dmenu

🚀 Installation

  1. Download or copy the mem script to a directory in your $PATH, such as ~/.local/bin/:
    nano ~/.local/bin/mem
  2. Make the script executable:
    chmod +x ~/.local/bin/mem

📖 Usage

CLI Mode

Pass a process name or a fragment of a command to see its total RAM usage printed to the terminal.

$ mem discord
254.12 MB

$ mem code
982.50 MB

$ mem --all
3442.97 MB

GUI Mode

Run the script with the --gui flag. This will open your preferred application launcher, prompt you to type a process name, and then display a desktop notification with the resulting memory usage.

$ mem --gui

This is highly useful for binding to a keyboard shortcut in your Window Manager.

Example: Keybind in Labwc / Openbox (rc.xml)

<keybind key="W-m">
  <action name="Execute" command="mem --gui" />
</keybind>

Example: Keybind in Sway / i3 (config)

bindsym Mod4+m exec mem --gui

Example: Keybind in Hyprland (hyprland.conf)

bind = SUPER, m, exec, mem --gui

⚙️ Configuration

You can customize the behavior of the GUI prompt by editing the configuration variables at the top of the mem script:

# Set to "fuzzel", "rofi", "wofi", "tofi", "bemenu", or "dmenu" to force a specific launcher. 
# Leave empty to auto-detect!
LAUNCHER_OVERRIDE=""
PROMPT_TEXT="Check RAM usage for: "

If LAUNCHER_OVERRIDE is left blank, mem will automatically scan your system and pick the best available launcher. If you have multiple installed, you can force your preferred one by typing its name in the quotes!

📄 License

This script is open-sourced software licensed under the MIT license. You are free to use, modify, and distribute it!

About

A simple RAM usage checker written in Bash

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages