feat: rofi power menu

This commit is contained in:
hesam-init 2024-02-14 15:39:53 +03:30
parent 577f8c0f9b
commit 98cf38ea31
4 changed files with 53 additions and 44 deletions

View file

@ -36,13 +36,13 @@ The following packages are required for the proper functioning of Hyprland on Vo
<details>
<summary><strong>System Components</strong></summary>
- dbus
- seatd
- polkit
- dbus : service
- seatd : service
- elogind : service
- polkit : service
- polkit-kde-agent
- elogind
- [ly](https://github.com/fairyglade/ly) : service
- mesa-dri
- [ly](https://github.com/fairyglade/ly) : display manager
- pipewire
- pipewire-pulse
- pipewire-devel

View file

@ -4,7 +4,7 @@ source $HOME/.config/hypr/scripts/env.sh
case $1 in
d) exec $rofi_dir/launchers/type-$launcher_type/launcher.sh ;;
p) exec $rofi_dir/powermenu/type-$powermenu_type/powermenu.sh ;;
p) exec $rofi_dir/applets/bin/powermenu.sh ;;
s) exec $rofi_dir/applets/bin/screenshot.sh ;;
h)
echo -e "rofilaunch.sh [action]\nwhere action,"

View file

@ -10,19 +10,29 @@ source "$HOME"/.config/rofi/applets/shared/theme.bash
theme="$type/$style"
# Theme Elements
prompt="`hostname`"
mesg="Uptime : `uptime -p | sed -e 's/up //g'`"
prompt="$(hostname)"
mesg="Uptime : $(uptime -p | sed -e 's/up //g')"
if [[ ( "$theme" == *'type-1'* ) || ( "$theme" == *'type-3'* ) || ( "$theme" == *'type-5'* ) ]]; then
if [[ "$theme" == *'type-1'* ]]; then
list_col='1'
list_row='6'
elif [[ ( "$theme" == *'type-2'* ) || ( "$theme" == *'type-4'* ) ]]; then
list_col='6'
list_row='5'
win_width='400px'
elif [[ "$theme" == *'type-3'* ]]; then
list_col='1'
list_row='5'
win_width='120px'
elif [[ "$theme" == *'type-5'* ]]; then
list_col='1'
list_row='5'
win_width='520px'
elif [[ ("$theme" == *'type-2'*) || ("$theme" == *'type-4'*) ]]; then
list_col='5'
list_row='1'
win_width='670px'
fi
# Options
layout=`cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2`
layout=$(cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2)
if [[ "$layout" == 'NO' ]]; then
option_1=" Lock"
option_2=" Logout"
@ -45,7 +55,8 @@ fi
# Rofi CMD
rofi_cmd() {
rofi -theme-str "listview {columns: $list_col; lines: $list_row;}" \
rofi -theme-str "window {width: $win_width;}" \
-theme-str "listview {columns: $list_col; lines: $list_row;}" \
-theme-str 'textbox-prompt-colon {str: "";}' \
-dmenu \
-p "$prompt" \
@ -56,7 +67,7 @@ rofi_cmd() {
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5\n$option_6" | rofi_cmd
echo -e "$option_1\n$option_2\n$option_3\n$option_5\n$option_6" | rofi_cmd
}
# Confirmation CMD
@ -78,52 +89,51 @@ confirm_exit() {
}
# Confirm and execute
confirm_run () {
confirm_run() {
selected="$(confirm_exit)"
if [[ "$selected" == "$yes" ]]; then
${1} && ${2} && ${3}
else
exit
fi
${1} && ${2} && ${3}
else
exit
fi
}
# Execute Command
run_cmd() {
if [[ "$1" == '--opt1' ]]; then
betterlockscreen -l
swaylock
elif [[ "$1" == '--opt2' ]]; then
confirm_run 'kill -9 -1'
elif [[ "$1" == '--opt3' ]]; then
confirm_run 'mpc -q pause' 'amixer set Master mute' 'systemctl suspend'
elif [[ "$1" == '--opt4' ]]; then
confirm_run 'systemctl hibernate'
confirm_run 'loginctl hibernate'
elif [[ "$1" == '--opt5' ]]; then
confirm_run 'systemctl reboot'
confirm_run 'loginctl reboot'
elif [[ "$1" == '--opt6' ]]; then
confirm_run 'systemctl poweroff'
confirm_run 'loginctl poweroff'
fi
}
# Actions
chosen="$(run_rofi)"
case ${chosen} in
$option_1)
run_cmd --opt1
;;
$option_2)
run_cmd --opt2
;;
$option_3)
run_cmd --opt3
;;
$option_4)
run_cmd --opt4
;;
$option_5)
run_cmd --opt5
;;
$option_6)
run_cmd --opt6
;;
$option_1)
run_cmd --opt1
;;
$option_2)
run_cmd --opt2
;;
$option_3)
run_cmd --opt3
;;
$option_4)
run_cmd --opt4
;;
$option_5)
run_cmd --opt5
;;
$option_6)
run_cmd --opt6
;;
esac

View file

@ -26,7 +26,6 @@ window {
location: center;
anchor: center;
fullscreen: false;
width: 800px;
x-offset: 0px;
y-offset: 0px;
margin: 0px;