Browse Source

Rofi style power menu

pull/32/head
Daniel 2 years ago committed by GitHub
parent
commit
61bbe3b7d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 123
      config-powermenu.rasi
  2. 61
      rofipower.sh

123
config-powermenu.rasi

@ -0,0 +1,123 @@
/* --- Configuration for Rofi Power ---- */
/* ---- Configuration ---- */
configuration {
show-icons: false;
}
/* ---- Load pywal colors (custom wal template) ---- */
@import "~/.config/rofi/pywal-color/pywal-theme.rasi"
/* ---- Global Properties ---- */
* {
font: "JetBrains Mono Nerd Font 14";
}
/* ---- Main Window ---- */
window {
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
width: 25%;
height: 25%;
x-offset: 0px;
y-offset: 0px;
padding: 0px;
border: 1px solid;
border-radius: 15px;
border-color: @active-background;
cursor: "default";
background-color: @background-color;
}
/* ---- Main Box ---- */
mainbox {
enabled: true;
spacing: 0px;
margin: 0px;
padding: 0px;
border: 0px solid;
border-radius: 0px;
background-image: url("~/.config/rofi/.current_wallpaper", width);
border-color: @active-background;
background-color: @background-color;
children: [ "inputbar", "listview", "message" ];
}
/* ---- Inputbar ---- */
inputbar {
enabled: true;
padding: 2px 4%;
background-color: transparent;
orientation: vertical;
children: ["prompt"];
}
prompt {
enabled: true;
padding: 2% 5%;
border-radius: 100% 100% 100% 100%;
border-color: @foreground;
background-color: @background-color;
text-color: @foreground;
cursor: text;
}
/* ---- 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: 30px;
padding: 4% 30px;
background-color: transparent;
cursor: "default";
border: 0px;
}
/* ---- Elements ---- */
element {
enabled: true;
padding: 20px;
border-radius: 40px;
background-color: transparent;
text-color: @foreground;
cursor: pointer;
}
element-text {
font: "JetBrains Mono Nerd Font 32";
background-color: transparent;
text-color: inherit;
cursor: inherit;
vertical-align: 0.5;
horizontal-align: 0.5;
}
element selected.normal {
background-color: @selected-normal-background;
text-color: @background;
}
/* ---- Message ---- */
message {
enabled: true;
margin: 0px;
padding: 15px;
border-radius: 0px;
background-color: transparent;
text-color: @foreground;
border: 0px;
}
textbox {
background-color: inherit;
text-color: inherit;
vertical-align: 0.5;
horizontal-align: 0.5;
}

61
rofipower.sh

@ -0,0 +1,61 @@
#!/usr/bin/env bash
# Swayconfig
SWAYCONFIG="$HOME/.config/swaylock/config"
# CMDs
uptime="`uptime -p | sed -e 's/up //g'`"
host=`hostnamectl hostname`
# Options
shutdown=''
reboot=''
lock=''
suspend=''
logout=''
# Rofi CMD
rofi_cmd() {
rofi -dmenu -p " $USER@$host" -mesg " Uptime: $uptime" -theme ~/.config/rofi/config-powermenu.rasi
}
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$lock\0meta\x1fl\n$suspend\0meta\x1fu\n$logout\0meta\x1fe\n$reboot\0meta\x1fr\n$shutdown\0meta\x1fs" | rofi_cmd
}
# Execute Command
run_cmd() {
if [[ $1 == '--shutdown' ]]; then
systemctl poweroff
elif [[ $1 == '--reboot' ]]; then
systemctl reboot
elif [[ $1 == '--suspend' ]]; then
systemctl suspend
elif [[ $1 == '--logout' ]]; then
hyprctl dispatch exit 0
fi
}
# Actions
chosen="$(run_rofi)"
case ${chosen} in
$shutdown)
run_cmd --shutdown
;;
$reboot)
run_cmd --reboot
;;
$hibernate)
run_cmd --hibernate
;;
$lock)
sleep 0.5s; swaylock --config ${SWAYCONFIG} & disown
;;
$suspend)
run_cmd --suspend
;;
$logout)
run_cmd --logout
;;
esac
Loading…
Cancel
Save