mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Use dotter
This commit is contained in:
15
local/bin/chtsh
Executable file
15
local/bin/chtsh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
selected=$(cat ~/.config/tmux/tmux-cht-languages ~/.config/tmux/tmux-cht-command | fzf)
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "Enter Query: " query
|
||||
|
||||
if rg -qs "$selected" ~/.config/tmux/tmux-cht-languages; then
|
||||
query=$(echo $query | tr ' ' '+')
|
||||
tmux neww zsh -c "echo \"curl cht.sh/$selected/$query/\" & curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done"
|
||||
else
|
||||
tmux neww zsh -c "curl -s cht.sh/$selected~$query | less"
|
||||
fi
|
||||
61
local/bin/compiler
Executable file
61
local/bin/compiler
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/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##*.}"
|
||||
echo "$file"
|
||||
|
||||
cd "$dir" || exit 1
|
||||
|
||||
textype() {
|
||||
textarget="$(getcomproot "$file" || echo "$file")"
|
||||
echo "$textarget"
|
||||
command="xelatex"
|
||||
(head -n5 "$textarget" | grep -qi "pdflatex") && command="pdflatex"
|
||||
$command -shell-escape --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 | cc) 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" ;;
|
||||
*/Makefile) make --file "$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 run ;;
|
||||
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
|
||||
23
local/bin/imv-open
Executable file
23
local/bin/imv-open
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
FIFO_PATH="$1"
|
||||
IMAGE="$2"
|
||||
MAINWINDOW="$(xdotool getactivewindow)"
|
||||
IMV_PID="$(pgrep nsxiv)"
|
||||
|
||||
if [ ! "$IMV_PID" ]; then
|
||||
nsxiv -aio "$IMAGE" &
|
||||
IMV_PID=$!
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
|
||||
xdotool windowactivate "$MAINWINDOW"
|
||||
|
||||
while read -r path; do
|
||||
imv-msg "$IMV_PID" close all
|
||||
imv-msg "$IMV_PID" open "$path"
|
||||
done <"$FIFO_PATH"
|
||||
|
||||
imv-msg "$IMV_PID" quit
|
||||
[ -e "$FIFO_PATH" ] && rm -f -- "$FIFO_PATH"
|
||||
19
local/bin/lfrun
Executable file
19
local/bin/lfrun
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cleanup() {
|
||||
exec 3>&-
|
||||
rm "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
lf "$@"
|
||||
else
|
||||
[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
|
||||
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
|
||||
exec 3>"$FIFO_UEBERZUG"
|
||||
trap cleanup EXIT
|
||||
lf "$@" 3>&-
|
||||
fi
|
||||
24
local/bin/lfub
Executable file
24
local/bin/lfub
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is a wrapper script for lb that allows it to create image previews with
|
||||
# ueberzug. This works in concert with the lf configuration file and the
|
||||
# lf-cleaner script.
|
||||
|
||||
set -e
|
||||
|
||||
cleanup() {
|
||||
exec 3>&-
|
||||
rm "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
lf "$@"
|
||||
else
|
||||
[ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
|
||||
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
|
||||
exec 3>"$FIFO_UEBERZUG"
|
||||
trap cleanup HUP INT QUIT TERM PWR EXIT
|
||||
lf "$@" 3>&-
|
||||
fi
|
||||
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
|
||||
10
local/bin/lock
Executable file
10
local/bin/lock
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
for o in HDMI-A-2 DP-1 eDP-1; do
|
||||
grim -o "$o" "/tmp/$o.png"
|
||||
# check if the file exists
|
||||
if [[ -f "/tmp/$o.png" ]]; then
|
||||
corrupter "/tmp/$o.png" "/tmp/$o.png" &
|
||||
fi
|
||||
done
|
||||
wait
|
||||
exec gtklock "$@"
|
||||
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
|
||||
19
local/bin/remaps
Executable file
19
local/bin/remaps
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/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
|
||||
# Turn on num lock
|
||||
xset -q | grep "Num Lock:\s*off" && xdotool key Num_Lock
|
||||
|
||||
setxkbmap lv
|
||||
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; }'
|
||||
22
local/bin/set-animated-bg
Executable file
22
local/bin/set-animated-bg
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
# Directory containing the videos
|
||||
VIDEO_DIR="${HOME}/Pictures/wallpapers/animated/wallset"
|
||||
|
||||
# List all video files in the directory
|
||||
VIDEOS=($(ls $VIDEO_DIR/*))
|
||||
|
||||
# Check if there are any videos in the directory
|
||||
if [ ${#VIDEOS[@]} -eq 0 ]; then
|
||||
echo "No videos found in $VIDEO_DIR."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Select a random video
|
||||
RANDOM_VIDEO=${VIDEOS[$((RANDOM % ${#VIDEOS[@]}))]}
|
||||
|
||||
# Play the selected v
|
||||
|
||||
wallset --video "$RANDOM_VIDEO"
|
||||
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
|
||||
3
local/bin/song-change
Executable file
3
local/bin/song-change
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
song=$(playerctl metadata --player=spotify --format "Title: {{ xesam:title }}\nArtist: {{ xesam:artist }}\nAlbum: {{ xesam:album }}")
|
||||
notify-send "Music Player" "$song" --icon=~/.config/spotifyd/spotify.png
|
||||
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
|
||||
25
local/bin/tmux-sessionizer
Executable file
25
local/bin/tmux-sessionizer
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
selected=$(fd --min-depth 1 --max-depth 1 --type d . ~/repos/Rust/ ~/repos/examples/ ~/repos/ ~/neorg/Work/ ~/Nextcloud/repos/ ~/Nextcloud/Documents/LaTeX/ ~/Nextcloud/Documents/Typst/ ~/Nextcloud/repos/university/** ~/Nextcloud/repos/university/**/**/ ~/repos/Codnity/ ~/repos/yoda-bot/ ~/repos/Codnity/emisela/ | sk --height 16)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||
tmux new-session -s "$selected_name" -c "$selected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected_name"
|
||||
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."
|
||||
26
local/bin/unix
Executable file
26
local/bin/unix
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
|
||||
#converted to shell by #nixers @ irc.unix.chat
|
||||
|
||||
cat <<'eof'
|
||||
[38;5;255m,_ ,_==▄▂[0m
|
||||
[38;5;255m, ▂▃▄▄▅▅[48;5;240m▅[48;5;20m▂[48;5;240m▅¾[0m. [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;255m[48;5;20m▄[0m[38;5;255m[48;5;199m▆[38;5;16m[48;5;255m<´ [38;5;32m"[38;5;34m»[38;5;255m▓▓[48;5;32m▓[48;5;240m%[0m\ [38;5;199m/ [38;5;20m/ [38;5;45m/ [38;5;118m/[0m
|
||||
[38;5;255m,[38;5;255m[48;5;240m▅[38;5;16m[48;5;255m7" [38;5;160m´[38;5;34m>[38;5;255m[48;5;39m▓▓[38;5;199m[48;5;255m▓[0m[38;5;255m% [38;5;20m/ [38;5;118m/ [38;5;199m> [38;5;118m/ [38;5;199m>[38;5;255m/[38;5;45m%[0m
|
||||
[38;5;255m▐[48;5;240m[38;5;255m¶[48;5;240m[38;5;255m▓[48;5;255m [38;5;196m,[38;5;34m»[48;5;201m[38;5;255m▓▓[0m[38;5;255m¾´[0m [38;5;199m/[38;5;255m> %[38;5;199m/[38;5;118m%[38;5;255m/[38;5;199m/ [38;5;45m/ [38;5;199m/[0m
|
||||
[38;5;255m[48;5;240m▓[48;5;255m[38;5;16m▃[48;5;16m[38;5;255m▅▅[38;5;16m[48;5;255m▅▃,,[38;5;32m▄[38;5;16m▅[38;5;255m[48;5;16m▅▅[38;5;255m[48;5;20mÆ[0m[38;5;255m\[0m[38;5;20m/[38;5;118m/[38;5;255m /[38;5;118m/[38;5;199m/[38;5;255m>[38;5;45m// [38;5;255m/[38;5;118m>[38;5;199m/ [38;5;20m/[0m
|
||||
[48;5;20m[38;5;255mV[48;5;255m[38;5;16m║[48;5;20m[38;5;255m«[0m[38;5;255m¼.;[48;5;240m[38;5;255m→[48;5;255m[38;5;16m ║[0m[38;5;255m<«.,[48;5;25m[38;5;255m`[48;5;240m=[0m[38;5;20m/[38;5;199m/ [38;5;255m/>[38;5;45m/[38;5;118m/[38;5;255m%/[38;5;199m% / [38;5;20m/[0m
|
||||
[38;5;20m//[48;5;255m[38;5;16m╠<´ -²,)[48;5;16m[38;5;255m(▓[48;5;255m[38;5;16m~"-[38;5;199m╝/[0m[38;5;255m¾[0m[38;5;199m/ [38;5;118m%[38;5;255m/[38;5;118m>[38;5;45m/ [38;5;118m/[38;5;199m>[0m
|
||||
[38;5;20m/ / [38;5;118m/ [48;5;20m[38;5;255m▐[48;5;240m[38;5;16m%[48;5;255m -./▄▃▄[48;5;16m[38;5;255m▅[48;5;255m[38;5;16m▐[48;5;255m[38;5;16m, [38;5;199m/[48;5;199m[38;5;255m7[0m[38;5;20m/[38;5;199m/[38;5;255m;/[38;5;199m/[38;5;118m% [38;5;20m/ /[0m
|
||||
[38;5;20m/ [38;5;199m/[38;5;255m/[38;5;45m/[38;5;118m/[38;5;255m[48;5;240m`[48;5;20m[38;5;255m▌[48;5;20m[38;5;255m▐[48;5;255m[38;5;16m %z[0m[38;5;255mWv xX[48;5;20m[38;5;255m▓[48;5;34m[38;5;255m▇[48;5;199m[38;255m▌[0m[38;5;20m/[38;5;199m/[38;5;255m&;[38;5;20m% [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;20m/ / [38;5;255m/ [38;5;118m%[38;5;199m/[38;5;255m/%/[48;5;240m[38;5;255m¾[48;5;255m[38;5;16m½´[38;5;255m[48;5;16m▌[0m[38;5;246m▃▄[38;5;255m▄▄[38;5;246m▄▃▃[0m[48;5;16m[38;5;255m▐[38;5;255m[48;5;199m¶[48;5;20m[38;5;255m\[0m[38;5;20m/[0m[48;5;255m[38;5;240m&[0m [38;5;20m/[0m
|
||||
[38;5;199m<[38;5;118m/ [38;5;45m/[38;5;255m</[38;5;118m%[38;5;255m/[38;5;45m/[38;5;255m`[48;5;16m▓[48;5;255m[38;5;16m![48;5;240m[38;5;255m%[48;5;16m[38;5;255m▓[0m[38;5;255m%[48;5;240m[38;5;255m╣[48;5;240m[38;5;255;╣[0m[38;5;255mW[0m[38;5;250mY<Y)[48;5;255m[38;5;16my&[0m[38;5;255m/`[48;5;240m\[0m
|
||||
[38;5;20m/ [38;5;199m/ [38;5;199m%[38;5;255m/%[38;5;118m/[38;5;45m/[38;5;255m<[38;5;118m/[38;5;199m%[38;5;45m/[38;5;20m/[48;5;240m[38;5;255m\[38;5;16m[48;5;255mi7; ╠N[0m[38;5;246m>[38;5;255m)VY>[48;5;240m[38;5;255m7[0m[38;5;255m; [38;5;255m[48;5;240m\[0m[38;5;255m_[0m [38;5;255mUNIX IS VERY SIMPLE [38;5;45mIT JUST NEEDS A[0m
|
||||
[38;5;20m/ [38;5;255m/[38;5;118m<[38;5;255m/ [38;5;45m/[38;5;255m/<[38;5;199m/[38;5;20m/[38;5;199m/[38;5;20m<[38;5;255m_/%\[38;5;255m[48;5;16m▓[48;5;255m[38;5;16m V[0m[38;5;255m%[48;5;255m[38;5;16mW[0m[38;5;255m%£)XY[0m [38;5;240m_/%[38;5;255m‾\_,[0m [38;5;45mGENIUS TO UNDERSTAND ITS SIMPLICITY[38;5;255m[0m
|
||||
[38;5;199m/ [38;5;255m/ [38;5;199m/[38;5;255m/[38;5;118m%[38;5;199m/[48;5;240m[38;5;255m_,=-[48;5;20m-^[0m[38;5;255m/%/%%[48;5;255m[38;5;16m\¾%[0m[38;5;255m¶[0m[48;5;255m[38;5;16m%[0m[38;5;255m%}[0m [38;5;240m/%%%[38;5;20m%%[38;5;240m%;\,[0m
|
||||
[38;5;45m%[38;5;20m/[38;5;199m< [38;5;20m/[48;5;20m[38;5;255m_/[48;5;240m [0m[38;5;255m%%%[38;5;240m%%[38;5;20m;[38;5;255mX[38;5;240m%[38;5;20m%[38;5;255m\%[38;5;240m%;, _/%%%;[38;5;20m,[38;5;240m \[0m
|
||||
[38;5;118m/ [38;5;20m/ [38;5;240m%[38;5;20m%%%%[38;5;240m%;, [38;5;255m\[38;5;240m%[38;5;20m%[38;5;255ml[38;5;240m%%;// _/[38;5;20m%;,[0m [38;5;234m[0m
|
||||
[38;5;20m/ [38;5;240m%[38;5;20m%%;,[0m [38;5;255m<[38;5;20m;[38;5;240m\-=-/ /[0m
|
||||
[38;5;20m;,[0m [38;5;240ml[0m
|
||||
eof
|
||||
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."
|
||||
30
local/bin/zellij-sessionizer
Executable file
30
local/bin/zellij-sessionizer
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
selected=$(fd --min-depth 1 --max-depth 1 --type d . ~/repos/Rust/ ~/repos/ ~/neorg/University/3rd-semester/ ~/Nextcloud/repos/ ~/Nextcloud/Documents/LaTeX/ ~/Nextcloud/Documents/Typst/ ~/Nextcloud/repos/university/** ~/Nextcloud/repos/university/**/**/ | sk --height 16)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
zellij_running=$(pgrep zellij)
|
||||
|
||||
if [[ -z $ZELLIJ ]] && [[ -z $zellij_running ]]; then
|
||||
# tmux new-session -s "$selected_name" -c "$selected"
|
||||
zellij action new-tab -n "$selected_name" -c "$selected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! zellij list-sessions | rg "$selected_name"; then
|
||||
zellij action
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected_name"
|
||||
Reference in New Issue
Block a user