init
This commit is contained in:
80
rofi/scripts/powermenu/powermenu
Executable file
80
rofi/scripts/powermenu/powermenu
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# variables
|
||||
uptime="$(uptime -p | sed -e 's/up //g')"
|
||||
shutdown=''
|
||||
reboot=''
|
||||
lock=''
|
||||
suspend=''
|
||||
logout=''
|
||||
yes=''
|
||||
no=''
|
||||
|
||||
rofi_cmd() {
|
||||
rofi -dmenu \
|
||||
-p "Uptime: $uptime" \
|
||||
-mesg "Uptime: $uptime" \
|
||||
-theme ~/.config/rofi/scripts/powermenu/style.rasi
|
||||
}
|
||||
|
||||
confirm_cmd() {
|
||||
rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 350px;}' \
|
||||
-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 ~/.config/rofi/scripts/powermenu/style.rasi
|
||||
}
|
||||
|
||||
confirm_exit() {
|
||||
echo -e "$yes\n$no" | confirm_cmd
|
||||
}
|
||||
|
||||
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
|
||||
hyprlock
|
||||
systemctl suspend
|
||||
elif [[ $1 == '--logout' ]]; then
|
||||
hyprctl dispatch exit
|
||||
elif [[ $1 == '--lock' ]]; then
|
||||
hyprlock
|
||||
fi
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Actions
|
||||
chosen="$(run_rofi)"
|
||||
case ${chosen} in
|
||||
$shutdown)
|
||||
run_cmd --shutdown
|
||||
;;
|
||||
$reboot)
|
||||
run_cmd --reboot
|
||||
;;
|
||||
$lock)
|
||||
run_cmd --lock
|
||||
;;
|
||||
$suspend)
|
||||
run_cmd --suspend
|
||||
;;
|
||||
$logout)
|
||||
run_cmd --logout
|
||||
;;
|
||||
esac
|
||||
168
rofi/scripts/powermenu/style.rasi
Normal file
168
rofi/scripts/powermenu/style.rasi
Normal file
@@ -0,0 +1,168 @@
|
||||
// Config
|
||||
configuration {
|
||||
show-icons: false;
|
||||
me-select-entry: "";
|
||||
me-accept-entry: [ MousePrimary, MouseSecondary, MouseDPrimary ];
|
||||
}
|
||||
|
||||
@theme "~/.config/rofi/theme/catppuccin-macchiato.rasi"
|
||||
|
||||
// Main Window
|
||||
window {
|
||||
transparency: "real";
|
||||
location: center;
|
||||
anchor: center;
|
||||
fullscreen: false;
|
||||
width: 450px;
|
||||
x-offset: 0px;
|
||||
y-offset: 0px;
|
||||
|
||||
enabled: true;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border: 2px solid;
|
||||
border-radius: 10px;
|
||||
border-color: @accent;
|
||||
cursor: "default";
|
||||
background-color: @background;
|
||||
}
|
||||
|
||||
// Main Box
|
||||
mainbox {
|
||||
enabled: true;
|
||||
spacing: 15px;
|
||||
margin: 0px;
|
||||
padding: 30px;
|
||||
border: 0px solid;
|
||||
border-radius: 5px;
|
||||
border-color: @selected;
|
||||
background-color: transparent;
|
||||
children: [ "message", "listview" ];
|
||||
}
|
||||
|
||||
// Inputbar
|
||||
inputbar {
|
||||
enabled: false;
|
||||
spacing: 15px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border: 0px;
|
||||
border-radius: 5px;
|
||||
border-color: @selected;
|
||||
background-color: transparent;
|
||||
text-color: @foreground;
|
||||
children: [ "textbox-prompt-colon", "prompt" ];
|
||||
}
|
||||
|
||||
dummy {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
textbox-prompt-colon {
|
||||
font: "Symbols Nerd Font 12";
|
||||
enabled: false;
|
||||
expand: false;
|
||||
str: "";
|
||||
padding: 0 14px;
|
||||
border-radius: 10px;
|
||||
border-color: @urgent;
|
||||
border: 2px solid;
|
||||
background-color: @background;
|
||||
text-color: @foreground;
|
||||
vertical-align: 0.5;
|
||||
horizontal-align: 0.5;
|
||||
}
|
||||
|
||||
prompt {
|
||||
enabled: false;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
border-color: @active;
|
||||
border: 2px solid;
|
||||
background-color: @background;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
// Message
|
||||
message {
|
||||
enabled: false;
|
||||
margin: 0px;
|
||||
padding: 12px;
|
||||
border: 0px solid;
|
||||
border-radius: 10px;
|
||||
border-color: @selected;
|
||||
background-color: @background-tb;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
textbox {
|
||||
background-color: inherit;
|
||||
text-color: inherit;
|
||||
vertical-align: 0.5;
|
||||
horizontal-align: 0.5;
|
||||
placeholder-color: @foreground;
|
||||
blink: true;
|
||||
markup: true;
|
||||
}
|
||||
|
||||
error-message {
|
||||
padding: 12px;
|
||||
border: 0px solid;
|
||||
border-radius: 10px;
|
||||
border-color: @selected;
|
||||
background-color: @background;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
// Listview
|
||||
listview {
|
||||
enabled: true;
|
||||
columns: 5;
|
||||
lines: 1;
|
||||
cycle: true;
|
||||
dynamic: true;
|
||||
scrollbar: false;
|
||||
layout: vertical;
|
||||
reverse: false;
|
||||
fixed-height: true;
|
||||
fixed-columns: true;
|
||||
spacing: 15px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border: 0px solid;
|
||||
border-radius: 0px;
|
||||
border-color: @selected;
|
||||
background-color: transparent;
|
||||
text-color: @foreground;
|
||||
cursor: "default";
|
||||
}
|
||||
|
||||
// Elements
|
||||
element {
|
||||
enabled: true;
|
||||
spacing: 0px;
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
border: 0px solid;
|
||||
border-radius: 10px;
|
||||
border-color: @accent;
|
||||
background-color: transparent;
|
||||
text-color: @foreground;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
element-text {
|
||||
font: "Symbols Nerd Font 24";
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
cursor: inherit;
|
||||
vertical-align: 0; // NOTE: Change this back to 0.5 once https://github.com/davatorium/rofi/issues/2076 is resolved
|
||||
horizontal-align: 0.5;
|
||||
}
|
||||
|
||||
element selected.normal {
|
||||
background-color: var(foreground);
|
||||
border-color: var(selected);
|
||||
border: 0px solid;
|
||||
text-color: var(background);
|
||||
}
|
||||
Reference in New Issue
Block a user