sysact works with multiple wm instances

This commit is contained in:
Luke Smith 2022-04-28 15:30:28 -04:00
parent cc0f28be71
commit feeccf15ba
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252
2 changed files with 12 additions and 4 deletions

View file

@ -2,6 +2,6 @@ https://lukesmith.xyz/rss.xml
https://notrelated.xyz/rss https://notrelated.xyz/rss
https://www.youtube.com/feeds/videos.xml?channel_id=UC2eYFnH61tmytImy1mTYvhA "~Luke Smith (YouTube)" https://www.youtube.com/feeds/videos.xml?channel_id=UC2eYFnH61tmytImy1mTYvhA "~Luke Smith (YouTube)"
https://landchad.net/rss.xml https://landchad.net/rss.xml
https://based.cooking/rss.xml https://based.cooking/index.xml
https://artixlinux.org/feed.php "tech" https://artixlinux.org/feed.php "tech"
https://www.archlinux.org/feeds/news/ "tech" https://www.archlinux.org/feeds/news/ "tech"

View file

@ -1,14 +1,22 @@
#!/bin/sh #!/bin/sh
# A dmenu wrapper script for system functions. # A dmenu wrapper script for system functions.
export WM="dwm"
case "$(readlink -f /sbin/init)" in case "$(readlink -f /sbin/init)" in
*systemd*) ctl='systemctl' ;; *systemd*) ctl='systemctl' ;;
*) ctl='loginctl' ;; *) ctl='loginctl' ;;
esac esac
case "$(printf "🔒 lock\n🚪 leave dwm\n♻ renew dwm\n🐻 hibernate\n🔃 reboot\n🖥shutdown\n💤 sleep\n📺 display off" | dmenu -i -p 'Action: ')" in wmpid(){ # This function is needed if there are multiple instances of the window manager.
tree="$(pstree -ps $$)"
tree="${tree#*$WM(}"
echo "${tree%%)*}"
}
case "$(printf "🔒 lock\n🚪 leave $WM\n♻ renew $WM\n🐻 hibernate\n🔃 reboot\n🖥shutdown\n💤 sleep\n📺 display off" | dmenu -i -p 'Action: ')" in
'🔒 lock') slock ;; '🔒 lock') slock ;;
'🚪 leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;; "🚪 leave $WM") kill -TERM "$(wmpid)" ;;
'♻️ renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;; "♻️ renew $WM") kill -HUP "$(wmpid)" ;;
'🐻 hibernate') slock $ctl hibernate ;; '🐻 hibernate') slock $ctl hibernate ;;
'💤 sleep') slock $ctl suspend ;; '💤 sleep') slock $ctl suspend ;;
'🔃 reboot') $ctl reboot -i ;; '🔃 reboot') $ctl reboot -i ;;