Last active
May 9, 2024 00:22
-
-
Save rahuldhole/57e46cb9c22924fbd8b0e744d2c17540 to your computer and use it in GitHub Desktop.
CPU & RAM usage popup | Create a shortcut to call this script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Capture CPU usage | |
cpu_usage=$(top -bn2 | grep '%Cpu' | tail -1 | grep -P '(....|...) id,' | awk '{print 100-$8}') | |
# Capture memory usage | |
memory_usage=$(free -m | grep 'Mem:' | awk '{ print $3/$2*100 }') | |
# Display CPU and memory usage in a popup message using xmessage | |
echo -e "System Usage \nCPU Usage: $cpu_usage% \nMemory Usage: $memory_usage%" | |
echo -e "CPU Usage: $cpu_usage \nMemory Usage: $memory_usage%" | xmessage -center -title "System Usage" -file - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment