diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-02-22 23:31:46 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-02-22 23:37:08 +0100 |
| commit | 00e4e889cd5864156a737318669303f2f775cafe (patch) | |
| tree | 2f61023fce1c0ab1a707f97845373b167a1169c0 /roles/hyprland | |
| parent | 60a3569f673b53f54a360340e9e57ab4caa5f391 (diff) | |
Configure power menu using tofi
Since it was almost impossible to change the spacing between the gum
choose items, I used tofi instead, which is already themed and the only
downside to it, is that it allows typing input on the menu which isn't
my favorite but it's also not bad at all
Diffstat (limited to 'roles/hyprland')
| -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 |
3 files changed, 48 insertions, 0 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 |
