Adam Richardson's Site

Utility Scripts

Table of Contents

<2022-05-01 Sun>

sus - Suspend

sus is a small script that locks the screen and puts the computer into suspend mode

#!/bin/bash

xlock &

sleep 1 && systemctl suspend

backup

  • Backup script that rsyncs home dir to a remote server. Ideally a cron job is setup to run this automatically.
  • (Note: cronie only) For example you could add this to your crontab 30 19 * * * source $HOME/.bash_env && $HOME/.local/bin/backup >> $HOME/.local/log/backup.log 2>&1 to run the backup daily at 7:30pm
  • When using vixie-cron you will not be able to use environment variables in the crontab, instead you might need to make a runner script that does the above.
#!/bin/bash

TIME=$(date); echo "backup starting at $TIME"

echo "Pushing password store"
cd $HOME/.password-store/ && git pull && git push

echo "rsyncing home folder"
rsync --recursive --exclude-from $HOME/.backup_exclude $HOME $BACKUP_SERVER:$BACKUP_SERVER_PATH/$HOSTNAME/

TIME=$(date); echo "backup done at $TIME"

.cache
.mozilla
.local/share/Steam
Music/
music/
games/
code/mame_getter/
.st/

volume

#!/bin/bash

pamixer -d 5

VOL=`pamixer --get-volume`
BAR=$(seq --separator="─" 0 "$((VOL / 5))" | sed 's/[0-9]//g')

dunstify -i "audio-volume-high" -r 2593 -u normal "$BAR"" $VOL%"
#!/bin/bash

pamixer -i 5

VOL=`pamixer --get-volume`
BAR=$(seq --separator="─" 0 "$((VOL / 5))" | sed 's/[0-9]//g')

dunstify -i "audio-volume-high" -r 2593 -u normal "$BAR"" $VOL%"
#!/bin/bash

pamixer -t

if [ `pamixer --get-mute` == "true" ];
then
    dunstify -i "audio-volume-muted" -r 2593 -u normal " Mute"
else
    VOL=`pamixer --get-volume`
    BAR=$(seq --separator="─" 0 "$((VOL / 5))" | sed 's/[0-9]//g')

    dunstify -i "audio-volume-high" -r 2593 -u normal "$BAR"" $VOL%"
fi

brightness

#!/bin/bash

xbacklight -dec 5

LIGHT=`xbacklight`
LIGHT=`printf "%.0f" $LIGHT`

BAR=$(seq --separator="─" 0 "$((LIGHT / 5))" | sed 's/[0-9]//g')

dunstify -i "system" -r 2593 -u normal "$BAR"" $LIGHT%"
#!/bin/bash

xbacklight -inc 5

LIGHT=`xbacklight`
LIGHT=`printf "%.0f" $LIGHT`

BAR=$(seq --separator="─" 0 "$((LIGHT / 5))" | sed 's/[0-9]//g')

dunstify -i "system" -r 2593 -u normal "$BAR"" $LIGHT%"

mail

  • It is probably good to sync mail down every few hours
#!/bin/sh
TIME=$(date); echo "syncmail starting at $TIME"

# Sync all mailboxes
mbsync -a -q

# Reindex mail with notmuch
notmuch new

TIME=$(date); echo "syncmail ending at $TIME"

ec emacsclient -c

#!/bin/sh

emacsclient -c