From 9e82c96713989a7565eadac505b36e3dbe91cd5a Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 11 Jun 2023 07:56:17 -0400 Subject: Added, removed, renamed scripts --- .local/bin/alarm | 17 ----------- .local/bin/backups/assimilate | 60 ------------------------------------- .local/bin/check-repos | 10 ------- .local/bin/cmus/toggle-mode | 14 --------- .local/bin/cmus/toggle-shuf | 7 ----- .local/bin/create-cryptusb | 32 ++++++++++++++++++++ .local/bin/cryptusb/create-cryptusb | 34 --------------------- .local/bin/cryptusb/sync-cryptusb | 8 ----- .local/bin/dmenu/mount-device | 39 ------------------------ .local/bin/dmenu/unicode-select | 9 ------ .local/bin/dmenu/unmount-device | 28 ----------------- .local/bin/exiti3 | 4 --- .local/bin/get-pkgs | 8 ----- .local/bin/getmail | 3 ++ .local/bin/getpass | 7 ++--- .local/bin/getpass-otp | 2 +- .local/bin/id-init | 2 +- .local/bin/init-tv | 3 ++ .local/bin/kill-libvirtd | 22 -------------- .local/bin/kill-steam | 3 -- .local/bin/lock | 7 ----- .local/bin/merge-renovate | 8 +++++ .local/bin/mount-device | 39 ++++++++++++++++++++++++ .local/bin/mount-media | 4 +-- .local/bin/start-vm | 9 ------ .local/bin/stop-alarm | 5 ---- .local/bin/stop-vm | 21 ------------- .local/bin/sync-cryptusb | 8 +++++ .local/bin/sync-music | 3 +- .local/bin/theme/get-gradient | 13 -------- .local/bin/theme/gradient.py | 24 --------------- .local/bin/unicode-select | 9 ++++++ .local/bin/unmount-device | 28 +++++++++++++++++ .local/bin/who-depends | 13 -------- .local/bin/yt-fix | 5 ++-- 35 files changed, 141 insertions(+), 367 deletions(-) delete mode 100755 .local/bin/alarm delete mode 100755 .local/bin/backups/assimilate delete mode 100755 .local/bin/check-repos delete mode 100755 .local/bin/cmus/toggle-mode delete mode 100755 .local/bin/cmus/toggle-shuf create mode 100755 .local/bin/create-cryptusb delete mode 100755 .local/bin/cryptusb/create-cryptusb delete mode 100755 .local/bin/cryptusb/sync-cryptusb delete mode 100755 .local/bin/dmenu/mount-device delete mode 100755 .local/bin/dmenu/unicode-select delete mode 100755 .local/bin/dmenu/unmount-device delete mode 100755 .local/bin/exiti3 delete mode 100755 .local/bin/get-pkgs create mode 100755 .local/bin/getmail create mode 100755 .local/bin/init-tv delete mode 100755 .local/bin/kill-libvirtd delete mode 100755 .local/bin/kill-steam delete mode 100755 .local/bin/lock create mode 100755 .local/bin/merge-renovate create mode 100755 .local/bin/mount-device delete mode 100755 .local/bin/start-vm delete mode 100755 .local/bin/stop-alarm delete mode 100755 .local/bin/stop-vm create mode 100755 .local/bin/sync-cryptusb delete mode 100755 .local/bin/theme/get-gradient delete mode 100755 .local/bin/theme/gradient.py create mode 100755 .local/bin/unicode-select create mode 100755 .local/bin/unmount-device delete mode 100755 .local/bin/who-depends (limited to '.local/bin') diff --git a/.local/bin/alarm b/.local/bin/alarm deleted file mode 100755 index 2909ecf..0000000 --- a/.local/bin/alarm +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -[ $1 = "-h" -o $1 = "--help" ] && echo "usage: alarm time sound_file" && exit 0 -[ $# != 2 ] && echo "usage: alarm time sound_file" && exit 1 - -echo "alarm set for $1" -echo "$(basename "$2") is the alarm tone" - -while [ $(date +%H:%M) != "$1" ] -do - sleep 1 -done - -amixer -q sset Master 100% unmute -pkill -RTMIN+10 i3blocks -mpv --loop=inf $2 - diff --git a/.local/bin/backups/assimilate b/.local/bin/backups/assimilate deleted file mode 100755 index fd6ed7f..0000000 --- a/.local/bin/backups/assimilate +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Full system backup with borg - -# Validate argument - should either be onsite or offsite to specify location -ERRMSG="error: please specify either onsite or offsite" -[ $# -ne 1 ] && echo $ERRMSG && exit 1 -[ "$1" != "onsite" -a "$1" != "offsite" ] && echo $ERRMSG && exit 1 - -# Set variables -LOCATION="$1" -SUDO_OPTS="--preserve-env=BORG_PASSCOMMAND,PASSWORD_STORE_DIR" -CREATE_OPTS="--warning --stats --show-rc --exclude-caches --one-file-system" -LOG="$HOME/.config/borg/log" - -# Hack to get repository passphrase from pass -# The passcommand will be invoked as root, so use sudo to run it as the user calling the script -# who owns the password store. The environmental variable PASSWORD_STORE_DIR is passed through -# SUDO_OPTS to the borg commands, and then passed to this command from the borg command -# by the same means. This allows custom password store locations to work with this script. -export BORG_PASSCOMMAND="sudo $SUDO_OPTS -u $USER pass Borg-Backup/$(hostname)-$LOCATION" - -# Create variables and function to monitor exit status -WARNING=0 -ERROR=0 -check_rc() { - rc=$1 - [ $1 -eq 1 ] && WARNING=1 - [ $1 -eq 2 ] && ERROR=1 -} - -# Start backup -echo -e "\n$LOCATION $(date)\n" >> $LOG -notify-send "beginning $LOCATION backup" - -# Backup root partition -sudo $SUDO_OPTS borg create $CREATE_OPTS \ - --exclude '/dev/*' \ - --exclude '/proc/*' \ - --exclude '/sys/*' \ - --exclude '/tmp/*' \ - --exclude '/mnt/*' \ - --exclude '/media/*' \ - "/mnt/$LOCATION-backup/$(hostname)::root-{now:%Y-%m-%d}" / 2>>$LOG -check_rc $? - -# Backup boot parition -sudo $SUDO_OPTS borg create $CREATE_OPTS \ - "/mnt/$LOCATION-backup/$(hostname)::boot-{now:%Y-%m-%d}" /boot 2>>$LOG -check_rc $? - -# Send notifications based on return codes of archives - -[ $WARNING -eq 1 ] && notify-send "One or more archives produced a warning" \ - "Please check the log at $LOG" - -[ $ERROR -eq 1 ] && notify-send -u critical \ - "One or more archives produced an error and was unable to complete" \ - "Please check the log at $LOG" - -[ $WARNING -eq 0 -a $ERROR -eq 0 ] && notify-send "$LOCATION backup complete" diff --git a/.local/bin/check-repos b/.local/bin/check-repos deleted file mode 100755 index d528ce6..0000000 --- a/.local/bin/check-repos +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cd $HOME/repos -for repo in $(ls) -do - [ -d $repo/.git ] && echo $repo && \ - echo "------------------------------------------------------" && \ - git --git-dir=$repo/.git --work-tree=$repo status 2>/dev/null && \ - echo "------------------------------------------------------" -done diff --git a/.local/bin/cmus/toggle-mode b/.local/bin/cmus/toggle-mode deleted file mode 100755 index e73edc6..0000000 --- a/.local/bin/cmus/toggle-mode +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Toggles the cmus aaa mode (all,album,artist) - -cmus-remote -C "toggle aaa_mode" -mode=$(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3) -artist=$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3-) -album=$(cmus-remote -Q | grep "tag album" | cut -d ' ' -f 3-) - -[ "$mode" = "all" ] && dunstctl close-all && notify-send "Playing from full library" \ - && exit -[ "$mode" = "artist" ] && dunstctl close-all && notify-send "Playing by artist: $artist" \ - && exit -[ "$mode" = "album" ] && dunstctl close-all && notify-send "Playing from album: $album" \ - && exit diff --git a/.local/bin/cmus/toggle-shuf b/.local/bin/cmus/toggle-shuf deleted file mode 100755 index 57c2606..0000000 --- a/.local/bin/cmus/toggle-shuf +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Toggle and report status of shuffle mode in cmus - -cmus-remote --shuffle -status=$(cmus-remote -Q | grep shuffle | cut -d ' ' -f 3) -dunstctl close-all -[ "$status" = "true" ] && notify-send "Shuffle on" || notify-send "Shuffle off" diff --git a/.local/bin/create-cryptusb b/.local/bin/create-cryptusb new file mode 100755 index 0000000..77d232e --- /dev/null +++ b/.local/bin/create-cryptusb @@ -0,0 +1,32 @@ +#!/bin/sh +# Prompts for and creates a LUKS encrypted partition on a device + +# Get disks connected to the system that are hotpluggable (USBs) +devices="$(lsblk -lp -o NAME,SIZE,HOTPLUG,TYPE | grep "1 disk" | awk '{print $1,"-",$2}')" +[ "$devices" = "" ] && echo "no devices available" && exit 0 + +# Prompt for device selection from the user +select=$(echo "$devices" | dmenu -i -p "Select a device") +[ "$select" = "" ] && echo "no device selected" && exit 0 + +# Get confirmation since this is a potentially dangerous operation +yn=$(echo "No\nYes" | dmenu -i -p "Create encrypted partition on $select") +[ "$yn" != "Yes" ] && exit 0 + +# Get device path from selection string +usb=$(echo $select | cut -d ' ' -f 1) +echo $usb + +# Create LUKS partition on selected device (user will be promted for password to encrypt) +sudo cryptsetup --type luks2 luksFormat "$usb" + +# Open device and create filesystem on partition +echo "creating filesystem" +map_name="crypt-create" +sudo cryptsetup open "$usb" "$map_name" +sudo mkfs.ext4 "/dev/mapper/$map_name" + +# Close device after creating filesystem +sudo cryptsetup close "$map_name" + +echo "done" diff --git a/.local/bin/cryptusb/create-cryptusb b/.local/bin/cryptusb/create-cryptusb deleted file mode 100755 index e0f49fe..0000000 --- a/.local/bin/cryptusb/create-cryptusb +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Prompts for and creates a LUKS encrypted partition on a device - -# Get disks connected to the system that are hotpluggable (USBs) -devices="$(lsblk -lp -o NAME,SIZE,HOTPLUG,TYPE | grep "1 disk" | awk '{print $1,"-",$2}')" -[ "$devices" = "" ] && echo "no devices available" && exit 0 - -# Prompt for device selection from the user -select=$(echo "$devices" | dmenu -i -p "Select a device") -[ "$select" = "" ] && echo "no device selected" && exit 0 - -# Get confirmation since this is a potentially dangerous operation -yn=$(echo "No\nYes" | dmenu -i -p "Create encrypted partition on $select") -[ "$yn" != "Yes" ] && exit 0 - -# Get device path from selection string -usb=$(echo $select | cut -d ' ' -f 1) -echo $usb - -# Create LUKS partition on selected device (user will be promted for password to encrypt) -sudo cryptsetup --type luks2 luksFormat "$usb" - -# Open device and create filesystem on partition -echo "creating filesystem" -map_name="crypt-create" -sudo cryptsetup open "$usb" "$map_name" -sudo mkfs.ext4 "/dev/mapper/$map_name" - -# Close device after creating filesystem -sudo cryptsetup close "$map_name" - -echo "done" - - diff --git a/.local/bin/cryptusb/sync-cryptusb b/.local/bin/cryptusb/sync-cryptusb deleted file mode 100755 index 6ba2737..0000000 --- a/.local/bin/cryptusb/sync-cryptusb +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Syncs important files to encrypted USB - -mount-device && \ -rsync -avP --exclude="virtual_machines*" --exclude="media*" \ - --exclude="*.iso" --exclude="*.qcow2" \ - $HOME/ /mnt/cryptusb/$USER@$(hostname)/ && \ -unmount-device diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device deleted file mode 100755 index c2decd5..0000000 --- a/.local/bin/dmenu/mount-device +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Script for mounting block devices - -# Set askpass program for authentication -#export SUDO_ASKPASS=/usr/bin/ssh-askpass - -# Check for and get device to mount from user -devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')" -[ "$devs" = "" ] && exit 0 -dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)" -[ "$dev" = "" ] && exit 0 - -# Open and map drive if it is encrypted -crypt=0 -[ "$(lsblk -no FSTYPE $dev)" = "crypto_LUKS" ] && crypt=1 && \ - mapname="$(echo -n "" | dmenu -i -p "Enter device mapper name")" && \ - sudo cryptsetup open $dev $mapname - -# Attempt to mount without mountpoint for devices in /etc/fstab -sudo mount "$dev" 2>/dev/null && exit 0 - -# Get mountpoint from user -mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" -[ "$mntpnt" = "" ] && exit 1 - -# If selected mountpoint does not exist ask to create it -# If user decides not to create non-existent drive, exit -[ ! -d $mntpnt ] && create="$(echo "No\nYes" | \ - dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ - ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) - -# Mount the device -if [ $crypt -eq 1 ]; then - sudo -A mount /dev/mapper/$mapname $mntpnt && pgrep -x dunst && \ - notify-send "$dev mounted to $mntpnt" -else - sudo -A mount $dev $mntpnt && pgrep -x dunst && \ - notify-send "$dev mounted to $mntpnt" -fi diff --git a/.local/bin/dmenu/unicode-select b/.local/bin/dmenu/unicode-select deleted file mode 100755 index b797691..0000000 --- a/.local/bin/dmenu/unicode-select +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Select unicode character via dmenu and copy to clipboard - -line="$(cat ~/.local/share/unicode_list | dmenu -i -l 10)" -grep "$line" ~/.local/share/unicode_list | tr -d [:print:] | - xclip -r -selection "clipboard" && - notify-send "$(xclip -selection "clipboard" -o) copied to clipboard" - - diff --git a/.local/bin/dmenu/unmount-device b/.local/bin/dmenu/unmount-device deleted file mode 100755 index 239663d..0000000 --- a/.local/bin/dmenu/unmount-device +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Script for unmounting filesystems - -# Set askpass program for authentication -#export SUDO_ASKPASS=/usr/bin/ssh-askpass - -# Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...) -exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$" -parts="$(lsblk -lp | grep "\(part\|crypt\)\s*/" | grep -v "$exclude" | awk '{print $7,"-",$4}')" -[ "$parts" = "" ] && exit 0 - -# Get filesystem to unmount from user -crypt=0 -select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)" -[ "$select" = "" ] && exit 0 -dev="$(lsblk -lp | grep "$select" | awk '{print $1}')" -[ "$(lsblk -no TYPE $dev)" = "crypt" ] && crypt=1 - -# Unmount the filesystem -umount=0 -sudo umount $select && pgrep -x dunst && \ - notify-send "Unmounted $select ($dev)" && umount=1 \ - || notify-send "Error: unable to unmount $select" "Are you in it?" - -[ $crypt -eq 1 -a $umount -eq 1 ] && sudo cryptsetup close $dev && pgrep -x dunst && \ - notify-send "Unmapped $dev" && exit 14 - - diff --git a/.local/bin/exiti3 b/.local/bin/exiti3 deleted file mode 100755 index 0fe76bf..0000000 --- a/.local/bin/exiti3 +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -read -p "Exit i3 [Y]/n?" exit -[ "$exit" = "Y" ] && i3-msg exit - diff --git a/.local/bin/get-pkgs b/.local/bin/get-pkgs deleted file mode 100755 index 19e64f3..0000000 --- a/.local/bin/get-pkgs +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Creates files containing lists of installed and manually installed packages -# in cache directory - -pkgdir="$HOME/.cache/packages" -apt list --installed | tail -n+2 | cut -d '/' -f 1 > $pkgdir/installed -apt list --manual-installed | tail -n+2 | - cut -d '/' -f 1 > $pkgdir/manual-installed diff --git a/.local/bin/getmail b/.local/bin/getmail new file mode 100755 index 0000000..c36137e --- /dev/null +++ b/.local/bin/getmail @@ -0,0 +1,3 @@ +#!/bin/sh + +ping -c 1 9.9.9.9 >/dev/null && mbsync -a && notify-send "Mail Synced" diff --git a/.local/bin/getpass b/.local/bin/getpass index bfa344f..1f9b3b5 100755 --- a/.local/bin/getpass +++ b/.local/bin/getpass @@ -3,13 +3,12 @@ pb=$PASSWORD_STORE_DIR [ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME chars=$(echo $pb | wc -c) -accts=$(find $pb -type f -name "*.gpg" | cut -c 2- | \ - grep -v ".*-OTP.gpg\|.*-2farecovery.gpg" | cut -c $chars- | \ +accts=$(find $pb -type f -name "*.gpg" | cut -c 2- | cut -c $chars- | \ rev | cut -c 5- | rev) acct="$(echo "$accts" | dmenu)" [ "$acct" = "" ] && exit -pass show $acct | xclip -r -selection "primary" \ - && pass show $acct | xclip -r -selection "clipboard" \ +pass show $acct | head -1 | xclip -r -selection "primary" \ + && pass show $acct | head -1 | xclip -r -selection "clipboard" \ && notify-send "Password Copied to Clipboard" \ && sleep $ct \ && pkill xclip diff --git a/.local/bin/getpass-otp b/.local/bin/getpass-otp index 535cc31..19c0c0e 100755 --- a/.local/bin/getpass-otp +++ b/.local/bin/getpass-otp @@ -3,7 +3,7 @@ pb=$PASSWORD_STORE_DIR [ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME chars=$(echo $pb | wc -c) -accts=$(find $pb -type f -name "*-OTP.gpg" | cut -c $chars- | \ +accts=$(find $pb -type f -name "*.gpg" | cut -c $chars- | \ rev | cut -c 5- | rev) acct="$(echo "$accts" | dmenu)" pass otp code $acct | xclip -r -selection "primary" \ diff --git a/.local/bin/id-init b/.local/bin/id-init index 72f8cbe..0634fe4 100755 --- a/.local/bin/id-init +++ b/.local/bin/id-init @@ -2,7 +2,7 @@ tmpfile="$(mktemp)" chmod 700 $tmpfile -echo "pass ssh" > $tmpfile +echo "pass homelab/ssh" > $tmpfile export SSH_ASKPASS="$tmpfile" export SSH_ASKPASS_REQUIRE="force" ssh-add diff --git a/.local/bin/init-tv b/.local/bin/init-tv new file mode 100755 index 0000000..17e7111 --- /dev/null +++ b/.local/bin/init-tv @@ -0,0 +1,3 @@ +xrandr --output HDMI-A-1 --auto --right-of DisplayPort-0 --mode 3840x2160 +bgscript +#--set underscan on --set "underscan vborder" 60 --set "underscan hborder" 70 --right-of DisplayPort-0 --mode 1920x1080 diff --git a/.local/bin/kill-libvirtd b/.local/bin/kill-libvirtd deleted file mode 100755 index 2ea802d..0000000 --- a/.local/bin/kill-libvirtd +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Stop all running domains and networks, and then stop all libvirtd daemons - -# Save running domains -rundoms="$(virsh list | grep running | awk '{print $2}')" -for dom in $rundoms -do - virsh managedsave $dom -done - -# Stop network -virsh net-destroy default - -# Stop libvirtd -sudo systemctl stop libvirtd >/dev/null -sudo systemctl stop libvirtd-ro.socket >/dev/null -sudo systemctl stop libvirtd-admin.socket >/dev/null -sudo systemctl stop libvirtd.socket >/dev/null -sudo systemctl stop virtlogd >/dev/null -sudo systemctl stop virtlogd-admin.socket >/dev/null -sudo systemctl stop virtlogd.socket >/dev/null -sudo systemctl stop systemd-machined >/dev/null diff --git a/.local/bin/kill-steam b/.local/bin/kill-steam deleted file mode 100755 index 5572ae7..0000000 --- a/.local/bin/kill-steam +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -pkill -f steam diff --git a/.local/bin/lock b/.local/bin/lock deleted file mode 100755 index 223ac59..0000000 --- a/.local/bin/lock +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Locks the screen with a blurred screenshot of the current window as the lock image -# Also pauses any music that is playing - -maim | convert - -paint 5 ~/.cache/lock.png -[ "$(cmus-remote -Q | head -1 | cut -d ' ' -f 2)" != "playing" ] || cmus-remote --pause -i3lock -u -e -i ~/.cache/lock.png diff --git a/.local/bin/merge-renovate b/.local/bin/merge-renovate new file mode 100755 index 0000000..ce23161 --- /dev/null +++ b/.local/bin/merge-renovate @@ -0,0 +1,8 @@ +#!/bin/sh + +image="$1" +[ "$image" = "" ] && echo "error: no image specified" && exit 1 +git checkout -b renovate/$image master +git pull --no-edit origin renovate/$image +git checkout master +git merge --no-ff --no-edit renovate/$image diff --git a/.local/bin/mount-device b/.local/bin/mount-device new file mode 100755 index 0000000..6b644df --- /dev/null +++ b/.local/bin/mount-device @@ -0,0 +1,39 @@ +#!/bin/sh +# Script for mounting block devices + +# Set askpass program for authentication +#export SUDO_ASKPASS=/usr/bin/ssh-askpass + +# Check for and get device to mount from user +devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')" +[ "$devs" = "" ] && exit 0 +dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)" +[ "$dev" = "" ] && exit 1 + +# Open and map drive if it is encrypted +crypt=0 +[ "$(lsblk -no FSTYPE $dev)" = "crypto_LUKS" ] && crypt=1 && \ + mapname="$(echo -n "" | dmenu -i -p "Enter device mapper name")" && \ + sudo cryptsetup open $dev $mapname + +# Attempt to mount without mountpoint for devices in /etc/fstab +sudo mount "$dev" 2>/dev/null && exit 0 + +# Get mountpoint from user +mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" +[ "$mntpnt" = "" ] && exit 1 + +# If selected mountpoint does not exist ask to create it +# If user decides not to create non-existent drive, exit +[ ! -d $mntpnt ] && create="$(echo "No\nYes" | \ + dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ + ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) + +# Mount the device +if [ $crypt -eq 1 ]; then + sudo -A mount /dev/mapper/$mapname $mntpnt && pgrep -x dunst && \ + notify-send "$dev mounted to $mntpnt" +else + sudo -A mount $dev $mntpnt && pgrep -x dunst && \ + notify-send "$dev mounted to $mntpnt" +fi diff --git a/.local/bin/mount-media b/.local/bin/mount-media index e748941..f35e4af 100755 --- a/.local/bin/mount-media +++ b/.local/bin/mount-media @@ -1,6 +1,6 @@ #!/bin/sh # Uses sshfs to locally mount media directories # Check if the media computer is reachable and if so mount the media -ping -W 0.01 -c 1 prometheus >/dev/null && \ - sshfs sisko@prometheus:/mnt/raid/media/ $HOME/media/prometheus/ +ping -W 0.01 -c 1 docker >/dev/null && \ + sshfs docker:/srv/docker/arr/data/media $HOME/media diff --git a/.local/bin/start-vm b/.local/bin/start-vm deleted file mode 100755 index 5ffea03..0000000 --- a/.local/bin/start-vm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Starts libvirtd, default network, and optionally any domains given as arguments - -pgrep libvirtd >/dev/null || sudo systemctl start libvirtd -virsh net-start default -for domain in "$@" -do - virsh start $domain -done diff --git a/.local/bin/stop-alarm b/.local/bin/stop-alarm deleted file mode 100755 index 4607b11..0000000 --- a/.local/bin/stop-alarm +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -pkill mpv -amixer -q sset Master 50% -pkill -RTMIN+10 i3blocks diff --git a/.local/bin/stop-vm b/.local/bin/stop-vm deleted file mode 100755 index 6c92250..0000000 --- a/.local/bin/stop-vm +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Stops domains given as arguments - -opts=$(getopt -o 'as' -l 'all,save' -- "$@") -eval set -- "$opts" -all=0 -save=0 -while true -do - case $1 in - '-a'|'--all') all=1; shift; continue ;; - '-s'|'--save') save=1; shift; continue ;; - '--') shift; break;; - esac -done - -[ $all -eq 1 ] && domains="$(virsh list | grep running | awk '{print $2}')" || domains="$@" -for domain in $domains -do - [ $save -eq 1 ] && virsh managedsave $domain || virsh shutdown $domain -done diff --git a/.local/bin/sync-cryptusb b/.local/bin/sync-cryptusb new file mode 100755 index 0000000..46daef9 --- /dev/null +++ b/.local/bin/sync-cryptusb @@ -0,0 +1,8 @@ +#!/bin/sh +# Syncs important files to encrypted USB + +mount-device && \ +rsync -avP --delete-after --exclude="virtual_machines*" --exclude="media*" \ + --exclude="*.iso" --exclude="*.qcow2" --exclude="*.zip" --exclude="*.img"\ + $HOME/ /mnt/cryptusb/$USER@$(hostname)/ +unmount-device diff --git a/.local/bin/sync-music b/.local/bin/sync-music index 4619a23..3338c48 100755 --- a/.local/bin/sync-music +++ b/.local/bin/sync-music @@ -1,4 +1,5 @@ #!/bin/sh # Sync music from media computer to local computer -rsync -av sisko@prometheus:/mnt/raid/media/music/ $HOME/media/music/ +rsync -av samadmin@jellyfin:/mnt/media/music/beets $HOME/media/music/ +#rsync -av $HOME/media/music/ mobian@192.168.88.252:~/Music/ diff --git a/.local/bin/theme/get-gradient b/.local/bin/theme/get-gradient deleted file mode 100755 index 91f9391..0000000 --- a/.local/bin/theme/get-gradient +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Gets and sets a color gradient for cava - -start="$1" -end="$2" -colors=$(~/.local/bin/theme/gradient.py $start $end 7) - -num=1 -path="$HOME/.config/cava/config" -for color in $colors; do - sed -i "s/gradient_color_$num.*$/gradient_color_$num = '$color'/" $path - num=$((num+1)) -done diff --git a/.local/bin/theme/gradient.py b/.local/bin/theme/gradient.py deleted file mode 100755 index f95bb07..0000000 --- a/.local/bin/theme/gradient.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python3 -# Gets a color gradient based on input color and number -# Depends on python3-colour - -import colour,sys - -if len(sys.argv) != 4: - print("arg error") - sys.exit(1) - -start = sys.argv[1] -end = sys.argv[2] -num = int(sys.argv[3]) - -grad = colour.color_scale(colour.hex2hsl(start),colour.hex2hsl(end),num) -grad_hex = [] -for hsl in grad: - grad_hex.append(colour.hsl2hex(hsl)) - -for color in grad_hex: - sys.stdout.write(color + "\n") - - - diff --git a/.local/bin/unicode-select b/.local/bin/unicode-select new file mode 100755 index 0000000..b797691 --- /dev/null +++ b/.local/bin/unicode-select @@ -0,0 +1,9 @@ +#!/bin/sh +# Select unicode character via dmenu and copy to clipboard + +line="$(cat ~/.local/share/unicode_list | dmenu -i -l 10)" +grep "$line" ~/.local/share/unicode_list | tr -d [:print:] | + xclip -r -selection "clipboard" && + notify-send "$(xclip -selection "clipboard" -o) copied to clipboard" + + diff --git a/.local/bin/unmount-device b/.local/bin/unmount-device new file mode 100755 index 0000000..239663d --- /dev/null +++ b/.local/bin/unmount-device @@ -0,0 +1,28 @@ +#!/bin/sh +# Script for unmounting filesystems + +# Set askpass program for authentication +#export SUDO_ASKPASS=/usr/bin/ssh-askpass + +# Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...) +exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$" +parts="$(lsblk -lp | grep "\(part\|crypt\)\s*/" | grep -v "$exclude" | awk '{print $7,"-",$4}')" +[ "$parts" = "" ] && exit 0 + +# Get filesystem to unmount from user +crypt=0 +select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)" +[ "$select" = "" ] && exit 0 +dev="$(lsblk -lp | grep "$select" | awk '{print $1}')" +[ "$(lsblk -no TYPE $dev)" = "crypt" ] && crypt=1 + +# Unmount the filesystem +umount=0 +sudo umount $select && pgrep -x dunst && \ + notify-send "Unmounted $select ($dev)" && umount=1 \ + || notify-send "Error: unable to unmount $select" "Are you in it?" + +[ $crypt -eq 1 -a $umount -eq 1 ] && sudo cryptsetup close $dev && pgrep -x dunst && \ + notify-send "Unmapped $dev" && exit 14 + + diff --git a/.local/bin/who-depends b/.local/bin/who-depends deleted file mode 100755 index d1fb0c2..0000000 --- a/.local/bin/who-depends +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Script that takes a package as an argument and returns installed packages -# that are dependent on it - -[ $# -eq 1 ] || echo "usage: who-depends package" -apt list --installed | tail -n+2 | cut -d '/' -f 1 > /tmp/whodepends -pkg="$1" -deps_all=$(apt-cache rdepends $pkg | tail -n+3 | sed "s/^\s*//") -for dep in $deps_all -do - grep -lq "$dep" /tmp/whodepends && echo "$dep" -done diff --git a/.local/bin/yt-fix b/.local/bin/yt-fix index 69e771a..efb76ad 100755 --- a/.local/bin/yt-fix +++ b/.local/bin/yt-fix @@ -7,7 +7,7 @@ stdin() { do ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" ext_length=${#ext} - remove=$((12+$ext_length)) + remove=$((15+$ext_length)) filename="$(echo $infile | rev | cut -c $remove- | rev)" mv "$infile" "$filename$ext" done @@ -18,7 +18,7 @@ cli() { do ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" ext_length=${#ext} - remove=$((12+$ext_length)) + remove=$((15+$ext_length)) filename="$(echo $infile | rev | cut -c $remove- | rev)" mv "$infile" "$filename$ext" done @@ -39,4 +39,3 @@ do done [ $read_stdin -eq 0 ] && cli "$@" || stdin - -- cgit v1.2.3