diff options
| author | darkeddie <lyttle.daniel@gmail.com> | 2023-11-25 09:26:40 +1100 |
|---|---|---|
| committer | darkeddie <lyttle.daniel@gmail.com> | 2023-11-25 09:26:40 +1100 |
| commit | d5b06a4c6301befd1e5e4e9efa189a71aee51e27 (patch) | |
| tree | 9d80c5bff17593c4413937b7fab22ea1a676d239 /config/hypr | |
| parent | 61bbe3b7d94387ede06353e626465f2987932afe (diff) | |
Implementation of Rofipower
Diffstat (limited to 'config/hypr')
| -rw-r--r-- | config/hypr/configs/Keybinds.conf | 2 | ||||
| -rwxr-xr-x | config/hypr/scripts/rofipower.sh | 67 |
2 files changed, 68 insertions, 1 deletions
diff --git a/config/hypr/configs/Keybinds.conf b/config/hypr/configs/Keybinds.conf index c072b4d7..8ad56515 100644 --- a/config/hypr/configs/Keybinds.conf +++ b/config/hypr/configs/Keybinds.conf @@ -30,7 +30,7 @@ bind = $mainMod, Q, killactive, bind = $mainMod, Return, exec, $term bind = $mainMod, T, exec, $files bind = CTRL ALT, L, exec, $scriptsDir/LockScreen.sh -bind = CTRL ALT, P, exec, $scriptsDir/Wlogout.sh +bind = CTRL ALT, P, exec, $scriptsDir/rofipower.sh bind = $mainMod CTRL, S, exec, $scriptsDir/RofiBeats.sh bind = $mainMod ALT, E, exec, $scriptsDir/RofiEmoji.sh bind = $mainMod, H, exec, $scriptsDir/KeyHints.sh diff --git a/config/hypr/scripts/rofipower.sh b/config/hypr/scripts/rofipower.sh new file mode 100755 index 00000000..7bb70e9c --- /dev/null +++ b/config/hypr/scripts/rofipower.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Swayconfig +SWAYCONFIG="$HOME/.config/swaylock/config" + +# CMDs +uptime="`uptime -p | sed -e 's/up //g'`" +host=`hostnamectl hostname` + +# Options +shutdown=' Shutdown' +reboot=' Reboot' +lock=' Lock' +suspend=' Suspend' +logout=' Logout' +hibernate=' Hibernate' + +# Rofi CMD +rofi_cmd() { + rofi -dmenu -p " $USER@$host" -mesg " Uptime: $uptime" -sep '|' -eh 2 -theme ~/.config/rofi/config-powermenu.rasi +} + +# Pass variables to rofi dmenu +run_rofi() { + echo -e "$lock\0meta\x1fl|$suspend\0meta\x1fu|$logout\0meta\x1fe|$reboot\0meta\x1fr|$shutdown\0meta\x1fs|$hibernate\0meta\x1fh" | rofi_cmd +} + +# Execute Command +run_cmd() { + if [[ $1 == '--shutdown' ]]; then + systemctl poweroff + elif [[ $1 == '--reboot' ]]; then + systemctl reboot + elif [[ $1 == '--suspend' ]]; then + systemctl suspend + elif [[ $1 == '--logout' ]]; then + hyprctl dispatch exit 0 + elif [[ $1 == '--hibernate' ]]; then + systemctl hibernate + fi +} + +# Actions +chosen="$(run_rofi)" +case ${chosen} in + $shutdown) + run_cmd --shutdown + ;; + $reboot) + run_cmd --reboot + ;; + $hibernate) + run_cmd --hibernate + ;; + $lock) + sleep 0.5s; swaylock --config ${SWAYCONFIG} & disown + ;; + $suspend) + run_cmd --suspend + ;; + $logout) + run_cmd --logout + ;; + $hibernate) + run_cmd --hibernate + ;; +esac
\ No newline at end of file |
