theme selector and powermenu

This commit is contained in:
Tiago Sousa 2024-03-15 21:21:25 +00:00
parent 83e8e09329
commit 867117f297
Signed by: tiago
SSH key fingerprint: SHA256:odOD9vln9U7qNe1R8o3UCbE3jkQCkr5/q5mgd5hwua0
2 changed files with 17 additions and 4 deletions

View file

@ -1,10 +1,14 @@
#!/bin/bash #!/bin/bash
# Define options # Define options
options="Shutdown\nRestart\nSuspend\nLock" options="Shutdown\nRestart\nSuspend\nLogout\nLock"
# Prompt user to select an option using Rofi # Prompt user to select an option using Rofi
selected_option=$(echo -e "$options" | rofi -dmenu -p "Power Menu") selected_option=$(echo -e "$options" | rofi -dmenu -p "Power Menu" -lines 6 -theme-str 'configuration {show-icons: false;} entry {placeholder: "Choose..."}')
if [ -z "$selected_option" ]; then
exit 0
fi
# Function to display confirmation dialog # Function to display confirmation dialog
confirm_action() { confirm_action() {
@ -32,6 +36,14 @@ case $selected_option in
"Suspend") "Suspend")
systemctl suspend systemctl suspend
;; ;;
"Logout")
confirmation=$(confirm_action "Logout?")
if [ "$confirmation" == "Yes" ]; then
i3-msg exit
else
exit 0
fi
;;
"Lock") "Lock")
i3-msg exit i3-msg exit
;; ;;

View file

@ -10,8 +10,9 @@ theme_options=(
# rofi script to get what theme to use # rofi script to get what theme to use
chosen=$(printf '%s\n' "${theme_options[@]}" | rofi -dmenu -p "Theme" -theme-str "configuration {show-icons:false;}") chosen=$(printf '%s\n' "${theme_options[@]}" | rofi -dmenu -p "Theme" -theme-str "configuration {show-icons:false;}")
if [[ $chosen == "-" ]]; then
exit 1 if [[ $chosen == "" ]]; then
exit 0
fi fi
theme=$(echo "${chosen}" | rev | cut -d- -f2- | rev) theme=$(echo "${chosen}" | rev | cut -d- -f2- | rev)