From 2cec4a04851250ab87445f180e6d5bfbe3e94faa Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 6 Jul 2023 11:44:39 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=94=B5=E6=BA=90=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home/config/bspwm/bspwmrc | 0 home/config/bspwm/scripts/confirm.sh | 6 +++ home/config/bspwm/scripts/powermenu.sh | 51 ++++++++++++++++++++++++++ home/config/polybar/config.ini | 2 +- home/config/polybar/modules/power.ini | 15 +++----- 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 home/config/bspwm/bspwmrc create mode 100644 home/config/bspwm/scripts/confirm.sh create mode 100644 home/config/bspwm/scripts/powermenu.sh diff --git a/home/config/bspwm/bspwmrc b/home/config/bspwm/bspwmrc new file mode 100644 index 0000000..e69de29 diff --git a/home/config/bspwm/scripts/confirm.sh b/home/config/bspwm/scripts/confirm.sh new file mode 100644 index 0000000..b68bc4f --- /dev/null +++ b/home/config/bspwm/scripts/confirm.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +yes='' +no='' + +echo -e "$yes\n$no" | rofi -dmenu -p 'Are you Sure?' -theme confirm \ No newline at end of file diff --git a/home/config/bspwm/scripts/powermenu.sh b/home/config/bspwm/scripts/powermenu.sh new file mode 100644 index 0000000..197078f --- /dev/null +++ b/home/config/bspwm/scripts/powermenu.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +prompt="Are you sure?" +mesg="Uptime : `uptime -p | sed -e 's/up //g'`" + +option_1="" +option_2="" +option_3="" +option_4="" +option_5="" + +yes='' +no='' + + +rofi_powermenu() { + echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5" | rofi -dmenu -p "$prompt" -mesg "$mesg" -markup-rows -theme powermenu +} + + +confirm_run () { + selected="$(~/.config/bspwm/scripts/confirm.sh)" + + if [[ "$selected" == "$yes" ]]; then + ${1} + else + echo $selected, $1 + exit + fi +} + + +chosen="$(rofi_powermenu)" + +case ${chosen} in + $option_1) + xflock4 --lock + ;; + $option_2) + confirm_run 'bspc quit' + ;; + $option_3) + confirm_run 'systemctl hibernate' + ;; + $option_4) + confirm_run 'systemctl reboot' + ;; + $option_5) + confirm_run 'ssytemctl poweroff' + ;; +esac \ No newline at end of file diff --git a/home/config/polybar/config.ini b/home/config/polybar/config.ini index a2d69c1..ae3b591 100644 --- a/home/config/polybar/config.ini +++ b/home/config/polybar/config.ini @@ -40,7 +40,7 @@ fixed-center = true modules-left = logo workspace pipe-db mpd modules-center = date -modules-right = netspeed volume pipe hibernate pipe logout +modules-right = netspeed volume pipe power tray-position = right diff --git a/home/config/polybar/modules/power.ini b/home/config/polybar/modules/power.ini index 2a1c595..65a2092 100644 --- a/home/config/polybar/modules/power.ini +++ b/home/config/polybar/modules/power.ini @@ -1,14 +1,9 @@ -[module/hibernate] + +[module/power] type = custom/text -;click-left = lxsession-logout -p "" -content = %{T9}%{T-} -content-foreground = ${color.yellow} - -[module/logout] -type = custom/text - -;click-left = lxsession-logout -p "" content = %{T9}襤%{T-} content-foreground = ${color.red} -content-padding = 2 \ No newline at end of file +content-padding = 2 + +click-left = ~/.config/bspwm/scripts/powermenu.sh \ No newline at end of file