mirror of
https://github.com/adi1090x/rofi.git
synced 2026-05-03 20:13:10 +02:00
Compare commits
1 Commits
c4f7a67380
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b0bfe92753 |
@@ -109,7 +109,7 @@ $ ./setup.sh
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<!-- sponsors --><a href="https://github.com/davidtoska"><img src="https://github.com/davidtoska.png" width="60px" alt="User avatar: David Toska" /></a><a href="https://github.com/dgxlab"><img src="https://github.com/dgxlab.png" width="60px" alt="User avatar: David Vargas" /></a><!-- sponsors -->
|
<!-- sponsors --><a href="https://github.com/davidtoska"><img src="https://github.com/davidtoska.png" width="60px" alt="User avatar: David Toska" /></a><a href="https://github.com/dgxlab"><img src="https://github.com/dgxlab.png" width="60px" alt="User avatar: David Vargas" /></a><a href="https://github.com/maksimdymov"><img src="https://github.com/maksimdymov.png" width="60px" alt="User avatar: Maksim" /></a><!-- sponsors -->
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ run_cmd() {
|
|||||||
openbox --exit
|
openbox --exit
|
||||||
elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then
|
elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then
|
||||||
bspc quit
|
bspc quit
|
||||||
elif [[ "$DESKTOP_SESSION" =~ 'i3' ]]; then
|
elif [[ "$DESKTOP_SESSION" == 'i3' ]]; then
|
||||||
i3-msg exit
|
i3-msg exit
|
||||||
elif [[ "$DESKTOP_SESSION" == 'plasma' ]]; then
|
elif [[ "$DESKTOP_SESSION" == 'plasma' ]]; then
|
||||||
qdbus org.kde.ksmserver /KSMServer logout 0 0 0
|
qdbus org.kde.ksmserver /KSMServer logout 0 0 0
|
||||||
@@ -95,9 +95,9 @@ case ${chosen} in
|
|||||||
run_cmd --reboot
|
run_cmd --reboot
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ case ${chosen} in
|
|||||||
run_cmd --reboot
|
run_cmd --reboot
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ case ${chosen} in
|
|||||||
run_cmd --reboot
|
run_cmd --reboot
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ case ${chosen} in
|
|||||||
run_cmd --reboot
|
run_cmd --reboot
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ case ${chosen} in
|
|||||||
run_cmd --hibernate
|
run_cmd --hibernate
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ case ${chosen} in
|
|||||||
run_cmd --hibernate
|
run_cmd --hibernate
|
||||||
;;
|
;;
|
||||||
$lock)
|
$lock)
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
if [[ -x '/usr/bin/betterlockscreen' ]]; then
|
||||||
betterlockscreen -l
|
betterlockscreen -l
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
elif [[ -x '/usr/bin/i3lock' ]]; then
|
||||||
i3lock
|
i3lock
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
## Author : Aditya Shakya (adi1090x)
|
|
||||||
## Github : @adi1090x
|
|
||||||
#
|
|
||||||
## Rofi : Power Menu
|
|
||||||
#
|
|
||||||
## Available Styles
|
|
||||||
#
|
|
||||||
## style-1 style-2 style-3 style-4 style-5
|
|
||||||
|
|
||||||
# Current Theme
|
|
||||||
type="type-1"
|
|
||||||
theme="style-1"
|
|
||||||
|
|
||||||
# Parse flags
|
|
||||||
while getopts "t:s:" opt; do
|
|
||||||
case $opt in
|
|
||||||
t) type="type-$OPTARG" ;;
|
|
||||||
s) theme="style-$OPTARG" ;;
|
|
||||||
\?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
dir="$HOME/.config/rofi/powermenu/$type"
|
|
||||||
|
|
||||||
# CMDs
|
|
||||||
uptime="`uptime -p | sed -e 's/up //g'`"
|
|
||||||
host=`hostname`
|
|
||||||
|
|
||||||
# Options
|
|
||||||
shutdown=' Shutdown'
|
|
||||||
reboot=' Reboot'
|
|
||||||
lock=' Lock'
|
|
||||||
suspend=' Suspend'
|
|
||||||
logout=' Logout'
|
|
||||||
yes=' Yes'
|
|
||||||
no=' No'
|
|
||||||
|
|
||||||
# Rofi CMD
|
|
||||||
rofi_cmd() {
|
|
||||||
rofi -dmenu \
|
|
||||||
-p "$host" \
|
|
||||||
-mesg "Uptime: $uptime" \
|
|
||||||
-theme ${dir}/${theme}.rasi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Confirmation CMD
|
|
||||||
confirm_cmd() {
|
|
||||||
rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 250px;}' \
|
|
||||||
-theme-str 'mainbox {children: [ "message", "listview" ];}' \
|
|
||||||
-theme-str 'listview {columns: 2; lines: 1;}' \
|
|
||||||
-theme-str 'element-text {horizontal-align: 0.5;}' \
|
|
||||||
-theme-str 'textbox {horizontal-align: 0.5;}' \
|
|
||||||
-dmenu \
|
|
||||||
-p 'Confirmation' \
|
|
||||||
-mesg 'Are you Sure?' \
|
|
||||||
-theme ${dir}/${theme}.rasi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ask for confirmation
|
|
||||||
confirm_exit() {
|
|
||||||
echo -e "$yes\n$no" | confirm_cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
# Pass variables to rofi dmenu
|
|
||||||
run_rofi() {
|
|
||||||
echo -e "$lock\n$suspend\n$logout\n$reboot\n$shutdown" | rofi_cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute Command
|
|
||||||
run_cmd() {
|
|
||||||
selected="$(confirm_exit)"
|
|
||||||
if [[ "$selected" == "$yes" ]]; then
|
|
||||||
if [[ $1 == '--shutdown' ]]; then
|
|
||||||
systemctl poweroff
|
|
||||||
elif [[ $1 == '--reboot' ]]; then
|
|
||||||
systemctl reboot
|
|
||||||
elif [[ $1 == '--suspend' ]]; then
|
|
||||||
mpc -q pause
|
|
||||||
amixer set Master mute
|
|
||||||
systemctl suspend
|
|
||||||
elif [[ $1 == '--logout' ]]; then
|
|
||||||
if [[ "$DESKTOP_SESSION" == 'openbox' ]]; then
|
|
||||||
openbox --exit
|
|
||||||
elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then
|
|
||||||
bspc quit
|
|
||||||
elif [[ "$DESKTOP_SESSION" =~ 'i3' ]]; then
|
|
||||||
i3-msg exit
|
|
||||||
elif [[ "$DESKTOP_SESSION" == 'plasma' ]]; then
|
|
||||||
qdbus org.kde.ksmserver /KSMServer logout 0 0 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Actions
|
|
||||||
chosen="$(run_rofi)"
|
|
||||||
case ${chosen} in
|
|
||||||
$shutdown)
|
|
||||||
run_cmd --shutdown
|
|
||||||
;;
|
|
||||||
$reboot)
|
|
||||||
run_cmd --reboot
|
|
||||||
;;
|
|
||||||
$lock)
|
|
||||||
if command -v betterlockscreen >/dev/null 2>&1; then
|
|
||||||
betterlockscreen -l
|
|
||||||
elif command -v i3lock >/dev/null 2>&1; then
|
|
||||||
i3lock
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
$suspend)
|
|
||||||
run_cmd --suspend
|
|
||||||
;;
|
|
||||||
$logout)
|
|
||||||
run_cmd --logout
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
Reference in New Issue
Block a user