diff options
| -rwxr-xr-x | roles/hyprland/files/scripts/power.sh | 38 | ||||
| -rw-r--r-- | roles/hyprland/tasks/main.yml | 2 | ||||
| -rw-r--r-- | roles/hyprland/templates/rules.conf.j2 | 8 | ||||
| -rw-r--r-- | roles/tofi/tasks/main.yml | 2 | ||||
| -rwxr-xr-x | roles/waybar/files/scripts/power-menu | 8 |
5 files changed, 56 insertions, 2 deletions
diff --git a/roles/hyprland/files/scripts/power.sh b/roles/hyprland/files/scripts/power.sh new file mode 100755 index 00000000..77e37626 --- /dev/null +++ b/roles/hyprland/files/scripts/power.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Use the commented styling to get tofi fullscreen theme instead of +# using the hpyrland windowrule workaround to get the dimming effect + # --width 100% \ + # --height 120% \ + # --font-size 20 \ + # --anchor center \ + # --border-width 0 \ + # --outline-width 0 \ + # --padding-top 50% \ + # --padding-left 42% \ + # --result-spacing 10 \ + # --placeholder-text "" \ + # --prompt-text "Power:" \ + # --background-color "#000B" +ACTION=$(printf ' Shutdown\n Reboot\n Suspend' | tofi \ + --width 450 \ + --height 300 \ + --font-size 20 \ + --anchor center \ + --prompt-text "Power:" \ + --placeholder-text "" \ + --result-spacing 10 +) + + +case "$ACTION" in + *Shutdown*) + hyprctl dispatch exec hyprshutdown --no-fork -t "Shutting down..." --post-cmd "systemctl poweroff" + ;; + *Reboot*) + hyprctl dispatch exec hyprshutdown --no-fork -t "Restarting..." --post-cmd "systemctl reboot" + ;; + *Suspend*) + loginctl lock-session && systemctl suspend + ;; +esac diff --git a/roles/hyprland/tasks/main.yml b/roles/hyprland/tasks/main.yml index e9b4301f..7cea14ab 100644 --- a/roles/hyprland/tasks/main.yml +++ b/roles/hyprland/tasks/main.yml @@ -111,3 +111,5 @@ dest: "/etc/hypr/scripts/wifi.sh" - src: "scripts/bluetooth.sh" dest: "/etc/hypr/scripts/bluetooth.sh" + - src: "scripts/power.sh" + dest: "/etc/hypr/scripts/power.sh" diff --git a/roles/hyprland/templates/rules.conf.j2 b/roles/hyprland/templates/rules.conf.j2 index 34253bdb..fe90ea0c 100644 --- a/roles/hyprland/templates/rules.conf.j2 +++ b/roles/hyprland/templates/rules.conf.j2 @@ -35,3 +35,11 @@ windowrule = float on, match:class steam windowrule = center on, match:class steam, match:title Steam windowrule = opacity 1.0 override 1.0 override, match:title Steam windowrule = size 460 800, match:class steam, match:title Friends List + +# Power menu +# Workaround dimming, by creating a 1x1 behind the tofi menu and configure dimming around that window +windowrule = float on, match:class work.kartoffln.power\-menu +windowrule = center on, match:class work.kartoffln.power\-menu +windowrule = size 1 1, match:class work.kartoffln.power\-menu +windowrule = stay_focused on, match:class work.kartoffln.power\-menu +windowrule = dim_around on, match:class work.kartoffln.power\-menu diff --git a/roles/tofi/tasks/main.yml b/roles/tofi/tasks/main.yml index c7e30763..552745d1 100644 --- a/roles/tofi/tasks/main.yml +++ b/roles/tofi/tasks/main.yml @@ -3,7 +3,7 @@ become: true become_user: "aur_builder" kewlfft.aur.aur: - name: "tofi" + name: "tofi-git" state: "present" use: "yay" diff --git a/roles/waybar/files/scripts/power-menu b/roles/waybar/files/scripts/power-menu index d9be8315..9fb4b3cd 100755 --- a/roles/waybar/files/scripts/power-menu +++ b/roles/waybar/files/scripts/power-menu @@ -1,3 +1,9 @@ #!/bin/bash -exec setsid uwsm-app -- /etc/hypr/scripts/power.sh +# Launch a specific class that is used to dim the background of the power menu +# This is done via a workaround window rules by creating a window size 1x1 behind the tofi menu +# and using this fake window to stay focused and dim around it +# This looks nicer than fiddling with the tofi styling in power.sh +exec setsid uwsm-app -- alacritty --class="work.kartoffln.power-menu" -e "/etc/hypr/scripts/power.sh" +# if you prefer you can use the following code, and update the tofi styling inside the script +# exec setsid uwsm-app -- /etc/hypr/scripts/power.sh |
