summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/arkenfox-auto-update20
-rwxr-xr-x.local/bin/compiler6
-rwxr-xr-x.local/bin/dmenumount10
-rwxr-xr-x.local/bin/dmenurecord24
-rwxr-xr-x.local/bin/dmenuumount49
-rwxr-xr-x.local/bin/getbib2
-rwxr-xr-x.local/bin/linkhandler2
-rwxr-xr-x.local/bin/mounter93
-rwxr-xr-x.local/bin/sd23
-rwxr-xr-x.local/bin/statusbar/sb-doppler2
-rwxr-xr-x.local/bin/statusbar/sb-kbselect1
-rwxr-xr-x.local/bin/statusbar/sb-music2
-rwxr-xr-x.local/bin/statusbar/sb-volume11
-rwxr-xr-x.local/bin/unmounter28
14 files changed, 202 insertions, 71 deletions
diff --git a/.local/bin/arkenfox-auto-update b/.local/bin/arkenfox-auto-update
new file mode 100755
index 0000000..05f4ca7
--- /dev/null
+++ b/.local/bin/arkenfox-auto-update
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# A wrapper for the arkenfox-updater that runs it on all pre-existing Arkenfox
+# user.js files on the machine.
+
+# On installation of LARBS, this file is copied to /usr/local/lib/ where it is
+# run by a pacman hook set up. The user should not have to run this manually.
+
+# Search for all Firefox and Librewolf profiles using Arkenfox.
+profiles="$(grep -sH "arkenfox user.js" \
+ /home/*/.librewolf/*.default-release/user.js \
+ /home/*/.mozilla/firefox/*.default-release/user.js)"
+
+IFS='
+'
+
+# Update each found profile.
+for profile in $profiles; do
+ arkenfox-updater -p "${profile%%/user.js*}" -s
+done
diff --git a/.local/bin/compiler b/.local/bin/compiler
index 6e28cd0..8420e25 100755
--- a/.local/bin/compiler
+++ b/.local/bin/compiler
@@ -39,9 +39,9 @@ case "$ext" in
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then
- lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
+ lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then
- groffdown -i "$file" | groff > "$base.pdf"
+ groffdown -i "$file" | groff -T pdf > "$base".pdf
else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;;
@@ -51,7 +51,7 @@ case "$ext" in
py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;;
- sass) sassc -a "$file" "$base.css" ;;
+ sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;;
diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount
index abeb0ce..8cf4a6b 100755
--- a/.local/bin/dmenumount
+++ b/.local/bin/dmenumount
@@ -27,18 +27,18 @@ mountusb() { \
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
- esac
- notify-send "πŸ’» USB mounting" "$chosen mounted to $mp."
+ esac && notify-send "πŸ’» USB mounting" "$chosen mounted to $mp." ||
+ notify-send "πŸ’» Drive failed to mount." "Probably a permissions issue or drive is already mounted."
}
mountandroid() { \
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
- simple-mtpfs --device "$chosen" "$mp"
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
- simple-mtpfs --device "$chosen" "$mp"
- notify-send "πŸ€– Android Mounting" "Android device mounted to $mp."
+ simple-mtpfs --device "$chosen" "$mp" &&
+ notify-send "πŸ€– Android Mounting" "Android device mounted to $mp." ||
+ notify-send "πŸ€– Android failed mounting." "Probably a permissions issue or phone is already mounted."
}
asktype() { \
diff --git a/.local/bin/dmenurecord b/.local/bin/dmenurecord
index b83a7c5..990b7b3 100755
--- a/.local/bin/dmenurecord
+++ b/.local/bin/dmenurecord
@@ -9,6 +9,8 @@
#
# If there is already a running instance, user will be prompted to end it.
+getdim() { xrandr | sed -n "s/\s*\([0-9]\+x[0-9]\+\).*\*.*/\1/p" ;}
+
updateicon() { \
echo "$1" > /tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
@@ -16,26 +18,23 @@ updateicon() { \
killrecording() {
recpid="$(cat /tmp/recordingpid)"
- # kill with SIGTERM, allowing finishing touches.
kill -15 "$recpid"
rm -f /tmp/recordingpid
updateicon ""
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
- # even after SIGTERM, ffmpeg may still run, so SIGKILL it.
- sleep 3
- kill -9 "$recpid"
- exit
}
screencast() { \
ffmpeg -y \
-f x11grab \
- -framerate 60 \
- -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
+ -framerate 30 \
+ -s "$(getdim)" \
-i "$DISPLAY" \
- -f alsa -i default \
- -r 30 \
- -c:v h264 -crf 0 -preset ultrafast -c:a aac \
+ -r 24 \
+ -use_wallclock_as_timestamps 1 \
+ -f alsa -thread_queue_size 1024 -i default \
+ -c:v h264 \
+ -crf 0 -preset ultrafast -c:a aac \
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
echo $! > /tmp/recordingpid
updateicon "βΊοΈπŸŽ™οΈ"
@@ -43,7 +42,8 @@ screencast() { \
video() { ffmpeg \
-f x11grab \
- -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
+ -framerate 30 \
+ -s "$(getdim)" \
-i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
@@ -104,7 +104,7 @@ videoselected()
ffmpeg \
-f x11grab \
- -framerate 60 \
+ -framerate 30 \
-video_size "$W"x"$H" \
-i :0.0+"$X,$Y" \
-c:v libx264 -qp 0 -r 30 \
diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount
index 946d12c..656d1f1 100755
--- a/.local/bin/dmenuumount
+++ b/.local/bin/dmenuumount
@@ -4,41 +4,18 @@
# Provides you with mounted partitions, select one to unmount.
# Drives mounted at /, /boot and /home will not be options to unmount.
-unmountusb() {
- [ -z "$drives" ] && exit
- chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
- chosen="$(echo "$chosen" | awk '{print $1}')"
- [ -z "$chosen" ] && exit
- sudo -A umount "$chosen" && notify-send "πŸ’» USB unmounting" "$chosen unmounted."
- }
+drives="$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}'; awk '/simple-mtpfs/ { print "πŸ“±", $2; }' /etc/mtab)"
-unmountandroid() { \
- chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
- [ -z "$chosen" ] && exit
- sudo -A umount -l "$chosen" && notify-send "πŸ€– Android unmounting" "$chosen unmounted."
- }
+chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
-asktype() { \
- choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
- case "$choice" in
- USB) unmountusb ;;
- Android) unmountandroid ;;
- esac
- }
-
-drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}')
-
-if ! grep simple-mtpfs /etc/mtab; then
- [ -z "$drives" ] && echo "No drives to unmount." && exit
- echo "Unmountable USB drive detected."
- unmountusb
-else
- if [ -z "$drives" ]
- then
- echo "Unmountable Android device detected."
- unmountandroid
- else
- echo "Unmountable USB drive(s) and Android device(s) detected."
- asktype
- fi
-fi
+case "$chosen" in
+ πŸ“±*)
+ chosen="${chosen#πŸ“± }"
+ sudo -A umount -l "$chosen"
+ ;;
+ *)
+ chosen="${chosen% (*}"
+ sudo -A umount -l "$chosen"
+ ;;
+esac && notify-send "πŸ–₯️ Drive unmounted." "$chosen successfully unmounted." ||
+ notify-send "πŸ–₯️ Drive failed to unmount." "Possibly a permissions or I/O issue."
diff --git a/.local/bin/getbib b/.local/bin/getbib
index bedc256..121dd6e 100755
--- a/.local/bin/getbib
+++ b/.local/bin/getbib
@@ -4,7 +4,7 @@
if [ -f "$1" ]; then
# Try to get DOI from pdfinfo or pdftotext output.
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
- doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:\s*\S\+[[:alnum:]]" -m 1) ||
+ doi=$(pdftotext "$1" 2>/dev/null - | sed -n '/[dD][oO][iI]:/{s/.*[dD][oO][iI]:\s*\(\S\+[[:alnum:]]\).*/\1/p;q}') ||
exit 1
else
doi="$1"
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler
index cc971fc..f62b581 100755
--- a/.local/bin/linkhandler
+++ b/.local/bin/linkhandler
@@ -13,7 +13,7 @@ else
fi
case "$url" in
- *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
+ *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
*png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
diff --git a/.local/bin/mounter b/.local/bin/mounter
new file mode 100755
index 0000000..38da0df
--- /dev/null
+++ b/.local/bin/mounter
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+# Mounts Android Phones and USB drives (encrypted or not). This script will
+# replace the older `dmenumount` which had extra steps and couldn't handle
+# encrypted drives.
+# TODO: Remove already mounted Android phones from prompt.
+# TODO: Try mount first for drives if in fstab to avoid directory prompt?
+# TODO: Add some support for connecting iPhones (although they are annoying).
+
+set -e
+
+# Check for phones.
+phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/πŸ“±/")"
+# Check for drives.
+alldrives="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,fstype")"
+# Get all LUKS drives
+allluks="$(echo "$alldrives" | grep crypto_LUKS)" || true
+# Get a list of the LUKS drive UUIDs already decrypted.
+decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed "s|.*LUKS2-||;s|-.*||")"
+# Functioning for formatting drives correctly for dmenu:
+filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6}' ; }
+
+# Get only LUKS drives that are not decrypted.
+IFS='
+'
+unopenedluks="$(for drive in $allluks; do
+ uuid="${drive%% *}"
+ uuid="${uuid//-}" # This is a bashism.
+ for open in $decrypted; do
+ [ "$uuid" = "$open" ] && break 1
+ done && continue 1
+ echo "πŸ”’ $drive"
+done | filter)"
+
+# Get all normal, non-encrypted or decrypted partitions that are not mounted.
+normalparts="$(echo "$alldrives"| grep -v crypto_LUKS | grep 'part\|rom\|crypt' | sed "s/^/πŸ’Ύ /" | filter )"
+
+# Add all to one variable. If no mountable drives found, exit.
+alldrives="$(echo "$phones
+$unopenedluks
+$normalparts" | sed "/^$/d;s/ *$//")"
+test -n "$alldrives"
+
+# Feed all found drives to dmenu and get user choice.
+chosen="$(echo "$alldrives" | dmenu -p "Mount which drive?" -i)"
+
+# Function for prompting user for a mountpoint.
+getmount(){
+ mp="$(find /mnt /media /mount /home -maxdepth 1 -type d 2>/dev/null | dmenu -i -p "Mount this drive where?")"
+ test -n "$mp"
+ if [ ! -d "$mp" ]; then
+ mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?")
+ [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
+ fi
+}
+
+case "$chosen" in
+ πŸ’Ύ*)
+ chosen="${chosen%% *}"
+ chosen="${chosen:1}" # This is a bashism.
+ getmount
+ sudo mount "$chosen" "$mp"
+ notify-send "πŸ’ΎDrive Mounted." "$chosen mounted to $mp."
+ ;;
+
+ πŸ”’*)
+ chosen="${chosen%% *}"
+ chosen="${chosen:1}" # This is a bashism.
+ # Number the drive.
+ while true; do
+ [ -f "/dev/mapper/usb$num" ] || break
+ num="$(printf "%02d" "$((num +1))")"
+ done
+
+ # Decrypt in a terminal window
+ ${TERMINAL:-st} -n floatterm -g 60x1 -e sudo cryptsetup open "$chosen" "usb$num"
+ # Check if now decrypted.
+ test -b "/dev/mapper/usb$num"
+
+ getmount
+ sudo mount "/dev/mapper/usb$num" "$mp"
+ notify-send "πŸ”“Decrypted drive Mounted." "$chosen decrypted and mounted to $mp."
+ ;;
+
+ πŸ“±*)
+ getmount
+ echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter"
+ chosen="${chosen%%:*}"
+ chosen="${chosen:1}" # This is a bashism.
+ simple-mtpfs --device "$chosen" "$mp"
+ notify-send "πŸ€– Android Mounted." "Android device mounted to $mp."
+ ;;
+esac
diff --git a/.local/bin/sd b/.local/bin/sd
index 7e09bf6..a0ff84c 100755
--- a/.local/bin/sd
+++ b/.local/bin/sd
@@ -2,10 +2,21 @@
# Open a terminal window in the same directory as the currently active window.
-PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
-PID="$(pstree -lpA "$PID")"
-PID="${PID##*"${SHELL##*/}"(}"
-PID="${PID#*lf(}"
-PID="${PID%%)*}"
-cd "$(readlink /proc/"$PID"/cwd)" || return 1
+windowPID=$(xprop -id "$(xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
+PIDlist=$(pstree -lpATna "$windowPID" | sed -En 's/.*,([0-9]+).*/\1/p' | tac)
+for PID in $PIDlist; do
+ cmdline=$(ps -o args= -p "$PID")
+ process_group_leader=$(ps -o comm= -p "$(ps -o pgid= -p "$PID" | tr -d ' ')")
+ cwd=$(readlink /proc/"$PID"/cwd)
+ # zsh and lf won't be ignored even if it shows ~ or /
+ case "$cmdline" in
+ 'lf -server') continue ;;
+ "${SHELL##*/}"|'lf'|'lf '*) break ;;
+ esac
+ # git (and its sub-processes) will show the root of a repository instead of the actual cwd, so they're ignored
+ [ "$process_group_leader" = 'git' ] || [ ! -d "$cwd" ] && continue
+ # This is to ignore programs that show ~ or / instead of the actual working directory
+ [ "$cwd" != "$HOME" ] && [ "$cwd" != '/' ] && break
+done
+[ "$PWD" != "$cwd" ] && [ -d "$cwd" ] && { cd "$cwd" || exit 1; }
"$TERMINAL"
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
index 7573c98..f58b744 100755
--- a/.local/bin/statusbar/sb-doppler
+++ b/.local/bin/statusbar/sb-doppler
@@ -184,7 +184,7 @@ US: KVNX: Norman, OK
US: KVBX: Vandenberg Afb: Orcutt, CA
EU: Europe
EU: GB: Great Brittain
-EU: SCAN: Scandinavia
+EU: SCAN: Scandinavia. Norway, Sweden And Denmark
EU: ALPS: The Alps
EU: NL: The Netherlands
EU: DE: Germany
diff --git a/.local/bin/statusbar/sb-kbselect b/.local/bin/statusbar/sb-kbselect
index f0c923f..ab2140c 100755
--- a/.local/bin/statusbar/sb-kbselect
+++ b/.local/bin/statusbar/sb-kbselect
@@ -5,6 +5,7 @@ kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
case $BLOCK_BUTTON in
1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
+ [ -z "$kb_choice" ] && exit 0
kb="$(echo "$kb_choice" | awk '{print $3}')"
setxkbmap "$kb"
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";;
diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music
index 7ea7032..d164b4b 100755
--- a/.local/bin/statusbar/sb-music
+++ b/.local/bin/statusbar/sb-music
@@ -1,6 +1,6 @@
#!/bin/sh
-filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
+filter() { sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume
index d17ce66..acdf7a9 100755
--- a/.local/bin/statusbar/sb-volume
+++ b/.local/bin/statusbar/sb-volume
@@ -4,9 +4,9 @@
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e pulsemixer ;;
- 2) pamixer -t ;;
- 4) pamixer --allow-boost -i 1 ;;
- 5) pamixer --allow-boost -d 1 ;;
+ 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
+ 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
+ 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
3) notify-send "πŸ“’ Volume module" "\- Shows volume πŸ”Š, πŸ”‡ if muted.
- Middle click to mute.
- Scroll to change." ;;
@@ -19,14 +19,15 @@ vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
[ "$vol" != "${vol%\[MUTED\]}" ] && echo πŸ”‡ && exit
vol="${vol#Volume: }"
+
split() {
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
}
-vol="$(split "$vol" ".")"
-vol="${vol##0}"
+
+vol="$(printf "%.0f" "$(split "$vol" ".")")"
case 1 in
$((vol >= 70)) ) icon="πŸ”Š" ;;
diff --git a/.local/bin/unmounter b/.local/bin/unmounter
new file mode 100755
index 0000000..7f1dbf5
--- /dev/null
+++ b/.local/bin/unmounter
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Unmount USB drives or Android phones. Replaces the older `dmenuumount`. Fewer
+# prompt and also de-decrypts LUKS drives that are unmounted.
+
+set -e
+
+mounteddroids="$(grep simple-mtpfs /etc/mtab | awk '{print "πŸ“±" $2}')"
+lsblkoutput="$(lsblk -nrpo "name,type,size,mountpoint")"
+mounteddrives="$(echo "$lsblkoutput" | awk '($2=="part"||$2="crypt")&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "πŸ’Ύ%s (%s)\n",$4,$3}')"
+
+allunmountable="$(echo "$mounteddroids
+$mounteddrives" | sed "/^$/d;s/ *$//")"
+test -n "$allunmountable"
+
+chosen="$(echo "$allunmountable" | dmenu -i -p "Unmount which drive?")"
+chosen="${chosen%% *}"
+test -n "$chosen"
+
+sudo -A umount -l "/${chosen#*/}"
+notify-send "Device unmounted." "$chosen has been unmounted."
+
+# Close the chosen drive if decrypted.
+cryptid="$(echo "$lsblkoutput" | grep "/${chosen#*/}$")"
+cryptid="${cryptid%% *}"
+test -b /dev/mapper/"${cryptid##*/}"
+sudo -A cryptsetup close "$cryptid"
+notify-send "πŸ”’Device dencryption closed." "Drive is now securely locked again."