diff options
Diffstat (limited to 'local/bin')
| -rwxr-xr-x | local/bin/backlight-ctl | 23 | ||||
| -rwxr-xr-x | local/bin/battery-low-check | 5 | ||||
| -rwxr-xr-x | local/bin/bitwarden-dmenu | 8 | ||||
| -rwxr-xr-x | local/bin/cacharle-sync | 28 | ||||
| -rwxr-xr-x | local/bin/music-dl | 34 | ||||
| -rw-r--r-- | local/bin/music-dl.conf | 9 | ||||
| -rwxr-xr-x | local/bin/newsboat-reload | 8 | ||||
| -rwxr-xr-x | local/bin/project-open | 53 | ||||
| -rwxr-xr-x | local/bin/repo-client | 3 | ||||
| -rwxr-xr-x | local/bin/tag-music | 32 | ||||
| -rwxr-xr-x | local/bin/touchpad-toggle | 12 |
11 files changed, 215 insertions, 0 deletions
diff --git a/local/bin/backlight-ctl b/local/bin/backlight-ctl new file mode 100755 index 0000000..2963d83 --- /dev/null +++ b/local/bin/backlight-ctl @@ -0,0 +1,23 @@ +#!/bin/sh + +[ "$#" -ne 1 ] && exit 1; + + +if [ "$(hostname)" = manjaro ] +then + cmd=light + up_opt=-A + down_opt=-U +else + cmd=xbacklight + up_opt=-inc + down_opt=-dec +fi + +case "$1" in + "up") "$cmd" "$up_opt" 5 ;; + "down") "$cmd" "$down_opt" 5 ;; + *) exit 1 ;; +esac + +notify-send "backlight $("$cmd" | cut -d '.' -f 1)" diff --git a/local/bin/battery-low-check b/local/bin/battery-low-check new file mode 100755 index 0000000..dbbdc6b --- /dev/null +++ b/local/bin/battery-low-check @@ -0,0 +1,5 @@ +#!/bin/sh + +capacity=$(cat /sys/class/power_supply/BAT0/capacity) + +[ "$capacity" -lt 10 ] && notify-send -u critical "Battery low $capacity%" diff --git a/local/bin/bitwarden-dmenu b/local/bin/bitwarden-dmenu new file mode 100755 index 0000000..68afe04 --- /dev/null +++ b/local/bin/bitwarden-dmenu @@ -0,0 +1,8 @@ +#!/bin/sh + +domain="$(echo | dmenu -p 'Enter domain name: ')" + +echo | dmenu -P -p 'Enter your master password: ' | + (bw get password "$domain" || + { notify-send -u critical 'Bad password'; exit 1; }) | + xclip -selection clipboard diff --git a/local/bin/cacharle-sync b/local/bin/cacharle-sync new file mode 100755 index 0000000..80f19bb --- /dev/null +++ b/local/bin/cacharle-sync @@ -0,0 +1,28 @@ +#!/bin/sh + +usage() { + echo "Usage: $0 push/pull [rsync args...]" +} + +[ -z "$1" ] && usage && exit 1 + +RSYNC_ARGS="$(echo "$*" | cut -d ' ' -f 2-)" +RSYNC_CMD="rsync -avh --progress --compress $RSYNC_ARGS" + +REMOTE_USER=charles +REMOTE_HOST=cacharle.xyz + +SYNC_DIR="cacharle-sync/" +SYNC_PATH="$HOME/$SYNC_DIR" + +case "$1" in + push) + $RSYNC_CMD "$SYNC_PATH" "$REMOTE_USER@$REMOTE_HOST:$SYNC_DIR" + ;; + pull) + $RSYNC_CMD "$REMOTE_USER@$REMOTE_HOST:$SYNC_DIR" "$SYNC_PATH" + ;; + *) + usage && exit 1 + ;; +esac diff --git a/local/bin/music-dl b/local/bin/music-dl new file mode 100755 index 0000000..a16cd97 --- /dev/null +++ b/local/bin/music-dl @@ -0,0 +1,34 @@ +#!/bin/sh + +conf_filename=music-dl.conf + +error() { + echo "Error: $1" + return 1 +} + +fatal() { + error "$1" + exit 1 +} + +[ ! -f "$conf_filename" ] && fatal "'$conf_filename' not found in current directory" + +conf_get() { + key="$1" + matches="$(sed -n 's/^'"$key"'=\(.*\)$/\1/ p' $conf_filename)" + if [ -z "$matches" ] + then + error "'$key' not found in '$conf_filename'" + return 1 + fi + echo "$matches" | tail -n 1 +} + +conf_get bonjour || echo pas bien +conf_get aurevoir + + +# ytdl='youtube-dl --output "%(title)s.%(ext)s"' +# ytdlp='youtube-dl --audio-format mp3 -i --output "%(playlist_index)s-%(title)s.%(ext)s"' +# ytdla='youtube-dl --audio-format mp3 -i -x -f bestaudio/best --output "%(playlist_index)s-%(title)s.%(ext)s"' diff --git a/local/bin/music-dl.conf b/local/bin/music-dl.conf new file mode 100644 index 0000000..e865370 --- /dev/null +++ b/local/bin/music-dl.conf @@ -0,0 +1,9 @@ +bonjour=foo +aurevoir=lala +auasdf + +asdf +asd +fa +sdf +asd diff --git a/local/bin/newsboat-reload b/local/bin/newsboat-reload new file mode 100755 index 0000000..82e26a7 --- /dev/null +++ b/local/bin/newsboat-reload @@ -0,0 +1,8 @@ +#!/bin/sh + +# adapted from: https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/cron/newsup + +ping -q -c 1 cacharle.xyz > /dev/null || exit # no internet +pgrep -f 'newsboat$' > /dev/null && exit # newsboat already running + +newsboat -x reload diff --git a/local/bin/project-open b/local/bin/project-open new file mode 100755 index 0000000..adb27a4 --- /dev/null +++ b/local/bin/project-open @@ -0,0 +1,53 @@ +#!/bin/sh + +# shellcheck disable=SC2088 +# (tile does not expand in single quote) +dest=$( + find ~/git -mindepth 1 -maxdepth 1 -printf '%A@\t%f\n' | + sort -r | + cut -f 2 | + dmenu -l 10 -p '~/git/' +) + +[ -z "$dest" ] && exit 1 + +dest_path="$HOME/git/$dest" + +if cd "$dest_path" 2> /dev/null +then + touch "$dest_path" + exec st +else + while [ -z "$choice" ] + do + choice=$(printf 'create\nclone\ncancel' | dmenu -p "New repository at ~/git/$dest?") + done + + case "$choice" in + "create") + mkdir -p "$dest_path" + cd "$dest_path" || exit 1 + git init + exec st + ;; + + "clone") + while [ -z "$remote_choice" ] + do + remote_choice=$(printf 'github.com\ncacharle.xyz\nclipboard\nother' | dmenu -p "Remote location") + done + case "$remote_choice" in + github.com) prefix='git@github.com:cacharle/' ;; + cacharle.xyz) prefix='git@cacharle.xyz:/srv/git/' ;; + clipboard) dest="$(xclip -selection clipboard -o)" ;; + other) ;; + esac + url="$prefix$(echo "$dest" | dmenu -p "Enter repository url: $prefix")" + st -e /bin/sh -c "git clone --recursive '$url' '$dest_path' && cd '$dest_path' && exec $SHELL" || + notify-send -u critical "Could not clone $url in $dest_path" && exit 1 + ;; + + "cancel") exit ;; + *) exit 1 ;; + esac +fi diff --git a/local/bin/repo-client b/local/bin/repo-client new file mode 100755 index 0000000..49049d8 --- /dev/null +++ b/local/bin/repo-client @@ -0,0 +1,3 @@ +#!/bin/sh + +ssh git@cacharle.xyz repo $* diff --git a/local/bin/tag-music b/local/bin/tag-music new file mode 100755 index 0000000..826a83a --- /dev/null +++ b/local/bin/tag-music @@ -0,0 +1,32 @@ +#!/bin/sh + +music_dir="$HOME/Music" + +for artist_dir in "$music_dir"/* +do + [ ! -d "$artist_dir" ] && continue + artist="$(basename "$artist_dir")" + [ "$artist" = backup ] && continue + + for album_dir in "$artist_dir"/* + do + album="$(basename "$album_dir")" + [ ! -d "$album_dir" ] && continue + + for song_file in "$album_dir"/* + do + [ ! -f "$song_file" ] && continue + song="$(basename "$song_file" | rev | cut -d '.' -f 2- | rev)" + # echo $song_file + track=0 + if expr "$song" : "[0-9][0-9]*\-.*" > /dev/null + then + track="$(echo "$song" | cut -d '-' -f 1)" + song="$(echo "$song" | cut -d '-' -f 2-)" + fi + # echo $track $song + # echo $song_file + taffy --artist "$artist" --album "$album" --title "$song" --track "$track" "$song_file" + done + done +done diff --git a/local/bin/touchpad-toggle b/local/bin/touchpad-toggle new file mode 100755 index 0000000..e4dc959 --- /dev/null +++ b/local/bin/touchpad-toggle @@ -0,0 +1,12 @@ +#!/bin/sh + +touchpad_name='ETPS/2 Elantech Touchpad' + +active="$(xinput list-props "$touchpad_name" | grep 'Device Enabled' | cut -f 3)" + +if [ "$active" -eq 1 ] +then + xinput disable "$touchpad_name" +else + xinput enable "$touchpad_name" +fi |
