mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
Added some useful scripts from Luke Smith - https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin
This commit is contained in:
parent
519493f324
commit
1048bb7f40
59
.local/bin/compiler
Executable file
59
.local/bin/compiler
Executable file
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script will compile or run another finishing operation on a document. I
|
||||||
|
# have this script run via vim.
|
||||||
|
#
|
||||||
|
# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
|
||||||
|
# presentations. Runs scripts based on extension or shebang.
|
||||||
|
#
|
||||||
|
# Note that .tex files which you wish to compile with XeLaTeX should have the
|
||||||
|
# string "xelatex" somewhere in a comment/command in the first 5 lines.
|
||||||
|
|
||||||
|
file=$(readlink -f "$1")
|
||||||
|
dir=${file%/*}
|
||||||
|
base="${file%.*}"
|
||||||
|
ext="${file##*.}"
|
||||||
|
|
||||||
|
cd "$dir" || exit 1
|
||||||
|
|
||||||
|
textype() {
|
||||||
|
textarget="$(getcomproot "$file" || echo "$file")"
|
||||||
|
echo "$textarget"
|
||||||
|
command="pdflatex"
|
||||||
|
(head -n5 "$textarget" | grep -qi 'xelatex') && command="xelatex"
|
||||||
|
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||||
|
grep -qi addbibresource "$textarget" &&
|
||||||
|
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
|
||||||
|
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
||||||
|
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$ext" in
|
||||||
|
# Try to keep these cases in alphabetical order.
|
||||||
|
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf >"$base".pdf ;;
|
||||||
|
c) cc "$file" -o "$base" && "$base" ;;
|
||||||
|
cpp) g++ "$file" -o "$base" && "$base" ;;
|
||||||
|
cs) mcs "$file" && mono "$base".exe ;;
|
||||||
|
go) go run "$file" ;;
|
||||||
|
h) sudo make install ;;
|
||||||
|
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 -T pdf >"$base".pdf
|
||||||
|
elif [ -x "$(command -v groffdown)" ]; then
|
||||||
|
groffdown -i "$file" | groff -T pdf >"$base".pdf
|
||||||
|
else
|
||||||
|
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
|
||||||
|
fi ;;
|
||||||
|
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf >"$base".pdf ;;
|
||||||
|
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf >"$base".pdf ;;
|
||||||
|
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
|
||||||
|
py) python "$file" ;;
|
||||||
|
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
|
||||||
|
rs) cargo build ;;
|
||||||
|
sass) sassc -a "$file" "$base".css ;;
|
||||||
|
scad) openscad -o "$base".stl "$file" ;;
|
||||||
|
sent) setsid -f sent "$file" 2>/dev/null ;;
|
||||||
|
tex) textype "$file" ;;
|
||||||
|
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
|
||||||
|
esac
|
||||||
12
.local/bin/getcomproot
Executable file
12
.local/bin/getcomproot
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# A helper script for LaTeX/groff files used by `compiler` and `opout`.
|
||||||
|
# The user can add the root file of a larger project as a comment as below:
|
||||||
|
# % root = mainfile.tex
|
||||||
|
# And the compiler script will run on that instead of the opened file.
|
||||||
|
|
||||||
|
texroot="$(grep -i "^.\+\s*root\s*=\s*\S\+" "$1")"
|
||||||
|
texroot="${texroot##*=}"
|
||||||
|
texroot="${texroot//[\"\' ]}"
|
||||||
|
|
||||||
|
[ -f "$texroot" ] && readlink -f "$texroot" || exit 1
|
||||||
12
.local/bin/ifinstalled
Executable file
12
.local/bin/ifinstalled
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Some optional functions in LARBS require programs not installed by default. I
|
||||||
|
# use this little script to check to see if a command exists and if it doesn't
|
||||||
|
# it informs the user that they need that command to continue. This is used in
|
||||||
|
# various other scripts for clarity's sake.
|
||||||
|
|
||||||
|
for x in "$@"; do
|
||||||
|
if ! which "$x" >/dev/null 2>&1 && ! pacman -Qq "$x" >/dev/null 2>&1; then
|
||||||
|
notify-send "📦 $x" "must be installed for this function." && exit 1 ;
|
||||||
|
fi
|
||||||
|
done
|
||||||
31
.local/bin/linkhandler
Executable file
31
.local/bin/linkhandler
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Feed script a url or file location.
|
||||||
|
# If an image, it will view in nsxiv,
|
||||||
|
# if a video or gif, it will view in mpv
|
||||||
|
# if a music file or pdf, it will download,
|
||||||
|
# otherwise it opens link in browser.
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
url="$(xclip -o)"
|
||||||
|
else
|
||||||
|
url="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$url" in
|
||||||
|
*mkv | *webm | *mp4 | *youtube.com/watch* | *youtube.com/playlist* | *youtube.com/shorts* | *youtu.be* | *hooktube.com* | *bitchute.com* | *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")" && nsxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 &
|
||||||
|
;;
|
||||||
|
*pdf | *cbz | *cbr)
|
||||||
|
curl -sL "$url" >"/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 &
|
||||||
|
;;
|
||||||
|
*mp3 | *flac | *opus | *mp3?source*)
|
||||||
|
qndl "$url" 'curl -LO' >/dev/null 2>&1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
18
.local/bin/maimpick
Executable file
18
.local/bin/maimpick
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is bound to Shift+PrintScreen by default, requires maim. It lets you
|
||||||
|
# choose the kind of screenshot to take, including copying the image or even
|
||||||
|
# highlighting an area to copy. scrotcucks on suicidewatch right now.
|
||||||
|
|
||||||
|
# variables
|
||||||
|
output="$(date '+%y%m%d-%H%M-%S').png"
|
||||||
|
xclip_cmd="xclip -sel clip -t image/png"
|
||||||
|
|
||||||
|
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
||||||
|
"a selected area") maim -s pic-selected-"${output}" ;;
|
||||||
|
"current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
|
||||||
|
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;
|
||||||
|
"a selected area (copy)") maim -s | ${xclip_cmd} ;;
|
||||||
|
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
|
||||||
|
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
|
||||||
|
esac
|
||||||
93
.local/bin/mounter
Executable file
93
.local/bin/mounter
Executable file
@ -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
|
||||||
16
.local/bin/opout
Executable file
16
.local/bin/opout
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# opout: "open output": A general handler for opening a file's intended output,
|
||||||
|
# usually the pdf of a compiled document. I find this useful especially
|
||||||
|
# running from vim.
|
||||||
|
|
||||||
|
basename="${1%.*}"
|
||||||
|
|
||||||
|
case "${*}" in
|
||||||
|
*.tex | *.sil | *.m[dse] | *.[rR]md | *.mom | *.[0-9])
|
||||||
|
target="$(getcomproot "$1" || echo "$1")"
|
||||||
|
setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1
|
||||||
|
;;
|
||||||
|
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
|
||||||
|
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
|
||||||
|
esac
|
||||||
15
.local/bin/remaps
Executable file
15
.local/bin/remaps
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is called on startup to remap keys.
|
||||||
|
# Decrease key repeat delay to 300ms and increase key repeat rate to 50 per second.
|
||||||
|
xset r rate 300 50
|
||||||
|
|
||||||
|
# Map the caps lock key to super, and map the menu key to right super.
|
||||||
|
# setxkbmap -option caps:super,altwin:menu_win
|
||||||
|
|
||||||
|
# When caps lock is pressed only once, treat it as escape.
|
||||||
|
killall xcape 2>/dev/null
|
||||||
|
# xcape -e 'Super_L=Escape'
|
||||||
|
|
||||||
|
# Turn off caps lock if on since there is no longer a key for it.
|
||||||
|
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
|
||||||
12
.local/bin/rotdir
Executable file
12
.local/bin/rotdir
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# When I open an image from the file manager in sxiv (the image viewer), I want
|
||||||
|
# to be able to press the next/previous keys to key through the rest of the
|
||||||
|
# images in the same directory. This script "rotates" the content of a
|
||||||
|
# directory based on the first chosen file, so that if I open the 15th image,
|
||||||
|
# if I press next, it will go to the 16th etc. Autistic, I know, but this is
|
||||||
|
# one of the reasons that sxiv is great for being able to read standard input.
|
||||||
|
|
||||||
|
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||||
|
base="$(basename "$1")"
|
||||||
|
ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'
|
||||||
37
.local/bin/setbg
Executable file
37
.local/bin/setbg
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
#!/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"
|
||||||
|
|
||||||
|
trueloc="$(readlink -f "$1")" &&
|
||||||
|
case "$(file --mime-type -b "$trueloc")" in
|
||||||
|
image/*) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
|
||||||
|
inode/directory) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
|
||||||
|
*)
|
||||||
|
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
|
||||||
11
.local/bin/td-toggle
Executable file
11
.local/bin/td-toggle
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
||||||
|
|
||||||
|
if pidof transmission-daemon >/dev/null; then
|
||||||
|
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-daemon && notify-send "transmission-daemon disabled."
|
||||||
|
else
|
||||||
|
ifinstalled transmission-cli || exit
|
||||||
|
[ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "transmission-daemon enabled."
|
||||||
|
fi
|
||||||
|
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||||
15
.local/bin/texclear
Executable file
15
.local/bin/texclear
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||||
|
# I have vim run this file whenever I exit a .tex file.
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.tex)
|
||||||
|
file=$(readlink -f "$1")
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
base="${file%.*}"
|
||||||
|
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(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
|
||||||
|
rm -rdf "$dir/_minted-$(basename -- "$base")"
|
||||||
|
;;
|
||||||
|
*) printf "Give .tex file as argument.\\n" ;;
|
||||||
|
esac
|
||||||
8
.local/bin/tordone
Executable file
8
.local/bin/tordone
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#/bin/sh
|
||||||
|
# * TR_APP_VERSION
|
||||||
|
# * TR_TIME_LOCALTIME
|
||||||
|
# * TR_TORRENT_DIR
|
||||||
|
# * TR_TORRENT_HASH
|
||||||
|
# * TR_TORRENT_ID
|
||||||
|
# * TR_TORRENT_NAME
|
||||||
|
notify-send "Transmission-daemon" "$TR_TORRENT_NAME has completely downloaded."
|
||||||
8
.local/bin/torwrap
Executable file
8
.local/bin/torwrap
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ifinstalled stig transmission-cli || exit
|
||||||
|
|
||||||
|
! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
|
||||||
|
|
||||||
|
$TERMINAL -e stig
|
||||||
|
pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||||
9
.local/bin/transadd
Executable file
9
.local/bin/transadd
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running.
|
||||||
|
|
||||||
|
# transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
|
||||||
|
|
||||||
|
pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}")
|
||||||
|
|
||||||
|
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
||||||
28
.local/bin/unmounter
Executable file
28
.local/bin/unmounter
Executable file
@ -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"
|
||||||
|
|
||||||
|
doas 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##*/}"
|
||||||
|
doas cryptsetup close "$cryptid"
|
||||||
|
notify-send "🔒Device dencryption closed." "Drive is now securely locked again."
|
||||||
Loading…
Reference in New Issue
Block a user