From b3474e85dcce03e7de0b4a4e30ff7fad1f38ee26 Mon Sep 17 00:00:00 2001 From: ryukamish Date: Sat, 11 Apr 2026 18:25:38 +0530 Subject: add: small bash scripts for added functionality --- scripts/rofi-powermenu | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/rofi-powermenu (limited to 'scripts/rofi-powermenu') diff --git a/scripts/rofi-powermenu b/scripts/rofi-powermenu new file mode 100755 index 0000000..6209944 --- /dev/null +++ b/scripts/rofi-powermenu @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +power_args=$(printf '%b' ' Lock\nLogout\n Restart\n󰒲 Suspend\n󰋊 Hibernate\n󰚦 Shutdown' | + rofi -dmenu -p "󰐥 " -i -theme-str 'window {width: 12em; padding: 2px; height: 16em;}') + +case "$power_args" in +*Lock) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; then + command -v swaylock &>/dev/null && swaylock + elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then + hyprlock + fi + ;; +*Logout) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; then + niri msg action quit + elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then + hyprctl dispatch exit + fi + ;; +*Restart) + systemctl reboot + ;; +*Suspend) + systemctl suspend + ;; +*Hibernate) + systemctl hibernate + ;; +*Shutdown) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; then + systemctl poweroff + elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then + hyprctl dispatch killactive && sleep 0.1 && hyprctl dispatch killactive && sleep 0.1 && systemctl poweroff + # hyprctl clients -j | jq -r '.[].pid' | xargs -r kill -9; systemctl poweroff + fi + ;; +esac -- cgit v1.3