Add scripts & configs

This commit is contained in:
Smirnov Olexandr 2020-10-16 22:55:26 +03:00
parent f8ffdbda2e
commit 734af357dd
33 changed files with 1432 additions and 957 deletions

View file

@ -1 +1,4 @@
rofi.theme: solarized
rofi.theme: flat-solarized # solarized
rofi.font: hack 12
rofi.auto-select: false
rofi.hide-scrollbar: true

View file

@ -0,0 +1,42 @@
* {
background-color: #202020;
border-color: #606060;
text-color: #c8c8c8;
width: 768px;
height: 512px;
}
window {
padding: 8px;
}
inputbar {
padding: 8px;
children: [/*prompt,*/ entry];
}
prompt {
border: 0 1px 0 0;
padding: 4px 20px 8px 12px;
}
entry {
padding: 4px 12px 8px 20px;
}
listview {
cycle: false;
}
element {
padding: 6px 24px;
}
element selected {
background-color: #303030;
text-color: #e0e0e0;
}
element-icon {
size: 20px;
}

View file

@ -0,0 +1,42 @@
* {
background-color: #002b36;
border-color: #606060;
text-color: #c8c8c8;
width: 768px;
height: 512px;
}
window {
padding: 8px;
}
inputbar {
padding: 8px;
children: [/* prompt, */ entry];
}
prompt {
border: 0 1px 0 0;
padding: 4px 20px 8px 12px;
}
entry {
padding: 4px 12px 8px 20px;
}
listview {
cycle: false;
}
element {
padding: 6px 24px;
}
element selected {
background-color: #073642;
text-color: #e0e0e0;
}
element-icon {
size: 20px;
}

View file

@ -1,23 +1,11 @@
#!/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"
@ -39,17 +27,14 @@ icons[cancel]="\u00d7"
declare -A actions
actions[lockscreen]="loginctl lock-session $XDG_SESSION_ID"
#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
@ -66,7 +51,6 @@ function check_valid {
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
@ -124,7 +108,6 @@ while true; do
shift 2
;;
"--choose")
# Check that the choice is valid
check_valid "$1" "$2"
selectionID="$2"
shift 2
@ -148,9 +131,6 @@ while true; do
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>"
@ -180,19 +160,15 @@ 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}" ]
@ -207,40 +183,33 @@ else
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