Command line interface for your desktopModern desktops are certainly very easy to use and have made Linux available even to unskilled users. On the other hand, I also realized that among the most advanced users there is little knowledge on how to use the terminal to govern the desktop. In this post you’ll find a short list of commands, especially useful in scripting for performing actions in the most used desktop environments - of course this is just a starting point: explore the man pages and visit freedesktop.org to understand in depth the underlying concepts. Enjoy!
Opens a file with the default application, obtaining the same effect you get when you click it from a file manager, or a URL with the default web browser.
This can open the default email client and compose an email.
Controls the screensaver and also other related items like screen lock and OS suspension.
systemctl suspend (or pm-suspend)
Suspends the OS.
systemctl hibernate (or pm-hibernate)
Hibernates the OS.
Create a desktop notification.
Create a wide variety of dialogs.
Graphical version for sudo.
A simple and nearly useless example:
choice="$(zenity --width=200 --height=200 --list \
--column "" --title="Exit menu" "Lock" \
"Suspend" "Hibernate" "Shutdown" 2>/dev/null)"
case $choice in
gksudo "systemctl suspend"
gksudo "systemctl hibernate"
gksudo "shutdown -h now"
Posted on 2019-08-18
Copyright © 2019-2021 Marcello Zaniboni