summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/backup33
-rwxr-xr-x.local/bin/development/dev22
-rwxr-xr-x.local/bin/development/github-repo-size3
-rwxr-xr-x.local/bin/development/gitpush26
-rwxr-xr-x.local/bin/open2
-rwxr-xr-x.local/bin/preview4
-rwxr-xr-x.local/bin/setbg57
-rwxr-xr-x.local/bin/shorts/ec5
-rwxr-xr-x.local/bin/shorts/qr4
-rwxr-xr-x.local/bin/shorts/refcitx5
-rwxr-xr-x.local/bin/shorts/sync-server12
-rwxr-xr-x.local/bin/shorts/syncdrive3
-rwxr-xr-x.local/bin/shorts/synchs7
-rwxr-xr-x.local/bin/shorts/synctab19
-rwxr-xr-x.local/bin/shorts/syslogcat3
-rwxr-xr-x.local/bin/shorts/xprint4
-rwxr-xr-x.local/bin/svlogtail55
17 files changed, 147 insertions, 117 deletions
diff --git a/.local/bin/backup b/.local/bin/backup
deleted file mode 100755
index 8f6e00d..0000000
--- a/.local/bin/backup
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-sudo cryptsetup open /dev/sdb1 backup
-sudo mount --mkdir /dev/mapper/backup /mnt/backup
-backup="/mnt/backup/$(hostname)"
-[ -d "$backup" ] ||
- { echo "$0: directory doesn't exist: $backup" >&2; exit 1; }
-
-cd ~ || exit
-rsync -Plru --delete \
- .config \
- .git \
- .gnupg \
- .local \
- .librewolf \
- .ssh \
- bin \
- DCIM \
- Dev \
- Documents \
- Downloads \
- GDrive \
- Music \
- Phone \
- Pictures \
- repos \
- Videos \
- "$backup/home/$USER/"
-
-find . -maxdepth 1 \( -type f -o -type l \) -exec rsync -Plu {} "$backup/home/$USER" \;
-
-echo "Backing up /etc directory..."
-sudo rsync -Plruq --delete /etc "$backup"
diff --git a/.local/bin/development/dev b/.local/bin/development/dev
index 76f1772..bcb5b46 100755
--- a/.local/bin/development/dev
+++ b/.local/bin/development/dev
@@ -33,6 +33,7 @@ md_test() { pandoc -t pdf "$file" | zathura -; }
tex_compile() { pdflatex -output-directory="$(dirname "$file")" "$file"; }
tex_clean() { find "$(dirname "${1}")" -regex \
'.*\(_minted.*\|.*\.\(4tc\|xref\|tmp\|pyc\|pyg\|pyo\|fls\|vrb\|fdb_latexmk\|bak\|swp\|aux\|log\|synctex\(busy\)\|lof\|lot\|maf\|idx\|mtc\|mtc0\|nav\|out\|snm\|toc\|bcf\|run\.xml\|synctex\.gz\|blg\|bbl\)\)' -delete; }
+cls_compile() { file="${file%.cls}.tex"; tex_compile "$@"; }
html_format() { tidy -q "$file" 2>/dev/null; }
html_lint() { tidy -q "$file" >/dev/null; }
html_run() { w3m "$file"; }
@@ -138,6 +139,7 @@ case $filetype in
text/x-shellscript) filetype_ext="sh" ;;
text/html) filetype_ext="html" ;;
application/javascript) filetype_ext="js" ;;
+ application/json) filetype_ext="json" ;;
text/x-php) filetype_ext="php" ;;
text/x-awk) filetype_ext="awk" ;;
esac
@@ -150,17 +152,15 @@ else
fi
execute_task() {
- [ "$NO_BASENAME" != 1 ] && {
- file_task="${file_ext}_${action}"
- [ "${tasks#*"[$file_task]"}" != "$tasks" ] &&
- { $file_task; local ret=$?; local tasked=1; }
- }
- [ "$tasked" != 1 ] && {
- filetype_task="${filetype_ext}_${action}"
- [ "${tasks#*"[$filetype_task]"}" != "$tasks" ] &&
- { $filetype_task; local ret=$?; local tasked=1; }
- }
- [ "$tasked" != 1 ] && return 1
+ file_task="${file_ext}_${action}"
+ filetype_task="${filetype_ext}_${action}"
+ if [ "$NO_BASENAME" != 1 ] && [ "${tasks#*"[$file_task]"}" != "$tasks" ]; then
+ $file_task; ret=$?
+ elif [ "${tasks#*"[$filetype_task]"}" != "$tasks" ]; then
+ $filetype_task; ret=$?
+ else
+ return 1
+ fi
[ "$ret" != 0 ] && printf "\nshell returned %s\n" "$ret" >&2
return 0
}
diff --git a/.local/bin/development/github-repo-size b/.local/bin/development/github-repo-size
new file mode 100755
index 0000000..0cedd88
--- /dev/null
+++ b/.local/bin/development/github-repo-size
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "$1" | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -i curl -s -k https://api.github.com/repos/'{}' | grep size
diff --git a/.local/bin/development/gitpush b/.local/bin/development/gitpush
index 97aa43b..0af8e20 100755
--- a/.local/bin/development/gitpush
+++ b/.local/bin/development/gitpush
@@ -1,10 +1,20 @@
#!/bin/sh
-case "$(git config --get remote.origin.url)" in
- *csstudent41*) sshadd ~/.ssh/github.com_id_ed25519 ;;
- *labstudent41*) sshadd ~/.ssh/labstudent41_id_ed25519 ;;
-esac
-
-git add --all
-git commit # --allow-empty-message
-git push -u origin
+push_to_remote() {
+ case "$(git config --get remote.origin.url)" in
+ *csstudent41*) sshadd ~/.ssh/github.com_id_ed25519 ;;
+ *labstudent41*) sshadd ~/.ssh/labstudent41_id_ed25519 ;;
+ *vtc-tech*) sshadd ~/.ssh/vartaktechclub_id_ed25519 ;;
+ esac
+
+ git add --all
+ git commit
+ git push -u origin
+}
+
+[ -z "$1" ] && { push_to_remote; exit; }
+
+for dir in "$@"; do
+ cd "$dir" || exit 1
+ push_to_remote
+done
diff --git a/.local/bin/open b/.local/bin/open
index a996105..9b83265 100755
--- a/.local/bin/open
+++ b/.local/bin/open
@@ -11,7 +11,7 @@ for file in "$@"; do
*.html) ${BROWSER:-w3m} "$file" ;;
*.pl.txt) fpl "$file" ;;
*.txt|*.description) ${PAGER:-less} "$file" ;;
- *.md) glow --pager "$file" ;;
+ *.md) glow --pager --width $(("$(tput cols)" - 5)) "$file" ;;
*.css|*.json|*.ipynb|*.vim|*.lua|*.iso|*.zip) LESSOPEN="|preview %s" less -r "$file" ;;
*.srt) fzf-subtitles -o "$file" ;;
*.dig) setsid -f digital "$file" ;;
diff --git a/.local/bin/preview b/.local/bin/preview
index f0cedb0..2968843 100755
--- a/.local/bin/preview
+++ b/.local/bin/preview
@@ -23,9 +23,9 @@ case "$1" in
*.png|*.jpg|*.jpeg|*.webp|*.mp3|*.ogg|*.mp4|*.mkv|*.webm) mediainfo -- "$1" ;;
*.info.json) jq -C . "$1" ;;
*.json|*.ipynb) highlight --syntax=json -- "$1" ;;
- *.tgz|*.tar.gz) tar tzf "$1" ;;
+ *.tar.gz|*.tgz) tar tzf "$1" ;;
*.tar.bz2|*.tbz2) tar tjf "$1" ;;
- *.tar.txz|*.txz) xz --list "$1" ;;
+ *.tar.xz|*.txz) tar tJf "$1" ;;
*.tar) tar tf "$1" ;;
*.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$1" ;;
*.rar) unrar l "$1" ;;
diff --git a/.local/bin/setbg b/.local/bin/setbg
index b636a37..c288895 100755
--- a/.local/bin/setbg
+++ b/.local/bin/setbg
@@ -1,18 +1,41 @@
---2024-10-23 16:26:25-- https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/setbg
-Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
-Resolving github.com (github.com)... 20.207.73.82
-Connecting to github.com (github.com)|20.207.73.82|:443... connected.
-HTTP request sent, awaiting response... 200 OK
-Length: unspecified [text/html]
-Saving to: ‘setbg’
-
- 0K .......... .......... .......... .......... .......... 3.47M
- 50K .......... .......... .......... .......... .......... 9.00M
- 100K .......... .......... .......... .......... .......... 10.7M
- 150K .......... .......... .......... .......... .......... 10.7M
- 200K .......... .......... .......... .......... .......... 10.9M
- 250K .......... .......... .......... .......... .......... 11.2M
- 300K .......... .......... .......... ....... 10.8M=0.04s
-
-2024-10-23 16:26:25 (8.07 MB/s) - ‘setbg’ saved [345695]
+#!/bin/sh
+# This script does the following:
+# Run by itself, set the wallpaper (at X start).
+# If given a file, set that as the new wallpaper.
+# If given a directory, choose random file in it.
+# If wal is installed, also generates a colorscheme.
+
+# Location of link to wallpaper link.
+bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/bg"
+
+# Configuration files of applications that have their themes changed by pywal.
+dunstconf="${XDG_CONFIG_HOME:-$HOME/.config}/dunst/dunstrc"
+zathuraconf="${XDG_CONFIG_HOME:-$HOME/.config}/zathura/zathurarc"
+
+# Give -s as parameter to make notifications silent.
+while getopts "s" o; do case "${o}" in
+ s) silent='1' ;;
+esac done
+
+shift $((OPTIND - 1))
+
+trueloc="$(readlink -f "$1")" &&
+case "$(file --mime-type -b "$trueloc")" in
+ image/* ) ln -sf "$trueloc" "$bgloc" && [ -z "$silent" ] && notify-send -i "$bgloc" "Changing wallpaper..." ;;
+ inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && [ -z "$silent" ] && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
+ *) [ -z "$silent" ] && notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;;
+esac
+
+# If pywal is installed, use it.
+if command -v wal >/dev/null 2>&1 ; then
+ wal -n -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
+# If pywal is removed, return config files to normal.
+else
+ [ -f "$dunstconf.bak" ] && unlink "$dunstconf" && mv "$dunstconf.bak" "$dunstconf"
+ [ -f "$zathuraconf.bak" ] && unlink "$zathuraconf" && mv "$zathuraconf.bak" "$zathuraconf"
+fi
+
+xwallpaper --zoom "$bgloc"
+# If running, dwm hit the key to refresh the color scheme.
+pidof dwm >/dev/null && xdotool key super+F5
diff --git a/.local/bin/shorts/ec b/.local/bin/shorts/ec
new file mode 100755
index 0000000..bc6e7d5
--- /dev/null
+++ b/.local/bin/shorts/ec
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# edit-clipboard: edit the content of clipboard
+
+xclip -sel clip -o >/tmp/clipboard && nvim /tmp/clipboard && xclip -sel clip -i /tmp/clipboard
diff --git a/.local/bin/shorts/qr b/.local/bin/shorts/qr
new file mode 100755
index 0000000..4203e71
--- /dev/null
+++ b/.local/bin/shorts/qr
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+qrencode "$@" -o /tmp/qr.png
+${OPENER:-xdg-open} /tmp/qr.png
diff --git a/.local/bin/shorts/refcitx b/.local/bin/shorts/refcitx
index 668952c..1d104bf 100755
--- a/.local/bin/shorts/refcitx
+++ b/.local/bin/shorts/refcitx
@@ -1,7 +1,8 @@
#!/bin/sh
-notify-send "Starting Fcitx..."
+id="$(notify-send --print-id "Starting Fcitx...")"
fcitx
sleep 1
remap
-notify-send "Fcitx Started"
+fcitx-remote -t
+notify-send --replace-id="$id" "✅ Fcitx Started"
diff --git a/.local/bin/shorts/sync-server b/.local/bin/shorts/sync-server
deleted file mode 100755
index 641db9c..0000000
--- a/.local/bin/shorts/sync-server
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-sshadd "$HOME/.ssh/${1}_id_ed25519"
-sync() { rsync -PRru --delete --exclude "*.git" "$@"; }
-
-sync \
- "${XDG_CONFIG_HOME:-$HOME/.config}/./vim/vimrc" \
- "${XDG_CONFIG_HOME:-$HOME/.config}/./tmux/tmux.conf" \
- "${XDG_CONFIG_HOME:-$HOME/.config}/./shell/aliasrc" \
- "${XDG_CONFIG_HOME:-$HOME/.config}/./shell/inputrc" \
- "${XDG_CONFIG_HOME:-$HOME/.config}/./shell/server.profile" \
- "${1}:.config"
diff --git a/.local/bin/shorts/syncdrive b/.local/bin/shorts/syncdrive
deleted file mode 100755
index 3d010cc..0000000
--- a/.local/bin/shorts/syncdrive
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-rclone -v sync --delete-excluded --exclude=".git/**" ~/GDrive gdrive:
diff --git a/.local/bin/shorts/synchs b/.local/bin/shorts/synchs
deleted file mode 100755
index 244dd48..0000000
--- a/.local/bin/shorts/synchs
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-sync-server rpi
-
-# rsync -u ~/.config/lf/lfrc /tmp/lfrc
-# sed -i '/set icons/d' /tmp/lfrc
-# rsync -Pu /tmp/lfrc rpi:.config/lf/
diff --git a/.local/bin/shorts/synctab b/.local/bin/shorts/synctab
deleted file mode 100755
index 1e44419..0000000
--- a/.local/bin/shorts/synctab
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-sshadd ~/.ssh/tab_id_ed25519
-sync() { rsync -Pru --delete --exclude "*.git" "$@"; }
-
-sync ~/GDrive/ tab:GDrive/
-sync "${XDG_VIDEOS_DIR:-$HOME/Videos}" tab:Videos/
-
-sync -R \
- "${XDG_DOCUMENTS_DIR:-$HOME/Documents}/./allreader" \
- "${XDG_DOCUMENTS_DIR:-$HOME/Documents}/./latex" \
- "${XDG_DOCUMENTS_DIR:-$HOME/Documents}/./Notes/bookmarks.txt" \
- tab:Documents/
-
-sync \
- "${XDG_MUSIC_DIR:-$HOME/Music}/Piano" \
- "${XDG_MUSIC_DIR:-$HOME/Music}/Devotional" \
- tab:Music/
-
diff --git a/.local/bin/shorts/syslogcat b/.local/bin/shorts/syslogcat
new file mode 100755
index 0000000..c9763c7
--- /dev/null
+++ b/.local/bin/shorts/syslogcat
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+awk '{ printf "%s: %s\n", FILENAME, $0 }' /var/log/*/current | sort -k2 | less +G -X
diff --git a/.local/bin/shorts/xprint b/.local/bin/shorts/xprint
index 12156f2..74fc666 100755
--- a/.local/bin/shorts/xprint
+++ b/.local/bin/shorts/xprint
@@ -2,7 +2,7 @@
[ -n "$TERMUX_VERSION" ] && { termux-clipboard-get; exit; }
-xclip -out -selection clipboard 2>/dev/null ||
-xclip -out -selection secondry 2>/dev/null ||
xclip -out -selection primary 2>/dev/null ||
+xclip -out -selection secondry 2>/dev/null ||
+xclip -out -selection clipboard 2>/dev/null ||
notify-send "Selection and clipboard is empty"
diff --git a/.local/bin/svlogtail b/.local/bin/svlogtail
new file mode 100755
index 0000000..1dda671
--- /dev/null
+++ b/.local/bin/svlogtail
@@ -0,0 +1,55 @@
+#!/bin/sh
+# From socklog-void
+# https://github.com/void-linux/socklog-void/blob/master/svlogtail
+
+usage () {
+ cat <<-'EOF'
+ svlogtail [-f] [LOG...] - show svlogd logs conveniently
+
+ Without arguments, show current logs of all services, uniquely.
+ With arguments, show all logs of mentioned services
+
+ With -f, follow log output.
+ EOF
+}
+
+globexist() {
+ [ -f "$1" ]
+}
+
+IFS='
+'
+
+fflag=false
+if [ "$1" = -f ]; then
+ shift
+ fflag=true
+fi
+
+if [ $# = 0 ]; then
+ cat /var/log/socklog/*/current | sort -u
+ if $fflag; then
+ tail -Fq -n0 /var/log/socklog/*/current | uniq
+ fi
+else
+ old=
+ cur=
+ for log; do
+ case "$log" in
+ -*) usage; exit 1;;
+ esac
+ if [ -d /var/log/socklog/$log ]; then
+ if globexist /var/log/socklog/$log/*.[us]; then
+ old="$old$IFS/var/log/socklog/$log/*.[us]"
+ fi
+ cur="$cur$IFS/var/log/socklog/$log/current"
+ else
+ echo "no logs for $log" 1>&2
+ exit 1
+ fi
+ done
+ cat $old $cur | sort
+ if $fflag; then
+ tail -Fq -n0 $cur
+ fi
+fi