Skip to content

Commit

Permalink
Format shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxattax97 committed Aug 29, 2024
1 parent 1059fd8 commit ed8c5e6
Show file tree
Hide file tree
Showing 12 changed files with 1,021 additions and 563 deletions.
1,403 changes: 934 additions & 469 deletions archiso/40-user.sh

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions bin/ctlpanel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

dont_join=${1:-0};
dont_join=${1:-0}

session="CtlPanel"
w_htop="Htop"
Expand All @@ -16,41 +16,41 @@ w_monero="Monero"

network_interface="eno1"

tmux has-session -t "CtlPanel" 2>/dev/null
tmux has-session -t "CtlPanel" 2> /dev/null

if [ "$?" -eq 1 ]; then
tmux new-session -d -s "$session" -n "$w_htop"
tmux new-window -n "$w_network" -t "$session"
tmux new-window -n "$w_logs" -t "$session"
tmux new-window -n "$w_minecraft" -t "$session" -c "/home/resolute/minecraft"
tmux new-window -n "$w_minecraft_mod" -t "$session" -c "/home/resolute/minecraft"
tmux new-window -n "$w_terraria" -t "$session" -c "/home/resolute/terraria/tmodloader"
tmux new-window -n "$w_course_watcher" -t "$session" -c "/home/resolute/src/purdue-course-watcher"
tmux new-window -n "$w_gekko" -t "$session" -c "/home/resolute/src/gekko"
tmux new-window -n "$w_monero" -t "$session"
tmux new-window -t "$session" # Open a bash terminal at the end.

tmux split-window -h -t "$session:$w_network"

tmux send-keys -t "$session:$w_htop" "htop" C-m
tmux send-keys -t "$session:$w_network.0" "speedometer -r $network_interface -t $network_interface" C-m
tmux send-keys -t "$session:$w_network.1" "clear && sudo iftop" C-m
tmux send-keys -t "$session:$w_logs" "clear && journalctl --system -f" C-m
tmux send-keys -t "$session:$w_minecraft" "cd main/ && clear && ./run.sh" C-m
tmux send-keys -t "$session:$w_minecraft_mod" "cd mainSpigot/ && clear && ./run.sh" C-m
tmux send-keys -t "$session:$w_terraria" "clear && ./tModLoaderServer # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_factorio" "clear && journalctl -f -u factorio.service" C-m
tmux send-keys -t "$session:$w_course_watcher" "clear && node index.js # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_gekko" "clear && node gekko --ui # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_monero" "clear && xmrig -o gulf.moneroocean.stream:10008 -u 46cWMT5YP2A8a8bSDzj3r7C7XkCkTWvJz2FFDjqnk8hnATYCrBJD22R1cyZJwK4tDTNGHFMTuSkCbNZeaYjhPADx9QisCcA -p Resolute --cpu-priority 1 -k # Disabled in ctlpanel" #C-m

if [ "$dont_join" -ne 1 ]; then
echo "Attaching to CtlPanel session ..."
tmux -2 attach-session -t "$session:$w_htop"
fi
tmux new-session -d -s "$session" -n "$w_htop"
tmux new-window -n "$w_network" -t "$session"
tmux new-window -n "$w_logs" -t "$session"
tmux new-window -n "$w_minecraft" -t "$session" -c "/home/resolute/minecraft"
tmux new-window -n "$w_minecraft_mod" -t "$session" -c "/home/resolute/minecraft"
tmux new-window -n "$w_terraria" -t "$session" -c "/home/resolute/terraria/tmodloader"
tmux new-window -n "$w_course_watcher" -t "$session" -c "/home/resolute/src/purdue-course-watcher"
tmux new-window -n "$w_gekko" -t "$session" -c "/home/resolute/src/gekko"
tmux new-window -n "$w_monero" -t "$session"
tmux new-window -t "$session" # Open a bash terminal at the end.

tmux split-window -h -t "$session:$w_network"

tmux send-keys -t "$session:$w_htop" "htop" C-m
tmux send-keys -t "$session:$w_network.0" "speedometer -r $network_interface -t $network_interface" C-m
tmux send-keys -t "$session:$w_network.1" "clear && sudo iftop" C-m
tmux send-keys -t "$session:$w_logs" "clear && journalctl --system -f" C-m
tmux send-keys -t "$session:$w_minecraft" "cd main/ && clear && ./run.sh" C-m
tmux send-keys -t "$session:$w_minecraft_mod" "cd mainSpigot/ && clear && ./run.sh" C-m
tmux send-keys -t "$session:$w_terraria" "clear && ./tModLoaderServer # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_factorio" "clear && journalctl -f -u factorio.service" C-m
tmux send-keys -t "$session:$w_course_watcher" "clear && node index.js # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_gekko" "clear && node gekko --ui # Disabled in ctlpanel" #C-m
tmux send-keys -t "$session:$w_monero" "clear && xmrig -o gulf.moneroocean.stream:10008 -u 46cWMT5YP2A8a8bSDzj3r7C7XkCkTWvJz2FFDjqnk8hnATYCrBJD22R1cyZJwK4tDTNGHFMTuSkCbNZeaYjhPADx9QisCcA -p Resolute --cpu-priority 1 -k # Disabled in ctlpanel" #C-m

if [ "$dont_join" -ne 1 ]; then
echo "Attaching to CtlPanel session ..."
tmux -2 attach-session -t "$session:$w_htop"
fi
else
if [ "$dont_join" -ne 1 ]; then
echo "Entering a child CtlPanel session ..."
tmux -2 new-session -t "$session:$w_htop"
fi
if [ "$dont_join" -ne 1 ]; then
echo "Entering a child CtlPanel session ..."
tmux -2 new-session -t "$session:$w_htop"
fi
fi
3 changes: 1 addition & 2 deletions bin/find-online
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ friends=("aneusted" "aurnes" "yu646" "dkrolopp" "girishg" "liu2034" "buckmast" "
echo "Scanning for online users ..."
count=0

for user in "${friends[@]}"
do
for user in "${friends[@]}"; do
if [ "$USER" != "$user" ]; then
if [ ! -z "$(w | grep "$user")" ]; then
echo "$user is online."
Expand Down
19 changes: 8 additions & 11 deletions bin/gspeak
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# [email protected] #
#################################


INPUT=$*
STRINGNUM=0

Expand All @@ -13,27 +12,25 @@ echo "---------------------------"
echo "Speech Script by Dan Fountain"
echo "[email protected]"
echo "---------------------------"
for key in "${!ary[@]}"
do
for key in "${!ary[@]}"; do
SHORTTMP[$STRINGNUM]="${SHORTTMP[$STRINGNUM]} ${ary[$key]}"
LENGTH=$(echo ${#SHORTTMP[$STRINGNUM]})
#echo "word:$key, ${ary[$key]}"
#echo "adding to: $STRINGNUM"
if [[ "$LENGTH" -lt "100" ]]; then
#echo starting new line
SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
#echo starting new line
SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
else
STRINGNUM=$(($STRINGNUM+1))
SHORTTMP[$STRINGNUM]="${ary[$key]}"
SHORT[$STRINGNUM]="${ary[$key]}"
STRINGNUM=$(($STRINGNUM + 1))
SHORTTMP[$STRINGNUM]="${ary[$key]}"
SHORT[$STRINGNUM]="${ary[$key]}"
fi
done

for key in "${!SHORT[@]}"
do
for key in "${!SHORT[@]}"; do
#echo "line: $key is: ${SHORT[$key]}"

echo "Playing line: $(($key+1)) of $(($STRINGNUM+1))"
echo "Playing line: $(($key + 1)) of $(($STRINGNUM + 1))"
NEXTURL=$(echo ${SHORT[$key]} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
mpg123 -q "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$NEXTURL&tl=En-us"
done
7 changes: 3 additions & 4 deletions bin/idle-mine
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ getCharging() {

getActiveSSHSessions() {
lines="$(ps aux | grep sshd | wc -l)"
echo "$(( (lines - 1) / 2 ))"
echo "$(((lines - 1) / 2))"
}

getLockedTime() {
# Time is in milliseconds.
rawTime=""
if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
rawTime="$(dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.GetActiveTime | grep uint32 | awk '{ printf $2 };')"
rawTime="$(dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.GetActiveTime | grep uint32 | awk '{ printf $2 };')"
else
rawTime="$(dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/freedesktop/ScreenSaver org.freedesktop.ScreenSaver.GetActiveTime | grep uint32 | awk '{ printf $2 };')"
fi
Expand Down Expand Up @@ -102,7 +102,7 @@ initMining() {
USE_GPU=0
fi

tmux has-session -t "$session" 2>/dev/null
tmux has-session -t "$session" 2> /dev/null

if [ "$?" -ne 1 ]; then
log "An idling tmux session already exists; exiting"
Expand Down Expand Up @@ -220,7 +220,6 @@ tick() {
IN_USE=0
fi


if [ -n "$DEBUG" ]; then
echo "MINING: $MINING | IN_USE: $IN_USE | LOCKED_TIME: $(getLockedTime) | IDLE_TO_START: $IDLE_TO_START"
fi
Expand Down
2 changes: 1 addition & 1 deletion config/awesome/scripts/locker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

exec xautolock -detectsleep \
-time 10 -locker "light-locker-command -l" \
-time 10 -locker "light-locker-command -l"
5 changes: 2 additions & 3 deletions config/bspwm/bspwmrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bspc config top_padding 20
bspc config split_ratio 0.50
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config automatic_scheme alternate
bspc config automatic_scheme alternate

# Use `xprop` to find these, use 2nd entry of WM_CLASS.
bspc rule -a Gimp desktop='^8' state=floating follow=on
Expand All @@ -35,8 +35,7 @@ bspc rule -a Yad state=floating sticky

bspwm_log_root="/tmp/bspwm_logs"

function runOnce()
{
function runOnce() {
cmd="${1}"
fork="${2}"
logfile="${3}"
Expand Down
6 changes: 3 additions & 3 deletions config/i3/init
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export ETH_INTERFACE=enp0s31f6

# Compton
killall -q compton
while pgrep -x compton >/dev/null; do sleep 0.1s; done
while pgrep -x compton > /dev/null; do sleep 0.1s; done
#compton -f -D 2 -i 0.85 -z \
#--backend glx --glx-no-stencil --glx-no-rebind-pixmap --glx-swap-method exchange \
#-b
compton --opengl --vsync opengl-swc --paint-on-overlay -cCG -r 10 -o 0.5 -l-12 -t-12 -fF -D35 -I0.4 -O0.4 --blur-background --blur-kern 7x7box -b

# Polybar
killall -q polybar
while pgrep -x polybar >/dev/null; do sleep 0.1s; done
while pgrep -x polybar > /dev/null; do sleep 0.1s; done

polybar main &

Expand All @@ -28,6 +28,6 @@ polybar main &
# ckb-next

killall -q ckb-next
while pgrep -x ckb-next >/dev/null; do sleep 0.1s; done
while pgrep -x ckb-next > /dev/null; do sleep 0.1s; done

ckb-next -b &
28 changes: 14 additions & 14 deletions config/rofi/menu/MAIN
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,46 @@ $task
$proj
$usem" | rofi "${ROFI_OPTIONS[@]}" -dmenu -i -p "search: ")

if [ "$another" == "$file" ] ; then
if [ "$another" == "$file" ]; then
$HOME/.config/rofi/menu/locate

elif [ "$another" == "$task" ] ; then
elif [ "$another" == "$task" ]; then
$HOME/.config/rofi/menu/task

elif [ "$another" == "$book" ] ; then
elif [ "$another" == "$book" ]; then
$HOME/.config/rofi/menu/books

elif [ "$another" == "$note" ] ; then
elif [ "$another" == "$note" ]; then
$HOME/.config/rofi/menu/note

elif [ "$another" == "$locl" ] ; then
elif [ "$another" == "$locl" ]; then
exec $HOME/.config/rofi/menu/marks $HOME/sets/.notes/localhost.wiki

elif [ "$another" == "$clip" ] ; then
elif [ "$another" == "$clip" ]; then
rofi "${ROFI_OPTIONS[@]}" -modi "clipboard:greenclip print" -show clipboard

elif [ "$another" == "$usem" ] ; then
elif [ "$another" == "$usem" ]; then
appname=$(cat $HOME/.config/applist | grep "\S" | rofi "${ROFI_OPTIONS[@]}" -threads 0 -dmenu -i -p 'apps:')
thelink=$(echo $appname | cut -d'+' -f3 | tr -d ' ')
[[ ! -n $appname ]] && exit
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
[[ $thelink =~ $regex ]]&& brave $thelink || $edit_with -e nvim ~/.config/applist
[[ $thelink =~ $regex ]] && brave $thelink || $edit_with -e nvim ~/.config/applist

elif [ "$another" == "$cont" ] ; then
elif [ "$another" == "$cont" ]; then
exec $HOME/.config/rofi/menu/contacts

elif [ "$another" == "$proj" ] ; then
elif [ "$another" == "$proj" ]; then
pather=$(/env/go/bin/proji ls | head -n-1 | tail -n+4 | cut -d "|" -f3-5 | tr "|" "\t" | rofi "${ROFI_OPTIONS[@]}" -threads 0 -dmenu -i -p 'projects:' | cut -f2)
nameer=$(basename $pather)
[[ $pather ]] && sed -e "s|.*root.*| root: $pather|" -e "1cname: \"$nameer\"" $HOME/.config/tmux/PRO.yml > $HOME/.config/tmux/prot.yml && /env/cpp/bin/tmass -l $HOME/.config/tmux load prot && kitty --class=til tmux attach -t $nameer
# kitty --class=til tmux attach -t $nameer

elif [ "$another" == "$pass" ] ; then
elif [ "$another" == "$pass" ]; then
exec $HOME/.config/rofi/menu/pass

elif [ -z "$another" ] ; then
echo "variable empty" && exit 1
elif [ -z "$another" ]; then
echo "variable empty" && exit 1

else
exec nohup $another > /dev/null 2>&1 &
exec nohup $another > /dev/null 2>&1 &
fi
2 changes: 1 addition & 1 deletion config/rofi/menu/sxhkd-help
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
ROFI_OPTIONS=( -theme $HOME/.config/rofi/bar.theme.rasi -theme-str "*{accent: ${color1:-#3294ff}; font: \"Hack 12\";}")
ROFI_OPTIONS=(-theme $HOME/.config/rofi/bar.theme.rasi -theme-str "*{accent: ${color1:-#3294ff}; font: \"Hack 12\";}")

options="$(awk '/^[a-z]/ && last {print $0,"\t",last} {last=""} /^#/{last=$0}' $HOME/.config/sxhkd/sxhkdrc | column -t -s $'\t')"
chosen="$(echo -e "$options" | rofi "${ROFI_OPTIONS[@]}" -dmenu)" # -selected-row 2
14 changes: 7 additions & 7 deletions config/rofi/menu/system
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
ROFI_OPTIONS=( -theme $HOME/.config/rofi/bar.theme.rasi -theme-str "*{accent: ${color1:-#3294ff};}")
ROFI_OPTIONS=(-theme $HOME/.config/rofi/bar.theme.rasi -theme-str "*{accent: ${color1:-#3294ff};}")

shutdown="shutdown"
reboot="reboot"
Expand All @@ -15,21 +15,21 @@ YESNO="no\nyes"

case $chosen in
$shutdown)
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && systemctl poweroff
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && systemctl poweroff
;;
$reboot)
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && systemctl reboot
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && systemctl reboot
;;
$lock)
loginctl lock-session ${XDG_SESSION_ID-}
loginctl lock-session ${XDG_SESSION_ID-}
;;
$suspend)
systemctl suspend
systemctl suspend
;;
$hibernate)
systemctl hibernate
systemctl hibernate
;;
$logout)
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && loginctl terminate-session ${XDG_SESSION_ID-}
[ $(echo -e $YESNO | rofi "${ROFI_OPTIONS[@]}" -theme-str "*{accent: #e53714;}" -dmenu -i -p "Proceed?") == "yes" ] && loginctl terminate-session ${XDG_SESSION_ID-}
;;
esac
25 changes: 12 additions & 13 deletions config/ssh/aws-ssm-ec2-proxy-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ ssh_public_key_path="$4"
ssh_public_key="$(cat "${ssh_public_key_path}")"
ssh_public_key_timeout=60

if [[ "${ec2_instance_id}" == *"${REGION_SEPARATOR}"* ]]
then
export AWS_DEFAULT_REGION="${ec2_instance_id##*${REGION_SEPARATOR}}"
ec2_instance_id="${ec2_instance_id%%${REGION_SEPARATOR}*}"
if [[ "${ec2_instance_id}" == *"${REGION_SEPARATOR}"* ]]; then
export AWS_DEFAULT_REGION="${ec2_instance_id##*${REGION_SEPARATOR}}"
ec2_instance_id="${ec2_instance_id%%${REGION_SEPARATOR}*}"
fi

>/dev/stderr echo "Add public key ${ssh_public_key_path} for ${ssh_user} at instance ${ec2_instance_id} for ${ssh_public_key_timeout} seconds"
echo "Add public key ${ssh_public_key_path} for ${ssh_user} at instance ${ec2_instance_id} for ${ssh_public_key_timeout} seconds" > /dev/stderr
aws ssm send-command \
--instance-ids "${ec2_instance_id}" \
--document-name 'AWS-RunShellScript' \
--comment "Add an SSH public key to authorized_keys for ${ssh_public_key_timeout} seconds" \
--parameters commands="\"
--instance-ids "${ec2_instance_id}" \
--document-name 'AWS-RunShellScript' \
--comment "Add an SSH public key to authorized_keys for ${ssh_public_key_timeout} seconds" \
--parameters commands="\"
mkdir -p ~${ssh_user}/.ssh && cd ~${ssh_user}/.ssh || exit 1
authorized_key='${ssh_public_key} ssm-session'
Expand All @@ -63,8 +62,8 @@ aws ssm send-command \
mv .authorized_keys authorized_keys
\""

>/dev/stderr echo "Start ssm session to instance ${ec2_instance_id}"
echo "Start ssm session to instance ${ec2_instance_id}" > /dev/stderr
aws ssm start-session \
--target "${ec2_instance_id}" \
--document-name 'AWS-StartSSHSession' \
--parameters "portNumber=${ssh_port}"
--target "${ec2_instance_id}" \
--document-name 'AWS-StartSSHSession' \
--parameters "portNumber=${ssh_port}"

0 comments on commit ed8c5e6

Please sign in to comment.