1
0
Fork 0

update a bunch of scripts

This commit is contained in:
Luca Bilke 2023-02-04 22:15:35 +01:00
parent 458c09881c
commit 6a16d32c3d
27 changed files with 3198 additions and 1734 deletions

View File

@ -4,7 +4,7 @@
# have this script run via vim. # have this script run via vim.
# #
# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent # Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
# presentations. Runs scripts based on extention or shebang. # presentations. Runs scripts based on extension or shebang.
# #
# Note that .tex files which you wish to compile with XeLaTeX should have the # 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. # string "xelatex" somewhere in a comment/command in the first 5 lines.
@ -17,8 +17,8 @@ cd "$dir" || exit 1
textype() { \ textype() { \
command="pdflatex" command="pdflatex"
texroot=$(readlink -f "$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]")") texroot=$(readlink -f "$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]")")
[ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot" [ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot"
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex" ( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="$dir" "$base" && $command --output-directory="$dir" "$base" &&
grep -qi addbibresource "$file" && grep -qi addbibresource "$file" &&
@ -39,9 +39,9 @@ case "$ext" in
java) loc=$(findup . -name gradlew); [ "$loc" != "" ] && exec "$loc" run -q -p "$(dirname "$loc")" ;; java) loc=$(findup . -name gradlew); [ "$loc" != "" ] && exec "$loc" run -q -p "$(dirname "$loc")" ;;
m) octave "$file" ;; m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then 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 elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff > "$base.pdf" groffdown -i "$file" | groff -T pdf > "$base.pdf"
else else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;; fi ; ;;
@ -51,7 +51,7 @@ case "$ext" in
py) python "$file" ;; py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;; rs) cargo build ;;
sass) sassc -a "$file" "$base.css" ;; sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;; scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;; sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;; tex) textype "$file" ;;

View File

@ -36,31 +36,31 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
fi fi
} }
morescreen() { # If multi-monitor is selected and there are more than two screens. morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:") primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
} }
multimon() { # Multi-monitor handler. multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in case "$(echo "$screens" | wc -l)" in
2) twoscreen ;; 2) twoscreen ;;
*) morescreen ;; *) morescreen ;;
esac ;} esac ;}
onescreen() { # If only one output available or chosen. onescreen() { # If only one output available or chosen.
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)""
} }
postrun() { # Stuff to run to clean up. postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed. setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases) remaps-no-change # Re-remap keys if keyboard added (for laptop bases)
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen { killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
} }
# Get all possible displays # Get all possible displays
allposs=$(xrandr -q | grep "connected") allposs=$(xrandr -q | grep "connected")
@ -70,14 +70,14 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen # If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] && [ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;} { onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
# Get user choice including multi-monitor and manual selection: # Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") && chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in case "$chosen" in
"manual selection") arandr ; exit ;; "manual selection") arandr ; exit ;;
"multi-monitor") multimon ;; "multi-monitor") multimon ;;
*) onescreen "$chosen" ;; *) onescreen "$chosen" ;;
esac esac
postrun postrun

View File

@ -4,17 +4,17 @@
# some choice programs to use to open it. # some choice programs to use to open it.
feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}" feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}"
case "$(printf "Copy URL\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dl\\nqueue yt-dl audio" | dmenu -i -p "Open it with?")" in case "$(printf "copy url\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dlp\\nqueue yt-dlp audio" | dmenu -i -p "Open it with?")" in
"copy url") echo "$feed" | xclip -selection clipboard ;; "copy url") echo "$feed" | xclip -selection clipboard ;;
mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;; mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;;
"mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;; "mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;;
"mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;; "mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;;
"queue yt-dl") qndl "$feed" >/dev/null 2>&1 ;; "queue yt-dlp") qndl "$feed" >/dev/null 2>&1 ;;
"queue yt-dl audio") qndl "$feed" 'youtube-dl --add-metadata -icx -f bestaudio/best' >/dev/null 2>&1 ;; "queue yt-dlp audio") qndl "$feed" 'yt-dlp -o "%(title)s.%(ext)s" -f bestaudio --embed-metadata --restrict-filenames' ;;
"queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;; "queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;;
PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
setbg) curl -L "$feed" > $XDG_CACHE_HOME/pic ; xwallpaper --zoom $XDG_CACHE_HOME/pic >/dev/null 2>&1 ;; setbg) curl -L "$feed" > $XDG_CACHE_HOME/pic ; xwallpaper --zoom $XDG_CACHE_HOME/pic >/dev/null 2>&1 ;;
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;; browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
lynx) lynx "$feed" >/dev/null 2>&1 ;; lynx) lynx "$feed" >/dev/null 2>&1 ;;

View File

@ -27,18 +27,18 @@ mountusb() { \
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; "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)";; "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";; *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
esac esac && notify-send "禍 USB mounting" "$chosen mounted to $mp." ||
notify-send "禍 USB mounting" "$chosen mounted to $mp." notify-send "禍 Drive failed to mount." "Probably a permissions issue or a drive is already mounted."
} }
mountandroid() { \ mountandroid() { \
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1 chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)" chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d" 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 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" simple-mtpfs --device "$chosen" "$mp" &&
notify-send " Android Mounting" "Android device mounted to $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() { \ asktype() { \

View File

@ -4,41 +4,22 @@
# Provides you with mounted partitions, select one to unmount. # Provides you with mounted partitions, select one to unmount.
# Drives mounted at /, /boot and /home will not be options to unmount. # Drives mounted at /, /boot and /home will not be options to unmount.
unmountusb() { 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)"
[ -z "$drives" ] && exit
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
[ -z "$chosen" ] && exit 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."
sudo -A umount "$chosen" && notify-send "禍 USB unmounting" "$chosen unmounted." sudo -A umount "$chosen" && notify-send "禍 USB unmounting" "$chosen unmounted."
}
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." sudo -A umount -l "$chosen" && notify-send " Android unmounting" "$chosen unmounted."
}
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

View File

@ -3,7 +3,7 @@
# The famous "get a menu of emojis to copy" script. # The famous "get a menu of emojis to copy" script.
# Get user selection via dmenu from emoji file. # Get user selection via dmenu from emoji file.
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//") chosen=$(cut -d ';' -f1 ~/.local/share/chars/* | dmenu -i -l 30 | sed "s/ .*//")
# Exit if none chosen. # Exit if none chosen.
[ -z "$chosen" ] && exit [ -z "$chosen" ] && exit

View File

@ -1,7 +0,0 @@
#!/bin/sh
cat <<EOF | xmenu
[]= Tiled Layout 0
><> Floating Layout 1
[M] Monocle Layout 2
EOF

View File

@ -6,18 +6,22 @@
# if a music file or pdf, it will download, # if a music file or pdf, it will download,
# otherwise it opens link in browser. # otherwise it opens link in browser.
# If no url given. Opens browser. For using script as $BROWSER. if [ -z "$1" ]; then
[ -z "$1" ] && { "$BROWSER"; exit; } url="$(xclip -o)"
else
url="$1"
fi
case "$1" in case "$url" in
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*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 "$1" >/dev/null 2>&1 ;; setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
*png|*jpg|*jpe|*jpeg|*gif) *png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; 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 & ;;
*pdf|*cbz|*cbr) *pdf|*cbz|*cbr)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; 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*) *mp3|*flac|*opus|*mp3?source*)
qndl "$1" 'curl -LO' >/dev/null 2>&1 ;; qndl "$url" 'curl -LO' >/dev/null 2>&1 ;;
*) *)
[ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" >/dev/null 2>&1 || setsid -f "$BROWSER" "$1" >/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 esac

View File

@ -4,13 +4,16 @@
# choose the kind of screenshot to take, including copying the image or even # choose the kind of screenshot to take, including copying the image or even
# highlighting an area to copy. scrotcucks on suicidewatch right now. # highlighting an area to copy. scrotcucks on suicidewatch right now.
dir="$HOME/Photos/Screenshots/" # 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 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 "${dir}pic-selected-$(date '+%y%m%d-%H%M-%S').png" ;; "a selected area") maim -s pic-selected-"${output}" ;;
"current window") maim -i "$(xdotool getactivewindow)" "${dir}pic-window-$(date '+%y%m%d-%H%M-%S').png" ;; "current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
"full screen") maim "${dir}pic-full-$(date '+%y%m%d-%H%M-%S').png" ;; "full screen") maim -q -d 0.2 pic-full-"${output}" ;;
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;; "a selected area (copy)") maim -s | ${xclip_cmd} ;;
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;; "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
esac esac

View File

@ -5,7 +5,7 @@
base="$(basename "$1")" base="$(basename "$1")"
notify-send "羽Queuing $base..." notify-send "羽Queuing $base..."
cmd="$2" cmd="$2"
[ -z "$cmd" ] && cmd="youtube-dl --add-metadata -ic" [ -z "$cmd" ] && cmd="yt-dlp --embed-metadata -ic"
idnum="$(tsp $cmd "$1")" idnum="$(tsp $cmd "$1")"
realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")"
tsp -D "$idnum" mv "$base" "$realname" tsp -D "$idnum" mv "$base" "$realname"

View File

@ -2,7 +2,7 @@
# Podboat sucks. This script replaces it. # Podboat sucks. This script replaces it.
# It reads the newsboat queue, queuing downloads with taskspooler. # It reads the newsboat queue, queuing downloads with taskspooler.
# It also removes the junk from extentions. # It also removes the junk from extensions.
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue" queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
while read -r line; do while read -r line; do

10
.local/bin/remaps-no-change Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
setxkbmap -layout "$(echo "$current" | cut -d ':' -f1)" -variant "$(echo "$current" | cut -d ':' -f2)" -option caps:super -option terminate:ctrl_alt_bksp
xset r rate 300 50
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
sleep 0.03
pkill -RTMIN+15 dwmblocks

View File

@ -2,9 +2,21 @@
# Open a terminal window in the same directory as the currently active window. # 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") windowPID=$(xprop -id "$(xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
PID="$(pstree -lpA "$PID")" PIDlist=$(pstree -lpATna "$windowPID" | sed -En 's/.*,([0-9]+).*/\1/p' | tac)
PID="${PID##*(}" for PID in $PIDlist; do
PID="${PID%)}" cmdline=$(ps -o args= -p "$PID")
cd "$(readlink /proc/"$PID"/cwd)" || return 1 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" "$TERMINAL"

View File

@ -4,15 +4,9 @@
# Run by itself, set the wallpaper (at X start). # Run by itself, set the wallpaper (at X start).
# If given a file, set that as the new wallpaper. # If given a file, set that as the new wallpaper.
# If given a directory, choose random file in it. # 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" 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")" && trueloc="$(readlink -f "$1")" &&
case "$(file --mime-type -b "$trueloc")" in case "$(file --mime-type -b "$trueloc")" in
image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;; image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
@ -20,14 +14,4 @@ case "$(file --mime-type -b "$trueloc")" in
*) notify-send "Error" "Not a valid image." ; exit 1;; *) notify-send "Error" "Not a valid image." ; exit 1;;
esac esac
# If pywal is installed, use it.
if command -v wal >/dev/null 2>&1 ; then
wal -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
pidof dwm >/dev/null && xdotool key super+F12
# 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" xwallpaper --zoom "$bgloc"

View File

@ -1,6 +1,5 @@
#!/bin/sh #!/bin/sh
# TODO: Rewrite this shit to connect to an external deluged transmission-remote "$1" -l | grep % |
transmission-remote -l | grep % |
sed " # The letters are for sorting and will not appear. sed " # The letters are for sorting and will not appear.
s/.*Stopped.*/A /; s/.*Stopped.*/A /;
s/.*Seeding.*/Z 﫠/; s/.*Seeding.*/Z 﫠/;
@ -8,20 +7,4 @@ transmission-remote -l | grep % |
s/.*Idle.*/B ﭦ/; s/.*Idle.*/B ﭦ/;
s/.*Uploading.*/L /; s/.*Uploading.*/L /;
s/.*%.*/M /" | s/.*%.*/M /" |
sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' - sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e tremc ;;
2) td-toggle ;;
3) notify-send " Torrent module" "\- Left click to open tremc.
- Middle click to toggle transmission.
- Shift click to edit script.
Module shows number of torrents:
: paused
ﭦ: idle (seeds needed)
: uploading (unfinished)
: downloading
﫠: done
﫠: done and seeding" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

View File

@ -9,8 +9,8 @@ case "$(printf " lock\nﴚ leave dwm\n累 renew dwm\nﭦ hibernate\n sleep
' lock') xset s activate & gpg-connect-agent --no-autostart reloadagent /bye;; ' lock') xset s activate & gpg-connect-agent --no-autostart reloadagent /bye;;
'ﴚ leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;; 'ﴚ leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
'累 renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;; '累 renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
# 'ﭦ hibernate') slock $ctl hibernate ;; # 'ﭦ hibernate') slock $ctl hibernate -i ;;
# ' sleep') slock $ctl suspend ;; # ' sleep') slock $ctl suspend -i ;;
'ﰇ reboot') $ctl reboot ;; 'ﰇ reboot') $ctl reboot ;;
'襤 shutdown') $ctl poweroff ;; '襤 shutdown') $ctl poweroff ;;
' display off') xset dpms force off ;; ' display off') xset dpms force off ;;

1631
.local/share/chars/emoji Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff