Add Scripts to ~/.scripts & Highlight Color Changes

- Add bunch of cli & rofi scripts to ~/.scripts
- Change rofi theme to use cyan highlight
- Change dunst notification sto use green highlight
- Make all rofi dmenu scripts use case insensitivity
This commit is contained in:
Sravan Balaji
2021-05-16 14:19:24 -04:00
parent c6648c5f79
commit e4f88101d4
13 changed files with 1035 additions and 157 deletions

61
.scripts/control-center.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
help_menu() {
echo "Main script to launch sub-menu scripts. Use only one argument at a time."
# echo " - Play / Pause: playerctl.sh --play-pause"
# echo " - Next: playerctl.sh --next"
# echo " - Previous: playerctl.sh --prev"
# echo " - Change Player: playerctl.sh --change"
# echo " - Rofi Menu: playerctl.sh --rofi"
# echo " - Help: playerctl.sh --help OR playerctl.sh -h"
}
rofi_menu() {
declare -a options=(
" Compositor - picom"
" Notifications - dunst"
" Media - playerctl"
" Hardware - system76-power"
" Power Menu - session"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--picom)
/home/sravan/.scripts/picom.sh --rofi
;;
--dunst)
/home/sravan/.scripts/dunst.sh --rofi
;;
--playerctl)
/home/sravan/.scripts/playerctl.sh --rofi
;;
--system76-power)
/home/sravan/.scripts/system76-power.sh --rofi
;;
--session)
/home/sravan/.scripts/session.sh --rofi
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

129
.scripts/dunst.sh Executable file
View File

@@ -0,0 +1,129 @@
#!/bin/bash
help_menu() {
echo "Script to interact with dunst. Use only one argument at a time."
echo " - Toggle On/Off: dunst.sh OR dunst.sh --toggle OR dunst.sh -t"
echo " - Turn On: dunst.sh --on"
echo " - Turn Off: dunst.sh --off"
echo " - Context Menu: dunst.sh --context"
echo " - Close Notification: dunst.sh --close"
echo " - History Pop: dunst.sh --history"
echo " - Toggle Do Not Disturb: dunst.sh --dnd"
echo " - Rofi Menu: dunst.sh --rofi"
echo " - Help: dunst.sh --help OR dunst.sh -h"
}
is_running() {
if pgrep -x dunst >/dev/null; then
echo 1
else
echo 0
fi
}
rofi_menu() {
declare -a options=(
"⏼ Toggle - toggle"
" Turn On - on"
" Turn Off - off"
" Open Actions - context"
" Close Notification - close"
" View History - history"
" Toggle Do Not Disturb - dnd"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--toggle)
if [ $(is_running) -eq '1' ]; then
main --off
else
main --on
fi
;;
--on)
# Get values from Xresources
config=~/.config/dunst/dunstrc
geometry_x=$(xgetres dunst.geometry-x)
geometry_y=$(xgetres dunst.geometry-y)
separator_height=$(xgetres dunst.sep-height)
padding=$(xgetres dunst.padding)
horizontal_padding=$(xgetres dunst.horiz-padding)
max_icon_size=$(xgetres dunst.max-icon-size)
frame_width=$(xgetres dunst.frame-width)
lb=$(xgetres dunst.low-background)
lf=$(xgetres dunst.low-foreground)
lfr=$(xgetres dunst.low-frame)
nb=$(xgetres dunst.normal-background)
nf=$(xgetres dunst.normal-foreground)
nfr=$(xgetres dunst.normal-frame)
cb=$(xgetres dunst.critical-background)
cf=$(xgetres dunst.critical-foreground)
cfr=$(xgetres dunst.critical-frame)
if [ $(is_running) -eq '1' ]; then
killall dunst
fi
# Start Dunst
/usr/bin/dunst -config $config \
-geometry "0x0-$geometry_x+$geometry_y" \
-separator_height "$separator_height" \
-padding "$padding" \
-horizontal_padding "$horizontal_padding" \
-max_icon_size "$max_icon_size" \
-frame_width "$frame_width" \
-lb "$lb" \
-lf "$lf" \
-lfr "$lfr" \
-nb "$nb" \
-nf "$nf" \
-nfr "$nfr" \
-cb "$cb" \
-cf "$cf" \
-cfr "$cfr" &
notify-send "Turning Dunst ON"
;;
--off)
notify-send "Turning Dunst OFF"
if [ $(is_running) -eq '1' ]; then
killall dunst
fi
;;
--context)
dunstctl context
;;
--close)
dunstctl close
;;
--history)
dunstctl history-pop
;;
--dnd)
dunstctl set-paused toggle
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

73
.scripts/picom.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
help_menu() {
echo "Script to interact with picom. Use only one argument at a time."
echo " - Toggle On/Off: picom.sh OR picom.sh --toggle OR picom.sh -t"
echo " - Turn On: picom.sh --on"
echo " - Turn Off: picom.sh --off"
echo " - Help: picom.sh --help OR picom.sh -h"
}
is_running() {
if pgrep -x picom >/dev/null; then
echo 1
else
echo 0
fi
}
rofi_menu() {
declare -a options=(
"⏼ Toggle - toggle"
" Turn On - on"
" Turn Off - off"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--toggle)
if [ $(is_running) -eq '1' ]; then
main --off
else
main --on
fi
;;
--on)
if [ $(is_running) -eq '1' ]; then
killall picom
fi
picom --config /home/sravan/.config/picom/picom.conf &
notify-send "Turning Picom ON"
;;
--off)
if [ $(is_running) -eq '1' ]; then
killall picom
fi
notify-send "Turning Picom OFF"
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

57
.scripts/playerctl.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
help_menu() {
echo "Script to interact with playerctl. Use only one argument at a time."
echo " - Play / Pause: playerctl.sh --play-pause"
echo " - Next: playerctl.sh --next"
echo " - Previous: playerctl.sh --prev"
echo " - Change Player: playerctl.sh --change"
echo " - Rofi Menu: playerctl.sh --rofi"
echo " - Help: playerctl.sh --help OR playerctl.sh -h"
}
rofi_menu() {
declare -a options=(
"懶 Play / Pause - play-pause"
"怜 Next - next"
"玲 Previous - prev"
" Change Source - change"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--play-pause)
playerctl --player=playerctld play-pause
;;
--next)
playerctl --player=playerctld next
;;
--prev)
playerctl --player=playerctld previous
;;
--change)
playerctld shift
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

70
.scripts/session.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
help_menu() {
echo "Script to interact with desktop session. Use only one argument at a time."
# echo " - Play / Pause: playerctl.sh --play-pause"
# echo " - Next: playerctl.sh --next"
# echo " - Previous: playerctl.sh --prev"
# echo " - Change Player: playerctl.sh --change"
# echo " - Rofi Menu: playerctl.sh --rofi"
# echo " - Help: playerctl.sh --help OR playerctl.sh -h"
}
rofi_menu() {
declare -a options=(
" Recompile & Restart Xmonad - restart"
" Logout - logout"
" Lock - lock"
"⏾ Sleep - sleep"
" Reboot - reboot"
" Shutdown - shutdown"
"鈴 Hibernate - hibernate"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--logout)
pkill xmonad
;;
--lock)
light-locker-command --lock
;;
--sleep)
pkexec systemctl suspend
;;
--reboot)
pkexec reboot
;;
--shutdown)
pkexec poweroff
;;
--hibernate)
pkexec systemctl hibernate
;;
--restart)
xmonad --recompile
xmonad --restart
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

124
.scripts/system76-power.sh Executable file
View File

@@ -0,0 +1,124 @@
#!/bin/bash
help_menu() {
echo "Script to interact with system76-power. Use only one argument at a time."
# echo " - Play / Pause: playerctl.sh --play-pause"
# echo " - Next: playerctl.sh --next"
# echo " - Previous: playerctl.sh --prev"
# echo " - Change Player: playerctl.sh --change"
# echo " - Rofi Menu: playerctl.sh --rofi"
# echo " - Help: playerctl.sh --help OR playerctl.sh -h"
}
rofi_menu() {
declare -a options=(
" Switchable Graphics - rofi-graphics"
" Performance Profile - rofi-profile"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi"
fi
}
rofi_graphics_menu() {
declare -a options=(
"Query Current Graphics - graphics-query"
"Switch to Compute Mode - graphics-compute"
"Switch to Hybrid Mode - graphics-hybrid"
"Switch to Integrated Mode - graphics-integrated"
"Switch to Nvidia Mode - graphics-nvidia"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi-graphics"
fi
}
rofi_profile_menu() {
declare -a options=(
"Query Current Profile - profile-query"
"Switch to Battery Mode - profile-battery"
"Switch to Balanced Mode - profile-balanced"
"Switch to Performance Mode - profile-performance"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" != "quit" ]]; then
main "--$option" && main "--rofi-profile"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--rofi-graphics)
rofi_graphics_menu
;;
--graphics-query)
current_graphics=$(pkexec system76-power graphics)
notify-send "System76-Power Graphics" "$current_graphics"
;;
--graphics-compute)
notify-send "System76-Power Graphics" "Switching to Compute Graphics..."
pkexec system76-power graphics compute
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--graphics-hybrid)
notify-send "System76-Power Graphics" "Switching to Hybrid Graphics..."
pkexec system76-power graphics hybrid
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--graphics-integrated)
notify-send "System76-Power Graphics" "Switching to Integrated Graphics..."
pkexec system76-power graphics integrated
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--graphics-nvidia)
notify-send "System76-Power Graphics" "Switching to Nvidia Graphics..."
pkexec system76-power graphics nvidia
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--rofi-profile)
rofi_profile_menu
;;
--profile-query)
current_profile=$(pkexec system76-power profile)
notify-send "System76-Power Profile" "$current_profile"
;;
--profile-battery)
pkexec system76-power profile battery
notify-send "System76-Power Profile" "Switched to Battery Profile"
;;
--profile-balanced)
pkexec system76-power profile balanced
notify-send "System76-Power Profile" "Switched to Balanced Profile"
;;
--profile-performance)
pkexec system76-power profile performance
notify-send "System76-Power Profile" "Switched to Performance Profile"
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@