summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/alarm17
-rwxr-xr-x.local/bin/backups/assimilate60
-rwxr-xr-x.local/bin/check-repos10
-rwxr-xr-x.local/bin/cmus/toggle-mode14
-rwxr-xr-x.local/bin/cmus/toggle-shuf7
-rwxr-xr-x.local/bin/create-cryptusb (renamed from .local/bin/cryptusb/create-cryptusb)2
-rwxr-xr-x.local/bin/cryptusb/sync-cryptusb8
-rwxr-xr-x.local/bin/exiti34
-rwxr-xr-x.local/bin/get-pkgs8
-rwxr-xr-x.local/bin/getmail3
-rwxr-xr-x.local/bin/getpass7
-rwxr-xr-x.local/bin/getpass-otp2
-rwxr-xr-x.local/bin/id-init2
-rwxr-xr-x.local/bin/init-tv3
-rwxr-xr-x.local/bin/kill-libvirtd22
-rwxr-xr-x.local/bin/kill-steam3
-rwxr-xr-x.local/bin/lock7
-rwxr-xr-x.local/bin/merge-renovate8
-rwxr-xr-x.local/bin/mount-device (renamed from .local/bin/dmenu/mount-device)2
-rwxr-xr-x.local/bin/mount-media4
-rwxr-xr-x.local/bin/start-vm9
-rwxr-xr-x.local/bin/stop-alarm5
-rwxr-xr-x.local/bin/stop-vm21
-rwxr-xr-x.local/bin/sync-cryptusb8
-rwxr-xr-x.local/bin/sync-music3
-rwxr-xr-x.local/bin/theme/get-gradient13
-rwxr-xr-x.local/bin/theme/gradient.py24
-rwxr-xr-x.local/bin/unicode-select (renamed from .local/bin/dmenu/unicode-select)0
-rwxr-xr-x.local/bin/unmount-device (renamed from .local/bin/dmenu/unmount-device)0
-rwxr-xr-x.local/bin/who-depends13
-rwxr-xr-x.local/bin/yt-fix5
31 files changed, 34 insertions, 260 deletions
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 @@
1#!/bin/sh
2
3[ $1 = "-h" -o $1 = "--help" ] && echo "usage: alarm time sound_file" && exit 0
4[ $# != 2 ] && echo "usage: alarm time sound_file" && exit 1
5
6echo "alarm set for $1"
7echo "$(basename "$2") is the alarm tone"
8
9while [ $(date +%H:%M) != "$1" ]
10do
11 sleep 1
12done
13
14amixer -q sset Master 100% unmute
15pkill -RTMIN+10 i3blocks
16mpv --loop=inf $2
17
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 @@
1#!/bin/sh
2# Full system backup with borg
3
4# Validate argument - should either be onsite or offsite to specify location
5ERRMSG="error: please specify either onsite or offsite"
6[ $# -ne 1 ] && echo $ERRMSG && exit 1
7[ "$1" != "onsite" -a "$1" != "offsite" ] && echo $ERRMSG && exit 1
8
9# Set variables
10LOCATION="$1"
11SUDO_OPTS="--preserve-env=BORG_PASSCOMMAND,PASSWORD_STORE_DIR"
12CREATE_OPTS="--warning --stats --show-rc --exclude-caches --one-file-system"
13LOG="$HOME/.config/borg/log"
14
15# Hack to get repository passphrase from pass
16# The passcommand will be invoked as root, so use sudo to run it as the user calling the script
17# who owns the password store. The environmental variable PASSWORD_STORE_DIR is passed through
18# SUDO_OPTS to the borg commands, and then passed to this command from the borg command
19# by the same means. This allows custom password store locations to work with this script.
20export BORG_PASSCOMMAND="sudo $SUDO_OPTS -u $USER pass Borg-Backup/$(hostname)-$LOCATION"
21
22# Create variables and function to monitor exit status
23WARNING=0
24ERROR=0
25check_rc() {
26 rc=$1
27 [ $1 -eq 1 ] && WARNING=1
28 [ $1 -eq 2 ] && ERROR=1
29}
30
31# Start backup
32echo -e "\n$LOCATION $(date)\n" >> $LOG
33notify-send "beginning $LOCATION backup"
34
35# Backup root partition
36sudo $SUDO_OPTS borg create $CREATE_OPTS \
37 --exclude '/dev/*' \
38 --exclude '/proc/*' \
39 --exclude '/sys/*' \
40 --exclude '/tmp/*' \
41 --exclude '/mnt/*' \
42 --exclude '/media/*' \
43 "/mnt/$LOCATION-backup/$(hostname)::root-{now:%Y-%m-%d}" / 2>>$LOG
44check_rc $?
45
46# Backup boot parition
47sudo $SUDO_OPTS borg create $CREATE_OPTS \
48 "/mnt/$LOCATION-backup/$(hostname)::boot-{now:%Y-%m-%d}" /boot 2>>$LOG
49check_rc $?
50
51# Send notifications based on return codes of archives
52
53[ $WARNING -eq 1 ] && notify-send "One or more archives produced a warning" \
54 "Please check the log at $LOG"
55
56[ $ERROR -eq 1 ] && notify-send -u critical \
57 "One or more archives produced an error and was unable to complete" \
58 "Please check the log at $LOG"
59
60[ $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 @@
1#!/bin/sh
2
3cd $HOME/repos
4for repo in $(ls)
5do
6 [ -d $repo/.git ] && echo $repo && \
7 echo "------------------------------------------------------" && \
8 git --git-dir=$repo/.git --work-tree=$repo status 2>/dev/null && \
9 echo "------------------------------------------------------"
10done
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 @@
1#!/bin/sh
2# Toggles the cmus aaa mode (all,album,artist)
3
4cmus-remote -C "toggle aaa_mode"
5mode=$(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3)
6artist=$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3-)
7album=$(cmus-remote -Q | grep "tag album" | cut -d ' ' -f 3-)
8
9[ "$mode" = "all" ] && dunstctl close-all && notify-send "Playing from full library" \
10 && exit
11[ "$mode" = "artist" ] && dunstctl close-all && notify-send "Playing by artist: $artist" \
12 && exit
13[ "$mode" = "album" ] && dunstctl close-all && notify-send "Playing from album: $album" \
14 && 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 @@
1#!/bin/sh
2# Toggle and report status of shuffle mode in cmus
3
4cmus-remote --shuffle
5status=$(cmus-remote -Q | grep shuffle | cut -d ' ' -f 3)
6dunstctl close-all
7[ "$status" = "true" ] && notify-send "Shuffle on" || notify-send "Shuffle off"
diff --git a/.local/bin/cryptusb/create-cryptusb b/.local/bin/create-cryptusb
index e0f49fe..77d232e 100755
--- a/.local/bin/cryptusb/create-cryptusb
+++ b/.local/bin/create-cryptusb
@@ -30,5 +30,3 @@ sudo mkfs.ext4 "/dev/mapper/$map_name"
30sudo cryptsetup close "$map_name" 30sudo cryptsetup close "$map_name"
31 31
32echo "done" 32echo "done"
33
34
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 @@
1#!/bin/sh
2# Syncs important files to encrypted USB
3
4mount-device && \
5rsync -avP --exclude="virtual_machines*" --exclude="media*" \
6 --exclude="*.iso" --exclude="*.qcow2" \
7 $HOME/ /mnt/cryptusb/$USER@$(hostname)/ && \
8unmount-device
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 @@
1#!/bin/sh
2read -p "Exit i3 [Y]/n?" exit
3[ "$exit" = "Y" ] && i3-msg exit
4
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 @@
1#!/bin/sh
2# Creates files containing lists of installed and manually installed packages
3# in cache directory
4
5pkgdir="$HOME/.cache/packages"
6apt list --installed | tail -n+2 | cut -d '/' -f 1 > $pkgdir/installed
7apt list --manual-installed | tail -n+2 |
8 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 @@
1#!/bin/sh
2
3ping -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 @@
3pb=$PASSWORD_STORE_DIR 3pb=$PASSWORD_STORE_DIR
4[ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME 4[ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME
5chars=$(echo $pb | wc -c) 5chars=$(echo $pb | wc -c)
6accts=$(find $pb -type f -name "*.gpg" | cut -c 2- | \ 6accts=$(find $pb -type f -name "*.gpg" | cut -c 2- | cut -c $chars- | \
7 grep -v ".*-OTP.gpg\|.*-2farecovery.gpg" | cut -c $chars- | \
8 rev | cut -c 5- | rev) 7 rev | cut -c 5- | rev)
9acct="$(echo "$accts" | dmenu)" 8acct="$(echo "$accts" | dmenu)"
10[ "$acct" = "" ] && exit 9[ "$acct" = "" ] && exit
11pass show $acct | xclip -r -selection "primary" \ 10pass show $acct | head -1 | xclip -r -selection "primary" \
12 && pass show $acct | xclip -r -selection "clipboard" \ 11 && pass show $acct | head -1 | xclip -r -selection "clipboard" \
13 && notify-send "Password Copied to Clipboard" \ 12 && notify-send "Password Copied to Clipboard" \
14 && sleep $ct \ 13 && sleep $ct \
15 && pkill xclip 14 && 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 @@
3pb=$PASSWORD_STORE_DIR 3pb=$PASSWORD_STORE_DIR
4[ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME 4[ -z "$PASSWORD_STORE_CLIP_TIME" ] && ct=45 || ct=$PASSWORD_STORE_CLIP_TIME
5chars=$(echo $pb | wc -c) 5chars=$(echo $pb | wc -c)
6accts=$(find $pb -type f -name "*-OTP.gpg" | cut -c $chars- | \ 6accts=$(find $pb -type f -name "*.gpg" | cut -c $chars- | \
7 rev | cut -c 5- | rev) 7 rev | cut -c 5- | rev)
8acct="$(echo "$accts" | dmenu)" 8acct="$(echo "$accts" | dmenu)"
9pass otp code $acct | xclip -r -selection "primary" \ 9pass 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 @@
2 2
3tmpfile="$(mktemp)" 3tmpfile="$(mktemp)"
4chmod 700 $tmpfile 4chmod 700 $tmpfile
5echo "pass ssh" > $tmpfile 5echo "pass homelab/ssh" > $tmpfile
6export SSH_ASKPASS="$tmpfile" 6export SSH_ASKPASS="$tmpfile"
7export SSH_ASKPASS_REQUIRE="force" 7export SSH_ASKPASS_REQUIRE="force"
8ssh-add 8ssh-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 @@
1xrandr --output HDMI-A-1 --auto --right-of DisplayPort-0 --mode 3840x2160
2bgscript
3#--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 @@
1#!/bin/sh
2# Stop all running domains and networks, and then stop all libvirtd daemons
3
4# Save running domains
5rundoms="$(virsh list | grep running | awk '{print $2}')"
6for dom in $rundoms
7do
8 virsh managedsave $dom
9done
10
11# Stop network
12virsh net-destroy default
13
14# Stop libvirtd
15sudo systemctl stop libvirtd >/dev/null
16sudo systemctl stop libvirtd-ro.socket >/dev/null
17sudo systemctl stop libvirtd-admin.socket >/dev/null
18sudo systemctl stop libvirtd.socket >/dev/null
19sudo systemctl stop virtlogd >/dev/null
20sudo systemctl stop virtlogd-admin.socket >/dev/null
21sudo systemctl stop virtlogd.socket >/dev/null
22sudo 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 @@
1#!/bin/sh
2
3pkill -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 @@
1#!/bin/sh
2# Locks the screen with a blurred screenshot of the current window as the lock image
3# Also pauses any music that is playing
4
5maim | convert - -paint 5 ~/.cache/lock.png
6[ "$(cmus-remote -Q | head -1 | cut -d ' ' -f 2)" != "playing" ] || cmus-remote --pause
7i3lock -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 @@
1#!/bin/sh
2
3image="$1"
4[ "$image" = "" ] && echo "error: no image specified" && exit 1
5git checkout -b renovate/$image master
6git pull --no-edit origin renovate/$image
7git checkout master
8git merge --no-ff --no-edit renovate/$image
diff --git a/.local/bin/dmenu/mount-device b/.local/bin/mount-device
index c2decd5..6b644df 100755
--- a/.local/bin/dmenu/mount-device
+++ b/.local/bin/mount-device
@@ -8,7 +8,7 @@
8devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')" 8devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')"
9[ "$devs" = "" ] && exit 0 9[ "$devs" = "" ] && exit 0
10dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)" 10dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)"
11[ "$dev" = "" ] && exit 0 11[ "$dev" = "" ] && exit 1
12 12
13# Open and map drive if it is encrypted 13# Open and map drive if it is encrypted
14crypt=0 14crypt=0
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 @@
1#!/bin/sh 1#!/bin/sh
2# Uses sshfs to locally mount media directories 2# Uses sshfs to locally mount media directories
3# Check if the media computer is reachable and if so mount the media 3# Check if the media computer is reachable and if so mount the media
4ping -W 0.01 -c 1 prometheus >/dev/null && \ 4ping -W 0.01 -c 1 docker >/dev/null && \
5 sshfs sisko@prometheus:/mnt/raid/media/ $HOME/media/prometheus/ 5 sshfs docker:/srv/docker/arr/data/media $HOME/media
6 6
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 @@
1#!/bin/sh
2# Starts libvirtd, default network, and optionally any domains given as arguments
3
4pgrep libvirtd >/dev/null || sudo systemctl start libvirtd
5virsh net-start default
6for domain in "$@"
7do
8 virsh start $domain
9done
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 @@
1#!/bin/sh
2
3pkill mpv
4amixer -q sset Master 50%
5pkill -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 @@
1#!/bin/sh
2# Stops domains given as arguments
3
4opts=$(getopt -o 'as' -l 'all,save' -- "$@")
5eval set -- "$opts"
6all=0
7save=0
8while true
9do
10 case $1 in
11 '-a'|'--all') all=1; shift; continue ;;
12 '-s'|'--save') save=1; shift; continue ;;
13 '--') shift; break;;
14 esac
15done
16
17[ $all -eq 1 ] && domains="$(virsh list | grep running | awk '{print $2}')" || domains="$@"
18for domain in $domains
19do
20 [ $save -eq 1 ] && virsh managedsave $domain || virsh shutdown $domain
21done
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 @@
1#!/bin/sh
2# Syncs important files to encrypted USB
3
4mount-device && \
5rsync -avP --delete-after --exclude="virtual_machines*" --exclude="media*" \
6 --exclude="*.iso" --exclude="*.qcow2" --exclude="*.zip" --exclude="*.img"\
7 $HOME/ /mnt/cryptusb/$USER@$(hostname)/
8unmount-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 @@
1#!/bin/sh 1#!/bin/sh
2# Sync music from media computer to local computer 2# Sync music from media computer to local computer
3 3
4rsync -av sisko@prometheus:/mnt/raid/media/music/ $HOME/media/music/ 4rsync -av samadmin@jellyfin:/mnt/media/music/beets $HOME/media/music/
5#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 @@
1#!/bin/sh
2# Gets and sets a color gradient for cava
3
4start="$1"
5end="$2"
6colors=$(~/.local/bin/theme/gradient.py $start $end 7)
7
8num=1
9path="$HOME/.config/cava/config"
10for color in $colors; do
11 sed -i "s/gradient_color_$num.*$/gradient_color_$num = '$color'/" $path
12 num=$((num+1))
13done
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 @@
1#!/usr/bin/python3
2# Gets a color gradient based on input color and number
3# Depends on python3-colour
4
5import colour,sys
6
7if len(sys.argv) != 4:
8 print("arg error")
9 sys.exit(1)
10
11start = sys.argv[1]
12end = sys.argv[2]
13num = int(sys.argv[3])
14
15grad = colour.color_scale(colour.hex2hsl(start),colour.hex2hsl(end),num)
16grad_hex = []
17for hsl in grad:
18 grad_hex.append(colour.hsl2hex(hsl))
19
20for color in grad_hex:
21 sys.stdout.write(color + "\n")
22
23
24
diff --git a/.local/bin/dmenu/unicode-select b/.local/bin/unicode-select
index b797691..b797691 100755
--- a/.local/bin/dmenu/unicode-select
+++ b/.local/bin/unicode-select
diff --git a/.local/bin/dmenu/unmount-device b/.local/bin/unmount-device
index 239663d..239663d 100755
--- a/.local/bin/dmenu/unmount-device
+++ b/.local/bin/unmount-device
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 @@
1#!/bin/sh
2
3# Script that takes a package as an argument and returns installed packages
4# that are dependent on it
5
6[ $# -eq 1 ] || echo "usage: who-depends package"
7apt list --installed | tail -n+2 | cut -d '/' -f 1 > /tmp/whodepends
8pkg="$1"
9deps_all=$(apt-cache rdepends $pkg | tail -n+3 | sed "s/^\s*//")
10for dep in $deps_all
11do
12 grep -lq "$dep" /tmp/whodepends && echo "$dep"
13done
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() {
7 do 7 do
8 ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" 8 ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)"
9 ext_length=${#ext} 9 ext_length=${#ext}
10 remove=$((12+$ext_length)) 10 remove=$((15+$ext_length))
11 filename="$(echo $infile | rev | cut -c $remove- | rev)" 11 filename="$(echo $infile | rev | cut -c $remove- | rev)"
12 mv "$infile" "$filename$ext" 12 mv "$infile" "$filename$ext"
13 done 13 done
@@ -18,7 +18,7 @@ cli() {
18 do 18 do
19 ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" 19 ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)"
20 ext_length=${#ext} 20 ext_length=${#ext}
21 remove=$((12+$ext_length)) 21 remove=$((15+$ext_length))
22 filename="$(echo $infile | rev | cut -c $remove- | rev)" 22 filename="$(echo $infile | rev | cut -c $remove- | rev)"
23 mv "$infile" "$filename$ext" 23 mv "$infile" "$filename$ext"
24 done 24 done
@@ -39,4 +39,3 @@ do
39done 39done
40 40
41[ $read_stdin -eq 0 ] && cli "$@" || stdin 41[ $read_stdin -eq 0 ] && cli "$@" || stdin
42