From 34c9c74c37b9c9e075b02ada2d50efc93a675fc0 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 25 Feb 2021 01:08:26 +0100 Subject: [PATCH] Add system actions script --- .config/polybar/modules | 4 ++-- .config/rofi/config.rasi | 2 +- .config/sxhkd/bspwm | 4 ---- .config/sxhkd/i3 | 4 ---- .config/sxhkd/sxhkdrc | 12 ++---------- .scripts/system.sh | 22 ++++++++++++++++++++++ 6 files changed, 27 insertions(+), 21 deletions(-) create mode 100755 .scripts/system.sh diff --git a/.config/polybar/modules b/.config/polybar/modules index b68031c..c8012fc 100644 --- a/.config/polybar/modules +++ b/.config/polybar/modules @@ -182,10 +182,10 @@ menu-0-3 = suspend menu-0-3-exec = menu-open-4 menu-1-0 = shutdown -menu-1-0-exec = poweroff +menu-1-0-exec = systemctl poweroff menu-2-0 = reboot -menu-2-0-exec = reboot +menu-2-0-exec = systemctl reboot menu-3-0 = logout menu-3-0-exec = bspc quit diff --git a/.config/rofi/config.rasi b/.config/rofi/config.rasi index b4963c8..5486528 100644 --- a/.config/rofi/config.rasi +++ b/.config/rofi/config.rasi @@ -9,7 +9,7 @@ configuration { display-drun: "run"; /* Layout */ - font: "DejaVu Sans Mono 12"; + font: "DejaVu Sans Mono, Font Awesome 5 Free 12"; lines: 8; width: 50; diff --git a/.config/sxhkd/bspwm b/.config/sxhkd/bspwm index 8642134..4379e07 100644 --- a/.config/sxhkd/bspwm +++ b/.config/sxhkd/bspwm @@ -8,10 +8,6 @@ super + shift + r bspc wm -r && notify-send -t 1000 "bspwm reloaded." -# Logout -super + shift + e - prompt.sh "Logout and exit bspwm?" "bspc quit" - ##--- Node ---## diff --git a/.config/sxhkd/i3 b/.config/sxhkd/i3 index a144389..4add174 100644 --- a/.config/sxhkd/i3 +++ b/.config/sxhkd/i3 @@ -6,10 +6,6 @@ super + shift + r i3-msg restart -# Logout -super + shift + e - prompt.sh "Logout and exit i3?" "i3-msg exit" - #--- Window ---# # Kill focused window diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 03d5f41..9acae6f 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -20,17 +20,9 @@ super + {_,shift} + m super + ctrl + r pkill -USR1 -x sxhkd && notify-send -t 1000 "sxhkd reloaded." -# Lock -super + alt + s - $HOME/.scripts/wm/lock.sh - -# Shutdown +# System super + shift + s - prompt.sh "Shutdown computer?" "poweroff" - -# Reboot -super + shift + w - prompt.sh "Reboot computer?" "reboot" + system.sh # Screen brightness super + {F2,F3} diff --git a/.scripts/system.sh b/.scripts/system.sh new file mode 100755 index 0000000..1b43aa6 --- /dev/null +++ b/.scripts/system.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Rofi prompt for system functions. + +if [ "$WM" = "bspwm" ]; then + logout="bspc quit" +elif [ "$WM" = "i3" ]; then + logout="i3-msg exit" +fi + +commands="\ + Lock:$HOME/.scripts/wm/lock.sh + Suspend:systemctl suspend + Shutdown:systemctl poweroff + Reboot:systemctl reboot + Logout:$logout" + +choice=$(echo "$commands" | cut -d ':' -f 1 | rofi -dmenu -i -p "System") || exit 0 + +exec=$(echo "$commands" | grep "^$choice" | cut -d ':' -f 2-) + +eval "$exec"