Add scripts collection

Add a couple of utility scripts.
This commit is contained in:
2020-06-24 16:56:47 +02:00
parent 31a4bc0768
commit e7427ba925
5 changed files with 110 additions and 0 deletions

View File

@@ -231,6 +231,9 @@ bindsym $mod+Shift+t [class="^TelegramDesktop$"] scratchpad show
bindsym --release Print exec gnome-screenshot -i bindsym --release Print exec gnome-screenshot -i
bindsym --release $mod+Print exec gnome-screenshot -a bindsym --release $mod+Print exec gnome-screenshot -a
# Zoom links in private browser
bindsym $mod+z exec ~/.local/bin/zoom-links
# keyboard layout (de layout without dead keys and switched ESC and CAPS_LOCK) # keyboard layout (de layout without dead keys and switched ESC and CAPS_LOCK)
exec setxkbmap own exec setxkbmap own

37
.local/bin/filterHistory Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
[ $# -eq 1 ] || { echo "Specify history file" >&2; exit 1; }
[ "$(stat -c '%a' "$1")" = "600" ] || { echo "File does not look like a history file" >&2; exit 1; }
declare -a COMMANDS
COMMANDS=('ls' \
'll' \
'l' \
':q' \
':Q' \
'exit' \
'cd' \
'cd ~' \
'cd .' \
'cd ..' \
'gs' \
'git status' \
'gd' \
'gpush' \
'git pull' \
'cmake .. && make' \
'exec zsh' \
'python3' \
'clear' \
)
printf '%s\n' "${COMMANDS[@]}" | column
echo "Are you a 100% sure you want to delete these commands from $1? (Type out yes)"
read yn
[ "$yn" = "yes" ] || exit 1
for c in "${COMMANDS[@]}"; do
c="$(echo "$c" | sed 's/\./\\./g; s/\//\\\//g')"
sed -Ei '/^: [0-9]+:[0-9]+;'"$c"'$/d' "$1"
echo "$c deleted"
done

34
.local/bin/raw2preview Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
errorAndExit () {
printf "\033[1;31m$1\033[0m" >&2
exit $2
}
extractRAW () {
if [ -r "$1" ]; then
if [ "$1" != "${1%CR2}" ] && [ ! -f "${1%CR2}JPG" ]; then
exiftool "$1" -PreviewImage -b > "${1%CR2}JPG"
echo "${1%CR2}JPG"
else
printf "\033[1;31mPreview for $1 exists already.\n\033[0m" >&2
fi
fi
}
if [ $# -ne 1 ] || [ ! -r "$1" ]; then
errorAndExit "Please specify one readable file.\n" 1
fi
if [ "$(file -b --mime-type "$1")" = "image/x-canon-cr2" ]; then
extractRAW "$1"
elif [ "$(head -n 1 "$1")" = "#Geeqie collection" ]; then
while read line; do
if echo "$line" | grep -qv "^#"; then
line="${line#\"}"
extractRAW "${line%\"}"
fi
done < "$1" # <"$(sed -r '/#/d;s/(^"|"$)//g' "$1")"
else
errorAndExit "Please specify either a CR2 or a geeqie collection\n" 1
fi

9
.local/bin/wifi-mute Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
## This runs as a crontab every 5minutes ('*/5 * * * * /usr/local/bin/wifi-mute')
if [[ "$(nmcli -t -f name con show --active)" =~ eduroam* ]]; then # iwgetid -r
# TODO: mute only speaker, not headphones
amixer set Master mute
fi

27
.local/bin/zoom-links Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
## Author: druckdev
## Created 2020-06-05
##
## A script that modifies Zoom links for the use in browsers, opens it then in a private chromium
## window and puts the password into the clipboard. If no argument is given the link is taken out
## of the clipboard.
## The reason behind the choice of Chromium is that my Firefox does weird things when used in
## scripts and that I wanted to run Zoom separately from my normal Firefox instances.
## (although this should be solvable by separate Firefox profiles.)
# Check if necessary commands exist
command -v chromium-browser >/dev/null 2>&1 || return 1
command -v xclip >/dev/null 2>&1 || return 1
# If no argument is given, set the clipboard as argument
set "$(xclip -selection c -o)"
# Check for right format
echo "$1" | grep -Eq "^https://tu-berlin.Zoom.us/(j|wc/join)/[0-9]*\?pwd=.+" || return 1
# Delete password part and convert /j/ to /wc/join/
link="$(echo "${1%pwd=*}" | sed 's_/j/_/wc/join/_')"
# Open link in private browser
chromium-browser --incognito --new-window "$link" >/dev/null 2>&1 &
# Put password in clipboard
echo -n "${1##*pwd=}" | xclip -selection c