aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
commit468a789dbc4b1928c035d8590895efc533520a27 (patch)
tree74cb056c37eaa50cd50491a7665608488ed4feb1 /local
parentf9883d2c3b3699d91e98feeffd7eece546f7c57e (diff)
downloaddotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.gz
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.bz2
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.zip
Updated file tree to match XDG base directory specification
Diffstat (limited to 'local')
-rwxr-xr-xlocal/bin/backlight-ctl23
-rwxr-xr-xlocal/bin/battery-low-check5
-rwxr-xr-xlocal/bin/bitwarden-dmenu8
-rwxr-xr-xlocal/bin/cacharle-sync28
-rwxr-xr-xlocal/bin/music-dl34
-rw-r--r--local/bin/music-dl.conf9
-rwxr-xr-xlocal/bin/newsboat-reload8
-rwxr-xr-xlocal/bin/project-open53
-rwxr-xr-xlocal/bin/repo-client3
-rwxr-xr-xlocal/bin/tag-music32
-rwxr-xr-xlocal/bin/touchpad-toggle12
-rw-r--r--local/share/applications/mutt.desktop4
-rw-r--r--local/share/applications/newsboat.desktop4
-rw-r--r--local/share/applications/sxiv.desktop4
-rw-r--r--local/share/applications/zathura.desktop4
-rw-r--r--local/share/mimeapps.list25
m---------local/share/mutt/solarized0
17 files changed, 256 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
diff --git a/local/share/applications/mutt.desktop b/local/share/applications/mutt.desktop
new file mode 100644
index 0000000..24d0a48
--- /dev/null
+++ b/local/share/applications/mutt.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Application
+Name=Mail client
+Exec=/usr/bin/mutt %u
diff --git a/local/share/applications/newsboat.desktop b/local/share/applications/newsboat.desktop
new file mode 100644
index 0000000..609bb5a
--- /dev/null
+++ b/local/share/applications/newsboat.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Application
+Name=RSS client
+Exec=/usr/bin/newsboat %u
diff --git a/local/share/applications/sxiv.desktop b/local/share/applications/sxiv.desktop
new file mode 100644
index 0000000..0db2053
--- /dev/null
+++ b/local/share/applications/sxiv.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Application
+Name=Image viewer
+Exec=/usr/local/bin/sxiv %u
diff --git a/local/share/applications/zathura.desktop b/local/share/applications/zathura.desktop
new file mode 100644
index 0000000..8c38677
--- /dev/null
+++ b/local/share/applications/zathura.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Application
+Name=PDF reader
+Exec=/usr/bin/zathura %u
diff --git a/local/share/mimeapps.list b/local/share/mimeapps.list
new file mode 100644
index 0000000..49a184b
--- /dev/null
+++ b/local/share/mimeapps.list
@@ -0,0 +1,25 @@
+[Default Applications]
+
+# from: https://git.lukesmith.xyz/dotfiles/file/.config/mimeapps.list
+
+# xdg-open will use these settings to determine how to open filetypes.
+# These .desktop entries can also be seen and changed in ~/.local/share/applications/
+
+# text/x-shellscript=text.desktop;
+# x-scheme-handler/magnet=torrent.desktop;
+# application/x-bittorrent=torrent.desktop;
+x-scheme-handler/mailto=mail.desktop;
+# text/plain=text.desktop;
+application/postscript=zathura.desktop;
+application/pdf=zathura.desktop;
+
+image/png=sxiv.desktop;
+image/jpeg=sxiv.desktop;
+image/gif=sxiv.desktop;
+image/svg+xml=sxiv.desktop;
+
+application/rss+xml=newsboat.desktop
+
+video/x-matroska=mpv.desktop
+# x-scheme-handler/lbry=lbry.desktop
+# inode/directory=file.desktop
diff --git a/local/share/mutt/solarized b/local/share/mutt/solarized
new file mode 160000
+Subproject 3b23c55eb43849975656dd89e3f35dacd2b93e6