add i3 and polybar conf, add new rofi logout screen
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
configuration {
|
||||
font: "Inter Regular 10";
|
||||
font: "JetBrainsMono Nerd Font 11";
|
||||
show-icons: true;
|
||||
drun-display-format: "{name}";
|
||||
fullscreen: false;
|
||||
@@ -9,6 +9,9 @@ configuration {
|
||||
disable-history: false;
|
||||
fullscreen: true;
|
||||
window-thumbnail: true;
|
||||
display-drun: "";
|
||||
display-run: "";
|
||||
display-window: "缾";
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -36,8 +39,8 @@ prompt {
|
||||
|
||||
button {
|
||||
action: "ok";
|
||||
str: " ";
|
||||
font: "FantasqueSansMono Nerd Font 11";
|
||||
str: "";
|
||||
font: "JetBrainsMono Nerd Font 11";
|
||||
expand: false;
|
||||
text-color: @foreground;
|
||||
background-color: @transparent;
|
||||
@@ -46,12 +49,12 @@ button {
|
||||
}
|
||||
|
||||
entry {
|
||||
font: "Inter Regular 11";
|
||||
font: "JetBrainsMono Nerd Font 11";
|
||||
background-color: @transparent;
|
||||
text-color: @foreground;
|
||||
expand: true;
|
||||
vertical-align: 0.5;
|
||||
horizontal-align: 0.5;
|
||||
margin: 0 0 0 10px;
|
||||
placeholder: "Type to search";
|
||||
placeholder-color: @foreground;
|
||||
blink: true;
|
||||
@@ -97,7 +100,6 @@ mainbox {
|
||||
children: [ inputbar, listview ];
|
||||
spacing: 25px;
|
||||
padding: 70px 15% 0 15%;
|
||||
/*padding: 70px 135px 0 135px;*/
|
||||
}
|
||||
|
||||
element {
|
||||
|
||||
93
rofi/powermenu/powermenu.rasi
Normal file
93
rofi/powermenu/powermenu.rasi
Normal file
@@ -0,0 +1,93 @@
|
||||
configuration {
|
||||
font: "JetBrainsMono Nerd Font 36";
|
||||
drun-display-format: "{name}";
|
||||
fullscreen: false;
|
||||
threads: 0;
|
||||
matching: "fuzzy";
|
||||
scroll-method: 0;
|
||||
disable-history: false;
|
||||
fullscreen: true;
|
||||
}
|
||||
|
||||
* {
|
||||
transparent: #00000000;
|
||||
foreground: #F2F2F2EE;
|
||||
background-selected: #F2F2F245;
|
||||
background-active: #F2F2F230;
|
||||
background-white: #F2F2F211;
|
||||
background-black: #00000066;
|
||||
urgent: #E91E6366;
|
||||
urgent-selected: #E91E6377;
|
||||
}
|
||||
|
||||
window {
|
||||
transparency: "real";
|
||||
background-color: @transparent;
|
||||
text-color: @foreground;
|
||||
location: northwest;
|
||||
anchor: northwest;
|
||||
}
|
||||
|
||||
inputbar {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
children: [ entry-wrapper ];
|
||||
}
|
||||
|
||||
listview {
|
||||
background-color: @transparent;
|
||||
lines: 6;
|
||||
spacing: 5%;
|
||||
cycle: false;
|
||||
dynamic: true;
|
||||
layout: horizontal;
|
||||
}
|
||||
|
||||
mainbox {
|
||||
background-color: @background-black;
|
||||
children: [ inputbar, listview ];
|
||||
padding: calc(50% - 70px) 0% 0% 15%;
|
||||
}
|
||||
|
||||
element {
|
||||
background-color: @transparent;
|
||||
text-color: @foreground;
|
||||
orientation: horizontal;
|
||||
border-radius: 10px;
|
||||
padding: 30px;
|
||||
vertical: 0.5;
|
||||
}
|
||||
|
||||
element-text {
|
||||
expand: true;
|
||||
horizontal-align: 0.5;
|
||||
vertical-align: 0.5;
|
||||
}
|
||||
|
||||
element normal.urgent,
|
||||
element alternate.urgent {
|
||||
background-color: @urgent;
|
||||
text-color: @foreground;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
element normal.active,
|
||||
element alternate.active {
|
||||
background-color: @background-active;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
element selected {
|
||||
background-color: #29B6F6;
|
||||
text-color: #212121;
|
||||
}
|
||||
|
||||
element selected.urgent {
|
||||
background-color: @urgent-selected;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
element selected.active {
|
||||
background-color: @background-active;
|
||||
color: @foreground-selected;
|
||||
}
|
||||
246
rofi/rofi-power-menu
Executable file
246
rofi/rofi-power-menu
Executable file
@@ -0,0 +1,246 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script defines just a mode for rofi instead of being a self-contained
|
||||
# executable that launches rofi by itself. This makes it more flexible than
|
||||
# running rofi inside this script as now the user can call rofi as one pleases.
|
||||
# For instance:
|
||||
#
|
||||
# rofi -show powermenu -modi powermenu:./rofi-power-menu
|
||||
#
|
||||
# See README.md for more information.
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# All supported choices
|
||||
all=(shutdown reboot suspend hibernate logout lockscreen)
|
||||
|
||||
# By default, show all (i.e., just copy the array)
|
||||
show=("${all[@]}")
|
||||
|
||||
declare -A texts
|
||||
texts[lockscreen]="lock screen"
|
||||
texts[switchuser]="switch user"
|
||||
texts[logout]="log out"
|
||||
texts[suspend]="suspend"
|
||||
texts[hibernate]="hibernate"
|
||||
texts[reboot]="reboot"
|
||||
texts[shutdown]="shut down"
|
||||
|
||||
declare -A icons
|
||||
icons[lockscreen]="\uf023"
|
||||
icons[switchuser]="\uf518"
|
||||
icons[logout]="\uf842"
|
||||
icons[suspend]="\uf9b1"
|
||||
icons[hibernate]="\uf7c9"
|
||||
icons[reboot]="\ufc07"
|
||||
icons[shutdown]="\uf011"
|
||||
icons[cancel]="\u00d7"
|
||||
|
||||
declare -A actions
|
||||
actions[lockscreen]="dm-tool lock"
|
||||
#actions[switchuser]="???"
|
||||
actions[logout]="loginctl terminate-session ${XDG_SESSION_ID-}"
|
||||
actions[suspend]="systemctl suspend"
|
||||
actions[hibernate]="systemctl hibernate"
|
||||
actions[reboot]="systemctl reboot"
|
||||
actions[shutdown]="systemctl poweroff"
|
||||
|
||||
# By default, ask for confirmation for actions that are irreversible
|
||||
confirmations=(reboot shutdown logout)
|
||||
|
||||
# By default, no dry run
|
||||
dryrun=false
|
||||
showsymbols=true
|
||||
|
||||
function check_valid {
|
||||
option="$1"
|
||||
shift 1
|
||||
for entry in "${@}"
|
||||
do
|
||||
if [ -z "${actions[$entry]+x}" ]
|
||||
then
|
||||
echo "Invalid choice in $1: $entry" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Parse command-line options
|
||||
parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols --name "$0" -- "$@")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'Terminating...' >&2
|
||||
exit 1
|
||||
fi
|
||||
eval set -- "$parsed"
|
||||
unset parsed
|
||||
while true; do
|
||||
case "$1" in
|
||||
"-h"|"--help")
|
||||
echo "rofi-power-menu - a power menu mode for Rofi"
|
||||
echo
|
||||
echo "Usage: rofi-power-menu [--choices CHOICES] [--confirm CHOICES]"
|
||||
echo " [--choose CHOICE] [--dry-run] [--symbols|--no-symbols]"
|
||||
echo
|
||||
echo "Use with Rofi in script mode. For instance, to ask for shutdown or reboot:"
|
||||
echo
|
||||
echo " rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot\""
|
||||
echo
|
||||
echo "Available options:"
|
||||
echo " --dry-run Don't perform the selected action but print it to stderr."
|
||||
echo " --choices CHOICES Show only the selected choices in the given order. Use / "
|
||||
echo " as the separator. Available choices are lockscreen, logout,"
|
||||
echo " suspend, hibernate, reboot and shutdown. By default, all"
|
||||
echo " available choices are shown."
|
||||
echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as"
|
||||
echo " the separator. Available choices are lockscreen, logout,"
|
||||
echo " suspend, hibernate, reboot and shutdown. By default, only"
|
||||
echo " irreversible actions logout, reboot and shutdown require"
|
||||
echo " confirmation."
|
||||
echo " --choose CHOICE Preselect the given choice and only ask for a confirmation"
|
||||
echo " (if confirmation is set to be requested). It is strongly"
|
||||
echo " recommended to combine this option with --confirm=CHOICE"
|
||||
echo " if the choice wouldn't require confirmation by default."
|
||||
echo " Available choices are lockscreen, logout, suspend,"
|
||||
echo " hibernate, reboot and shutdown."
|
||||
echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support"
|
||||
echo " for the symbols. Use, for instance, fonts from the"
|
||||
echo " Nerdfonts collection. By default, they are shown"
|
||||
echo " -h,--help Show this help text."
|
||||
exit 0
|
||||
;;
|
||||
"--dry-run")
|
||||
dryrun=true
|
||||
shift 1
|
||||
;;
|
||||
"--confirm")
|
||||
IFS='/' read -ra confirmations <<< "$2"
|
||||
check_valid "$1" "${confirmations[@]}"
|
||||
shift 2
|
||||
;;
|
||||
"--choices")
|
||||
IFS='/' read -ra show <<< "$2"
|
||||
check_valid "$1" "${show[@]}"
|
||||
shift 2
|
||||
;;
|
||||
"--choose")
|
||||
# Check that the choice is valid
|
||||
check_valid "$1" "$2"
|
||||
selectionID="$2"
|
||||
shift 2
|
||||
;;
|
||||
"--symbols")
|
||||
showsymbols=true
|
||||
shift 1
|
||||
;;
|
||||
"--no-symbols")
|
||||
showsymbols=false
|
||||
shift 1
|
||||
;;
|
||||
"--")
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Internal error" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Define the messages after parsing the CLI options so that it is possible to
|
||||
# configure them in the future.
|
||||
|
||||
function write_message {
|
||||
icon="<span font_size=\"medium\">$1</span>"
|
||||
text="<span font_size=\"medium\">$2</span>"
|
||||
if [ "$showsymbols" = "true" ]
|
||||
then
|
||||
echo -n "\u200e$icon \u2068$text\u2069"
|
||||
else
|
||||
echo -n "$text"
|
||||
fi
|
||||
}
|
||||
|
||||
function print_selection {
|
||||
echo -e "$1" | $(read -r -d '' entry; echo "echo $entry")
|
||||
}
|
||||
|
||||
declare -A messages
|
||||
declare -A confirmationMessages
|
||||
for entry in "${all[@]}"
|
||||
do
|
||||
messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}")
|
||||
done
|
||||
for entry in "${all[@]}"
|
||||
do
|
||||
confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}")
|
||||
done
|
||||
confirmationMessages[cancel]=$(write_message "${icons[cancel]}" "No, cancel")
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
# If arguments given, use those as the selection
|
||||
selection="${@}"
|
||||
else
|
||||
# Otherwise, use the CLI passed choice if given
|
||||
if [ -n "${selectionID+x}" ]
|
||||
then
|
||||
selection="${messages[$selectionID]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't allow custom entries
|
||||
echo -e "\0no-custom\x1ftrue"
|
||||
# Use markup
|
||||
echo -e "\0markup-rows\x1ftrue"
|
||||
|
||||
if [ -z "${selection+x}" ]
|
||||
then
|
||||
echo -e "\0prompt\x1fPower menu"
|
||||
for entry in "${show[@]}"
|
||||
do
|
||||
echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}"
|
||||
done
|
||||
else
|
||||
for entry in "${show[@]}"
|
||||
do
|
||||
if [ "$selection" = "$(print_selection "${messages[$entry]}")" ]
|
||||
then
|
||||
# Check if the selected entry is listed in confirmation requirements
|
||||
for confirmation in "${confirmations[@]}"
|
||||
do
|
||||
if [ "$entry" = "$confirmation" ]
|
||||
then
|
||||
# Ask for confirmation
|
||||
echo -e "\0prompt\x1fAre you sure"
|
||||
echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}"
|
||||
echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
# If not, then no confirmation is required, so mark confirmed
|
||||
selection=$(print_selection "${confirmationMessages[$entry]}")
|
||||
fi
|
||||
if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ]
|
||||
then
|
||||
if [ $dryrun = true ]
|
||||
then
|
||||
# Tell what would have been done
|
||||
echo "Selected: $entry" >&2
|
||||
else
|
||||
# Perform the action
|
||||
${actions[$entry]}
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ]
|
||||
then
|
||||
# Do nothing
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
# The selection didn't match anything, so raise an error
|
||||
echo "Invalid selection: $selection" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user