1
0
Fork 0

changes made:

- converted all tabs (that I could find) to spaces
 - move shell _then_ and _do_ keywords on same line as _if_ and _loops_
 - re-organize .scripts/ dir (add sentinel and bluefeds scripts too)
This commit is contained in:
Pratham Patel 2022-09-25 03:47:51 +05:30
parent e8a4944a11
commit fc036396a0
30 changed files with 263 additions and 125 deletions

View File

@ -1,5 +1,5 @@
if [[ "$OSTYPE" == "freebsd"* ]]; then
echo "FreeBSD"
echo "WIP: FreeBSD"
elif [[ "$OSTYPE" == "openbsd"* ]]; then
echo "OpenBSD"
echo "WIP: OpenBSD"
fi

View File

@ -7,34 +7,34 @@ pgrep -x sxhkd > /dev/null || sxhkd &
bspc monitor -d work virtualization music other extra extraa
bspc config border_width 6
bspc config window_gap 12
bspc config border_width 6
bspc config window_gap 12
bspc config focused_border_color \#FF0000
bspc config active_border_color \#FFFFFF
bspc config normal_border_color \#FFFFFF #08C96B
bspc config presel_border_color \#A57FE8
bspc config focused_border_color \#FF0000
bspc config active_border_color \#FFFFFF
bspc config normal_border_color \#FFFFFF #08C96B
bspc config presel_border_color \#A57FE8
bspc config split_ratio 0.5
bspc config split_ratio 0.5
bspc config borderless_monocle false
bspc config gapless_monocle true
bspc config borderless_monocle false
bspc config gapless_monocle true
bspc config left_padding 8
bspc config bottom_padding 8
bspc config top_padding 8
bspc config right_padding 8
bspc config left_padding 8
bspc config bottom_padding 8
bspc config top_padding 8
bspc config right_padding 8
bspc config left_monocle_padding 6
bspc config bottom_monocle_padding 6
bspc config top_monocle_padding 6
bspc config right_monocle_padding 6
bspc config left_monocle_padding 6
bspc config bottom_monocle_padding 6
bspc config top_monocle_padding 6
bspc config right_monocle_padding 6
bspc config focus_follows_pointer false
bspc config pointer_follows_focus false
bspc config pointer_follows_monitor false
bspc config focus_follows_pointer false
bspc config pointer_follows_focus false
bspc config pointer_follows_monitor false
bspc config center_pseudo_tiled false
bspc config center_pseudo_tiled false
bspc rule -a mpv state=floating
bspc rule -a "Nvidia-settings" state=floating

View File

@ -1,14 +1,13 @@
#!/usr/bin/env bash
if [[ $(pidof mpv) ]]; then
POS=$(echo '{ "command": ["get_property_string", "time-pos"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1)
DUR=$(echo '{ "command": ["get_property_string", "duration"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1)
METADATA=$(echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpvsocket | awk -F "\"*,\"*" '{print $1}' | awk -F "\"*:\"*" '{print $2}' )
printf "$METADATA"
printf ' (%d:%02d:%02d' $(($POS/3600)) $(($POS%3600/60)) $(($POS%60))
printf ' / %d:%02d:%02d)\n' $(($DUR/3600)) $(($DUR%3600/60)) $(($DUR%60))
POS=$(echo '{ "command": ["get_property_string", "time-pos"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1)
DUR=$(echo '{ "command": ["get_property_string", "duration"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1)
METADATA=$(echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpvsocket | awk -F "\"*,\"*" '{print $1}' | awk -F "\"*:\"*" '{print $2}' )
printf "$METADATA"
printf ' (%d:%02d:%02d' $(($POS/3600)) $(($POS%3600/60)) $(($POS%60))
printf ' / %d:%02d:%02d)\n' $(($DUR/3600)) $(($DUR%3600/60)) $(($DUR%60))
else
exit
exit
fi

View File

@ -1,10 +1,10 @@
configuration {
font: "Fira Code 14";
show-icons: true;
terminal: "alacritty";
/*icon-theme: ;*/
sidebar-mode: false;
click-to-exit: true;
show-match: true;
theme: "gruvbox-dark-hard";
font: "Fira Code 14";
show-icons: true;
terminal: "alacritty";
/*icon-theme: ;*/
sidebar-mode: false;
click-to-exit: true;
show-match: true;
theme: "gruvbox-dark-hard";
}

View File

@ -6,73 +6,63 @@ STAT1="$(amixer -D pulse sget Master | tail -n 1 | cut -c 35)"
STAT2="$(amixer -D pulse sget Master | tail -n 1 | cut -c 40)"
UPORDOWN="$1"
if [ "$UPORDOWN" = "up" ]
then
if [ "$STAT0" = "f" ] || [ "$STAT1" = "f" ] || [ "$STAT2" = "f" ]
then
notify-send -u critical "Volume Manager" "Unmuted\!"
pactl set-sink-mute 1 0
fi
amixer -D pulse sset Master 10%+
if [[ "$UPORDOWN" == "up" ]]; then
if [[ "$STAT0" == "f" ]] || [[ "$STAT1" == "f" ]] || [[ "$STAT2" == "f" ]]; then
notify-send -u critical "Volume Manager" "Unmuted\!"
pactl set-sink-mute 1 0
fi
amixer -D pulse sset Master 10%+
fi
if [ "$UPORDOWN" = "down" ]
then
if [[ "$UPORDOWN" == "down" ]]; then
# the commented out part below should work
# but for some reason
# decreasing 10% volume shows 9% volume decrease in polybar widget
# but it is actually 10% volume decrease when checking with amixer
# so less efficient code; for the OCD;
#if [ "$VOL" = "100%" ]
#then
# amixer -D pulse sset Master 90%
#else
# amixer -D pulse sset Master 10%-
#fi
# the commented out part below should work
# but for some reason
# decreasing 10% volume shows 9% volume decrease in polybar widget
# but it is actually 10% volume decrease when checking with amixer
# so less efficient code; for the OCD;
case "$VOL" in
case "$VOL" in
"100%")
amixer -D pulse sset Master 90%
;;
"100%")
amixer -D pulse sset Master 90%
;;
"90%]")
amixer -D pulse sset Master 80%
;;
"90%]")
amixer -D pulse sset Master 80%
;;
"80%]")
amixer -D pulse sset Master 70%
;;
"80%]")
amixer -D pulse sset Master 70%
;;
"70%]")
amixer -D pulse sset Master 60%
;;
"70%]")
amixer -D pulse sset Master 60%
;;
"60%]")
amixer -D pulse sset Master 50%
;;
"60%]")
amixer -D pulse sset Master 50%
;;
"50%]")
amixer -D pulse sset Master 40%
;;
"50%]")
amixer -D pulse sset Master 40%
;;
"40%]")
amixer -D pulse sset Master 30%
;;
"40%]")
amixer -D pulse sset Master 30%
;;
"30%]")
amixer -D pulse sset Master 20%
;;
"30%]")
amixer -D pulse sset Master 20%
;;
"20%]")
amixer -D pulse sset Master 10%
;;
"20%]")
amixer -D pulse sset Master 10%
;;
"0%] ")
amixer -D pulse sset Master 10%-
;;
esac
"0%] ")
amixer -D pulse sset Master 10%-
;;
esac
fi

View File

@ -1,66 +1,66 @@
# launch rofi
super + space
rofi -modi drun,run -show drun
rofi -modi drun,run -show drun
# Return to launch terminal emulator
# b to launch browser
super + {Return,b}
{alacritty,firefox}
{alacritty,firefox}
# w to reload/relaunch feh/change bg
# p to reload/relaunch polybar
# Escape to turn screen off and lock the computer
super + shift + {w,p,Escape}
{bash $HOME/.config/feh/fehbg &,bash $HOME/.config/polybar/launch.sh &,bash $HOME/.config/sxhkd/mods/module_lock_script.sh}
{bash $HOME/.config/feh/fehbg &,bash $HOME/.config/polybar/launch.sh &,bash $HOME/.config/sxhkd/mods/module_lock_script.sh}
# c to reload config
# q to quit selected window
super + shift + {c,q}
{pkill -USR1 -x sxhkd && bspc wm -r,bspc node -c}
{pkill -USR1 -x sxhkd && bspc wm -r,bspc node -c}
# t to enable tiled mode for current window
# shift + t to enable floating mode for current window
# f to enable fullscreen mode for current window
super + {t,shift + t,f}
bspc node -t {tiled,floating,fullscreen}
bspc node -t {tiled,floating,fullscreen}
# super h,j,k,l to move between windows
# add shift to swap the window to left right etc
super + {_,shift +, ctrl +}{h,j,k,l}
bspc node -{f,s,n} {west,south,north,east}
bspc node -{f,s,n} {west,south,north,east}
# expand a window by moving one of its side outward
super + alt + shift {h,j,k,l}
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}
#contract a window by moving one of its side inward
super + ctrl + shift + {h,j,k,l}
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}
# focus the next/previous desktop in the current monitor
super + bracket{left,right}
bspc desktop -f {prev,next}.local
bspc desktop -f {prev,next}.local
# [ to decrease volume by 10%
# ] to increase volume by 10%
super + shift + bracket{left,right}
{bash $HOME/.config/sxhkd/mods/module_alsa.sh down,bash $HOME/.config/sxhkd/mods/module_alsa.sh up}
{bash $HOME/.config/sxhkd/mods/module_alsa.sh down,bash $HOME/.config/sxhkd/mods/module_alsa.sh up}
# switch between nodes (locally)
alt + {_,shift} + Tab
bspc node -f {next,prev}.local.!hidden.window
bspc node -f {next,prev}.local.!hidden.window
# focus or send to the given desktop
super + {_,shift + }{1-9,0}
bspc {desktop -f,node -d} '^{1-9,10}'
bspc {desktop -f,node -d} '^{1-9,10}'
# move a floating window
super + {Left,Down,Up,Right}
bspc node -v {-20 0,0 20,0 -20,20 0}
bspc node -v {-20 0,0 20,0 -20,20 0}
# bspwm rotate: split horizontally/vertically
super + shift + {v,s}
bspc node @parent -R {90,90}
bspc node @parent -R {90,90}
# exit bspwn (return to console)
super + shift + ctrl + alt + 0
bspc quit
bspc quit

View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
# systemd services for each of my podman container
CONTAINER_SERVICES=(
"container-gitea-chitragupta.service" \
"container-gitea-govinda.service" \
"container-hugo-mahayogi.service" \
"container-hugo-vaikunthnatham.service" \
"container-nextcloud-chitragupta.service" \
"container-nextcloud-govinda.service" \
"container-transmission-raadhe.service" \
"container-caddy-vishwambhar.service" \
)
# calculate uptime in MINUTES
SECONDS_SINCE=$(date --date "$(uptime -s)" +%s)
SECONDS_NOW=$(date +%s)
SECONDS_DIFF=$((SECONDS_NOW - SECONDS_SINCE))
UPTIME_MINUTES=$((SECONDS_DIFF / 60))
UPTIME_CMP=20
# Nextcloud takes time to start
# So don't immediately restart services (and send e-mail)
# until the uptime is greater than 20 minutes
if [[ "$UPTIME_MINUTES" -gt "$UPTIME_CMP" ]]; then
# loop through all services in $CONTAINER_SERVICES
for INDV_SERVICE in ${CONTAINER_SERVICES[@]}; do
CHECK_ENABLEMENT=$(systemctl --user is-enabled "$INDV_SERVICE")
# check if a service is enabled
# don't restart services that I manually disabled
if [[ "$CHECK_ENABLEMENT" == "enabled" ]]; then
# check if a service is active or not
CONTAINER_STAT=1
systemctl --user is-active --quiet service "$INDV_SERVICE" && CONTAINER_STAT=0
# if container is not running
# start it
if [[ $CONTAINER_STAT -eq 1 ]]; then
# pretty date format
CURR_DATE=$(date +'(UTC%:::z) %Y/%m/%d %H:%M:%S')
# what should be in the e-mail _IF_ the service is restarted?
MAILCONTENT=$HOME/.scripts/_bluefeds/mail/containers/"$INDV_SERVICE".mailcontents
# restart $INDV_SERVICE _AND_ container-caddy-vishwambhar.service
systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-caddy-vishwambhar.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $HOME/.log/cron/pratham/log
# send e-mail about the service that was restarted
/usr/sbin/ssmtp thefirst1322@gmail.com < $MAILCONTENT
fi
fi
done
fi

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
DATE=$(date +"%Y_%m_%d__%H_%M_%S");
/usr/sbin/zfs snapshot trayimurti/containers/volumes/nextcloud@$DATE

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'caddy-vishwambhar'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'gitea-chitragupta'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'gitea-govinda'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'hugo-mahayogi'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'hugo-vaikunthnatham'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'nextcloud-chitragupta'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'nextcloud-govinda'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'nextcloud-karma'

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: Restarted 'transmission-raadhe'

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
CHK_DATE=$(date +'%Y/%m/%d')
LOG_FILE=$HOME/.log/cron/pratham/log
if [[ -f "$LOG_FILE" ]]; then
echo "-----------"
cat "$LOG_FILE" | grep "${CHK_DATE}" | grep --color=auto -E "container.*service"
echo "-----------"
fi

View File

@ -9,4 +9,5 @@
/usr/bin/updatedb &
sleep 600s
/home/pratham/.scripts/flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby ([re]boot-ed)" && exit 0
# don't use $HOME, root is running this
/home/pratham/.scripts/_flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby ([re]boot-ed)" && exit 0

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
/usr/bin/updatedb &
sleep 600s
# don't use $HOME, root is running this
/home/pratham/.scripts/_flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby (resumed from suspend)" && exit 0

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
ORIGDIR="/var/lib/transmission-daemon/.config/transmission-daemon/torrents"
CONFDIR="/libertine/config_dir"
TORRDIR="/libertine/torrents"
rsync --size-only $ORIGDIR/*.* $CONFDIR/
chmod 664 $CONFDIR/*.*
chown ubuntu:ubuntu -v $CONFDIR/*.*
sleep 5
chmod 775 -R $TORRDIR
chown ubuntu:debian-transmission -R $TORRDIR
find $TORRDIR -type f -exec chmod 664 {} \;
find $TORRDIR -type f -name "*.DS_Store" -exec rm {} \;
sleep 5
updatedb

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
transmission-daemon.service
CHECK_ENABLEMENT=$(systemctl --user is-enabled transmission-daemon.service)
# check if a service is enabled
# don't restart services that I manually disabled
if [[ "$CHECK_ENABLEMENT" == "enabled" ]]; then
# check if a service is active or not
CONTAINER_STAT=1
systemctl --user is-active --quiet service transmission-daemon.service && CONTAINER_STAT=0
# if container is not running
# start it
if [[ $CONTAINER_STAT -eq 1 ]]; then
systemctl --user start transmission-daemon.service
fi
else
exit 1
fi

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
DATE=$(date +"%Y_%m_%d__%H_%M_%S");
/usr/sbin/zfs snapshot libertine/container-vols/test@$DATE

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
MY_IP_ADDR=$(hostname -I | awk '{print $1}')
dig +time=2 +tries=1 +noall example.com @${MY_IP_ADDR}
if [[ $? -ne 0 ]]; then
/usr/local/bin/pihole restartdns
fi

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
/usr/bin/updatedb &
sleep 600s
/home/pratham/.scripts/flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby (resumed from suspend)" && exit 0

View File

@ -107,21 +107,18 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
alias gnomecc="XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
if command -v flatpak > /dev/null
then
if command -v flatpak > /dev/null; then
# Get a list of flatpak applications in the reverse domain name format
readarray -t ids < <(flatpak list --app --columns=application)
for id in "${ids[@]}"
do
for id in "${ids[@]}"; do
# Take everything past the last dot (the name)
name="${id##*.}"
# Make it lowercase to approximate binary name
binary="${name,,}"
# If there is not already a command at that name
if ! command -v "${binary}" > /dev/null
then
if ! command -v "${binary}" > /dev/null; then
# Create an alias that runs the flatpak
alias "$binary=flatpak run \"$id\""
fi

6
.zshrc
View File

@ -53,8 +53,7 @@ PROMPT=$'\n%F{11}─┬─[%f %F{5}%y %f%F{white}%? %D %*%f %F{11}]%f
# common stuff for Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]
then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# syntax highlighting
ZSH_SYNTAX_HIGH="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
@ -99,8 +98,7 @@ then
fi
# stuff for macOS
elif [[ "$OSTYPE" == "darwin"* ]]
then
elif [[ "$OSTYPE" == "darwin"* ]]; then
# syntax highlighting
ZSH_SYNTAX_HIGH="/usr/local/opt/zsh-fast-syntax-highlighting/share/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"