1
0
Fork 0
shfmt
This commit is contained in:
Luca Bilke 2023-02-07 17:19:53 +01:00
parent 1f2fda79e8
commit 774f14f273
59 changed files with 797 additions and 721 deletions

View File

@ -18,7 +18,7 @@ fi
# Automatically determine an unused $DISPLAY
d=0
while true ; do
while true; do
[ -e "/tmp/.X$d-lock" ] || [ -S "/tmp/.X11-unix/X$d" ] || break
d=$((d + 1))
done
@ -33,7 +33,7 @@ fi
removelist=
# check for GNU hostname
if hostname --version > /dev/null 2>&1; then
if hostname --version >/dev/null 2>&1; then
if ! hostname --version 2>&1 | grep GNU -q; then
hostname=$(hostname -f)
fi
@ -56,7 +56,7 @@ dummy=0
# create a file with auth information for the server. ':0' is a dummy.
xserverauthfile=$(mktemp --tmpdir serverauth.XXXXXXXXXX)
trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP BUS TERM
xauth -q -f "$xserverauthfile" << EOF
xauth -q -f "$xserverauthfile" <<EOF
add :$dummy . $mcookie
EOF
@ -66,15 +66,15 @@ serverargs=${serverargs}" -auth "${xserverauthfile}
# if '$displayname' already exists do not overwrite it as another
# server may need it. Add them to the '$xserverauthfile' instead.
for displayname in $authdisplay $hostname$authdisplay; do
authcookie=$(xauth list "$displayname" | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p") 2>/dev/null;
authcookie=$(xauth list "$displayname" | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p") 2>/dev/null
if [ -n "${authcookie+x}" ]; then
xauth -q << EOF
xauth -q <<EOF
add $displayname . $mcookie
EOF
removelist="$displayname $removelist"
else
dummy=$((dummy+1));
xauth -q -f "$xserverauthfile" << EOF
dummy=$((dummy + 1))
xauth -q -f "$xserverauthfile" <<EOF
add :$dummy . $authcookie
EOF
fi
@ -91,7 +91,7 @@ if [ x"$xserverauthfile" != x ]; then
rm -f "$xserverauthfile"
fi
if command -v deallocvt > /dev/null 2>&1; then
if command -v deallocvt >/dev/null 2>&1; then
deallocvt
fi

View File

@ -10,7 +10,7 @@ OPTIONFILE=/etc/X11/Xsession.options
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/X11/xsession.d" ] && SESSIONDIR=${XDG_CONFIG_HOME:-$HOME/.config}/X11/xsession.d || SESSIONDIR=/etc/X11/Xsession.d
[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/xorg/" ] && ERRFILE=${XDG_DATA_HOME:-$HOME/.local/share}/xorg/xsession-errors || ERRFILE=$HOME/.xsession-errors
message () {
message() {
# pretty-print messages of arbitrary length; use xmessage if it
# is available and $DISPLAY is set
MESSAGE="$PROGNAME: $*"
@ -20,23 +20,23 @@ message () {
# fi
}
message_nonl () {
message_nonl() {
# pretty-print messages of arbitrary length (no trailing newline); use
# xmessage if it is available and $DISPLAY is set
MESSAGE="$PROGNAME: $*"
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
# if [ -n "$DISPLAY" ] && command -v xmessage > /dev/null 2>&1; then
# echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
# fi
}
errormsg () {
errormsg() {
# exit script with error
message "$*"
exit 1
}
internal_errormsg () {
internal_errormsg() {
# exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
# One big call to message() for the sake of xmessage; if we had two then
# the user would have dismissed the error we want reported before seeing the
@ -66,10 +66,10 @@ has_option() {
}
# attempt to create an error file; abort if we cannot
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
if (umask 077 && touch "$ERRFILE") 2>/dev/null && [ -w "$ERRFILE" ] &&
[ ! -L "$ERRFILE" ]; then
chmod 600 "$ERRFILE"
elif ERRFILE=$(mktemp 2> /dev/null); then
elif ERRFILE=$(mktemp 2>/dev/null); then
if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
"\"$ERRFILE\"; look for session log/errors in" \
@ -82,7 +82,7 @@ fi
# truncate ERRFILE if it is too big to avoid disk usage DoS
if [ "$(stat -c%s \""$ERRFILE"\")" -gt 500000 ]; then
T=$(mktemp -p "$HOME")
tail -c 500000 "$ERRFILE" > "$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"
tail -c 500000 "$ERRFILE" >"$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"
fi
exec >>"$ERRFILE" 2>&1

View File

@ -1,7 +1,7 @@
# vim:set ft=sh
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -n "$XDG_RUNTIME_DIR" ] && \
[ "$XDG_RUNTIME_DIR" = "/run/user/`id -u`" ] && \
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -n "$XDG_RUNTIME_DIR" ] &&
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] &&
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
# We are under systemd-logind or something remarkably similar, and
# a user-session socket has already been set up.

View File

@ -1,13 +1,11 @@
# vim:set ft=sh
add_module()
{
add_module() {
case :$GTK_MODULES: in
*:$1:*)
;;
*:$1:*) ;;
*)
if [ -z "$GTK_MODULES" ]
then
if [ -z "$GTK_MODULES" ]; then
GTK_MODULES=$1
else
GTK_MODULES=$GTK_MODULES:$1

View File

@ -4,4 +4,4 @@ if [ "${SSH_AUTH_SOCK:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY="$(tty)"
gpg-connect-agent updatestartuptty /bye > /dev/null
gpg-connect-agent updatestartuptty /bye >/dev/null

View File

@ -1,7 +1,6 @@
# vim:set ft=sh
start()
{
start() {
pidof -s $1 || $@ >/dev/null 2>&1 &
}

View File

@ -15,6 +15,7 @@ null_ls.setup {
debug = false,
sources = {
formatting.black.with { extra_args = { "--fast" } },
formatting.shfmt,
-- formatting.stylua,
-- diagnostics.flake8,
},

View File

@ -15,11 +15,11 @@ ext="${file##*.}"
cd "$dir" || exit 1
textype() { \
textype() {
command="pdflatex"
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"
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
(head -n5 "$file" | grep -qi 'xelatex') && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -qi addbibresource "$file" &&
biber --input-directory "$dir" "$base" &&
@ -28,33 +28,36 @@ textype() { \
}
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 ;;
# 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 ;;
# findup is a script available here: https://unix.stackexchange.com/a/35265
java) loc=$(findup . -name gradlew); [ "$loc":w != "" ] && exec "$loc" run -q -p "$(dirname $loc)" ;;
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
java)
loc=$(findup . -name gradlew)
[ "$loc":w != "" ] && exec "$loc" run -q -p "$(dirname $loc)"
;;
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" ;;
fnl) fennel --compile "$file" > "$base.lua" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$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" ;;
fnl) fennel --compile "$file" >"$base.lua" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
esac

View File

@ -4,8 +4,11 @@ These cronjobs have components that require information about your current displ
When you add them as cronjobs, I recommend you precede the command with commands as those below:
```
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here
```
$()$(
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus
export DISPLAY=:0
. $HOME/.zprofile
then_command_goes_here
)$()
This ensures that notifications will display, xdotool commands will function and environmental variables will work as well.

View File

@ -9,8 +9,7 @@ sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
if pacman -Qu | grep -v "\[ignored\]"; then
notify-send " Repository Sync" "Updates available. Click statusbar icon () for update."
else
notify-send " Repository Sync" "Sync complete. No new packages for update."

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.consaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send " Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send " Cronjobs saved and disabled.")
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - <"${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send " Cronjobs re-enabled.") || (crontab -l >"${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send " Cronjobs saved and disabled.")

View File

@ -12,9 +12,15 @@
# Xorg and MacOS as well.
# Run only if user logged in (prevent cron errors)
pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;}
pgrep -u "${USER:=$LOGNAME}" >/dev/null || {
echo "$USER not logged in; sync will not run."
exit
}
# Run only if not already running in other instance
pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;}
pgrep mbsync >/dev/null && {
echo "mbsync is already running."
exit
}
# First, we have to get the right variables for the mbsync file, the pass
# archive, notmuch and the GPG home. This is done by searching common profile
@ -35,12 +41,12 @@ alias mbsync="mbsync -c $MBSYNCRC"
# Settings are different for MacOS (Darwin) systems.
case "$(uname)" in
Darwin)
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
Darwin)
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2; }
;;
*)
*)
case "$(readlink -f /sbin/init)" in
*systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;;
*systemd* | *openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;;
esac
# remember if a display server is running since `ps` doesn't always contain a display
pgrepoutput="$(pgrep -a X\(org\|wayland\))"
@ -48,7 +54,7 @@ case "$(uname)" in
notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "New mail!" "📬 $2 new mail(s) in \`$1\` account."
done ;}
done; }
;;
esac
@ -56,17 +62,16 @@ esac
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi
new=$(find\
"$HOME/.local/share/mail/$acc/INBOX/new/"\
"$HOME/.local/share/mail/$acc/Inbox/new/"\
"$HOME/.local/share/mail/$acc/inbox/new/"\
"$HOME/.local/share/mail/$acc/INBOX/cur/"\
"$HOME/.local/share/mail/$acc/Inbox/cur/"\
"$HOME/.local/share/mail/$acc/inbox/cur/"\
-type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null)
new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" \
"$HOME/.local/share/mail/$acc/Inbox/new/" \
"$HOME/.local/share/mail/$acc/inbox/new/" \
"$HOME/.local/share/mail/$acc/INBOX/cur/" \
"$HOME/.local/share/mail/$acc/Inbox/cur/" \
"$HOME/.local/share/mail/$acc/inbox/cur/" \
-type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2>/dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
case 1 in
$((newcount > 0)) ) notify "$acc" "$newcount" ;;
$((newcount > 0))) notify "$acc" "$newcount" ;;
esac
}

View File

@ -7,7 +7,7 @@
pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit
echo " 痢" > /tmp/newsupdate
echo " 痢" >/tmp/newsupdate
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
/usr/bin/newsboat -x reload
rm -f /tmp/newsupdate

View File

@ -1,5 +1,5 @@
#!/bin/sh
while : ; do
while :; do
dmesg -W -f kern | grep "input:" -q
sleep 1
remaps us:dvorak

View File

@ -1,4 +1,4 @@
#!/bin/sh
while : ; do
while :; do
mpc idle >/dev/null && pkill -RTMIN+11 dwmblocks || break
done

View File

@ -1,2 +1,2 @@
#!/bin/sh
playerctl status -F | (while read -r _; do pkill -RTMIN+11 dwmblocks; done;)
playerctl status -F | (while read -r _; do pkill -RTMIN+11 dwmblocks; done)

View File

@ -13,9 +13,9 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
internal=$(echo "$screens" | grep -v "$external")
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" |
tail -n 1 | awk '{print $1}')
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" |
tail -n 1 | awk '{print $1}')
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
@ -50,7 +50,8 @@ multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in
2) twoscreen ;;
*) morescreen ;;
esac ;}
esac
}
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 ' ' -)""
@ -59,7 +60,10 @@ onescreen() { # If only one output available or chosen.
postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed.
remaps -n # 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
@ -70,14 +74,22 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen
[ "$(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:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in
"manual selection") arandr ; exit ;;
case "$chosen" in
"manual selection")
arandr
exit
;;
"multi-monitor") multimon ;;
*) onescreen "$chosen" ;;
esac
esac
postrun

View File

@ -5,17 +5,20 @@
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-dlp\\nqueue yt-dlp audio" | dmenu -i -p "Open it with?")" in
"copy url") echo "$feed" | xclip -selection clipboard ;;
mpv) setsid -f mpv -quiet "$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 ;;
"queue yt-dlp") qndl "$feed" >/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 ;;
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 ;;
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 ;;
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
lynx) lynx "$feed" >/dev/null 2>&1 ;;
"copy url") echo "$feed" | xclip -selection clipboard ;;
mpv) setsid -f mpv -quiet "$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 ;;
"queue yt-dlp") qndl "$feed" >/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 ;;
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 ;;
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
;;
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
lynx) lynx "$feed" >/dev/null 2>&1 ;;
esac

View File

@ -5,7 +5,7 @@
# be prompted to give a mountpoint from already existsing directories. If you
# input a novel directory, it will prompt you to create that directory.
getmount() { \
getmount() {
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
@ -14,9 +14,9 @@ getmount() { \
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
fi
}
}
mountusb() { \
mountusb() {
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
sudo -A mount "$chosen" 2>/dev/null && notify-send "禍 USB mounting" "$chosen mounted." && exit 0
@ -24,14 +24,19 @@ mountusb() { \
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in
"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";;
"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." ||
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 "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
@ -39,15 +44,15 @@ mountandroid() { \
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() { \
asktype() {
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
case $choice in
USB) mountusb ;;
Android) mountandroid ;;
esac
}
}
anddrives=$(simple-mtpfs -l 2>/dev/null)
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"

View File

@ -13,7 +13,8 @@ share2mnt=//"$srvname".local/"$share"
sharemount() {
mounted=$(mount -v | grep "$share2mnt") || ([ ! -d /mnt/"$share" ] && sudo mkdir /mnt/"$share")
[ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0
notify-send "Netshare $share already mounted"; exit 1
notify-send "Netshare $share already mounted"
exit 1
}
sharemount

View File

@ -9,10 +9,10 @@
#
# If there is already a running instance, user will be prompted to end it.
updateicon() { \
echo "$1" > /tmp/recordingicon
updateicon() {
echo "$1" >/tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
}
}
killrecording() {
recpid="$(cat /tmp/recordingpid)"
@ -25,9 +25,9 @@ killrecording() {
sleep 3
kill -9 "$recpid"
exit
}
}
screencast() { \
screencast() {
ffmpeg -y \
-f x11grab \
-framerate 60 \
@ -37,69 +37,70 @@ screencast() { \
-r 30 \
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon "ﲠ"
}
}
video() { ffmpeg \
video() {
ffmpeg \
-f x11grab \
-s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
-i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon "ﲣ"
}
}
webcamhidef() { ffmpeg \
webcamhidef() {
ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 1920x1080 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon ""
}
}
webcam() { ffmpeg \
webcam() {
ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 640x480 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon ""
}
}
audio() { \
audio() {
ffmpeg \
-f alsa -i default \
-c:a flac \
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon ""
}
}
askrecording() { \
askrecording() {
choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
case "$choice" in
screencast) screencast;;
audio) audio;;
video) video;;
*selected) videoselected;;
webcam) webcam;;
"webcam (hi-def)") webcamhidef;;
screencast) screencast ;;
audio) audio ;;
video) video ;;
*selected) videoselected ;;
webcam) webcam ;;
"webcam (hi-def)") webcamhidef ;;
esac
}
}
asktoend() { \
asktoend() {
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
[ "$response" = "Yes" ] && killrecording
}
}
videoselected()
{
slop -f "%x %y %w %h" > /tmp/slop
read -r X Y W H < /tmp/slop
videoselected() {
slop -f "%x %y %w %h" >/tmp/slop
read -r X Y W H </tmp/slop
rm /tmp/slop
ffmpeg \
@ -109,15 +110,15 @@ videoselected()
-i :0.0+"$X,$Y" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
echo $! >/tmp/recordingpid
updateicon "ﲣ"
}
case "$1" in
screencast) screencast;;
audio) audio;;
video) video;;
*selected) videoselected;;
kill) killrecording;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
screencast) screencast ;;
audio) audio ;;
video) video ;;
*selected) videoselected ;;
kill) killrecording ;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;;
esac

View File

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

View File

@ -2,10 +2,8 @@
set -e
path="$1"
shift 1
while [[ $path != / ]];
do
while [[ $path != / ]]; do
find "$path" -maxdepth 1 -mindepth 1 "$@"
# Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
path="$(readlink -f "$path"/..)"
done

View File

@ -13,15 +13,19 @@ else
fi
case "$url" in
*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 & ;;
*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 ;;
*)
*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 &
;;
*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

View File

@ -9,11 +9,10 @@ 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} ;;
"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

View File

@ -7,7 +7,7 @@
basename="${1%.*}"
case "${*}" in
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid -f xdg-open "$basename".pdf >/dev/null 2>&1 ;;
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
*.tex | *.m[dse] | *.[rR]md | *.mom | *.[0-9]) setsid -f xdg-open "$basename".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

View File

@ -4,7 +4,7 @@
msgTag="volume"
# Change the volume using alsa(might differ if you use pulseaudio)
pamixer "$@" > /dev/null
pamixer "$@" >/dev/null
# Query amixer for the current volume and whether or not the speaker is muted
volume="$(pamixer --get-volume)"

View File

@ -6,5 +6,5 @@
# (with other things) by default and is used in some other places.
for i in $(ls /tmp/mpvSockets/*); do
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i";
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i"
done

View File

@ -5,4 +5,4 @@
# For example:
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray)" = "Yes" ] && $2

View File

@ -9,6 +9,6 @@ while read -r line; do
[ -z "$line" ] && continue
url="${line%%[ ]*}"
qndl "$url" "curl -LO"
done < "$queuefile"
done <"$queuefile"
echo > "$queuefile"
echo >"$queuefile"

View File

@ -6,22 +6,21 @@ index() {
if [ "$1" = "-n" ]; then
newgroup="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
elif [ "$1" = "" ];
then
elif [ "$1" = "" ]; then
groups="us:dvorak de:nodeadkeys"
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
i=1
while [ ! "$found" ]; do
group=$(index $i)
if [ "$group" = "$current" ]; then
newgroup=$(index $((i+1)))
newgroup=$(index $((i + 1)))
[ -z "$newgroup" ] && newgroup=$(index 1)
found=true
elif [ -z "$group" ]; then
newgroup=$(index 1)
found=true
fi
i=$((i+1))
i=$((i + 1))
done
else
newgroup="$1"
@ -29,7 +28,8 @@ fi
setxkbmap -layout "$(echo "$newgroup" | cut -d ':' -f1)" -variant "$(echo "$newgroup" | cut -d ':' -f2)" -option caps:super -option terminate:ctrl_alt_bksp 1>/dev/null 2>&1 || echo "Unkown keyboard layout"
xset r rate 300 50
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
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

@ -4,7 +4,8 @@ current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s
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'
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

@ -1,6 +1,6 @@
#!/bin/sh
if echo "$1" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ; then
if echo "$1" | grep -q "https*://\S\+\.[A-Za-z]\+\S*"; then
url="$1"
else
url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" |
@ -14,5 +14,5 @@ RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then
notify-send "You already have this RSS feed."
else
echo "$url" >> "$RSSFILE" && notify-send "RSS feed added."
echo "$url" >>"$RSSFILE" && notify-send "RSS feed added."
fi

View File

@ -11,7 +11,7 @@ for PID in $PIDlist; do
# zsh and lf won't be ignored even if it shows ~ or /
case "$cmdline" in
'lf -server') continue ;;
"${SHELL##*/}"|'lf'|'lf '*) break ;;
"${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

View File

@ -8,10 +8,13 @@
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
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." ; exit 1;;
esac
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."
exit 1
;;
esac
xwallpaper --zoom "$bgloc"

View File

@ -12,7 +12,7 @@ lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
# Remove, prepare files
rm -f "$shell_shortcuts" "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
printf "# vim: filetype=sh\\nalias " >"$shell_shortcuts"
# Format the `directories` file in the correct syntax and sent it to all three configs.
eval "echo \"$(cat "$bmdirs")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");

View File

@ -1,9 +1,9 @@
#!/bin/sh
vals=$(aptitude full-upgrade --simulate --assume-yes |\
grep -m1 '^[0-9]\+ packages upgraded,' |\
tr -cd '0-9 ' |\
tr ' ' '\n' |\
grep '[0-9]\+' |\
vals=$(aptitude full-upgrade --simulate --assume-yes |
grep -m1 '^[0-9]\+ packages upgraded,' |
tr -cd '0-9 ' |
tr ' ' '\n' |
grep '[0-9]\+' |
xargs echo)
print=" "

View File

@ -10,37 +10,60 @@ for battery in /sys/class/power_supply/BAT?*; do
[ -n "${capacity+x}" ] && printf " "
capacity="$(cat "$battery/capacity" 2>&1)"
case "$(cat "$battery/status" 2>&1)" in
"Full") icon=""; color="$green" ;;
"Charging") icon=""; color="$cyan" ;;
"Not charging") icon=""; color="$white" ;;
"Unknown") icon=""; color="$orange" ;;
"Full")
icon=""
color="$green"
;;
"Charging")
icon=""
color="$cyan"
;;
"Not charging")
icon=""
color="$white"
;;
"Unknown")
icon=""
color="$orange"
;;
"Discharging")
if [ "$capacity" -le 10 ]; then
icon=""; color="$red"
icon=""
color="$red"
elif [ "$capacity" -le 20 ]; then
icon=""; color="$red"
icon=""
color="$red"
elif [ "$capacity" -le 30 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 40 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 50 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 60 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 70 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 80 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 90 ]; then
icon=""; color="$white"
icon=""
color="$white"
elif [ "$capacity" -le 95 ]; then
icon=""; color="$white"
icon=""
color="$white"
else
icon=""; color="$white"
icon=""
color="$white"
fi
;;
*) exit 1 ;;
esac
printf "$color%s$reset %d" "$icon" "$capacity";
printf "$color%s$reset %d" "$icon" "$capacity"
done && printf "\\n"

View File

@ -1,7 +1,7 @@
#!/bin/sh
cache=/tmp/cpubarscache
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
[ ! -f $cache ] && echo "$stats" > "$cache"
[ ! -f $cache ] && echo "$stats" >"$cache"
old=$(cat "$cache")
printf "\033[11m﬙\033[10m "
echo "$stats" | while read -r row; do
@ -12,14 +12,15 @@ echo "$stats" | while read -r row; do
case "$(echo "$old" | awk '{if ($1 == id)
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle")" in
"0") printf "\033[32m▁";;
"1") printf "\033[32m▂";;
"2") printf "\033[32m▃";;
"3") printf "\033[33m▄";;
"4") printf "\033[33m▅";;
"5") printf "\033[33m▆";;
"6"|"7"|"8") printf "\033[31m▇";;
"0") printf "\033[32m▁" ;;
"1") printf "\033[32m▂" ;;
"2") printf "\033[32m▃" ;;
"3") printf "\033[33m▄" ;;
"4") printf "\033[33m▅" ;;
"5") printf "\033[33m▆" ;;
"6" | "7" | "8") printf "\033[31m▇" ;;
esac
done; printf "\033[0m\n"
echo "$stats" > "$cache"
done
printf "\033[0m\n"
echo "$stats" >"$cache"

View File

@ -12,7 +12,7 @@ url="wttr.in/Karlsruhe"
opt="?F"
emojiopt="?format=1"
convertemoji() {
sed -i '
sed -i '
s/☀️//
s/☁️//
s/⛅️//
@ -26,11 +26,11 @@ s/🌩//
s/🌫//
' "$emojifile"
}
getforecast() { curl -sf "$url$opt" > "$weatherfile" && curl -sf "$url$emojiopt" > "$emojifile" || exit 1 ;}
getforecast() { curl -sf "$url$opt" >"$weatherfile" && curl -sf "$url$emojiopt" >"$emojifile" || exit 1; }
showweather() {
emoji="$(printf "\033[12m%s\033[10m" "$(cut -d ' ' -f 1 "$emojifile")")"
sed '16q;d' "$weatherfile" | grep -wo "[0-9]*%" | sort -rn | sed "s/^/$emoji /g;1q" | tr -d '\n'
sed '13q;d' "$weatherfile" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " \033[34m\033[0m " $1 "°","\033[31m\033[0m " $2 "°"}';
sed '13q;d' "$weatherfile" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " \033[34m\033[0m " $1 "°","\033[31m\033[0m " $2 "°"}'
}
getforecast && convertemoji
showweather

View File

@ -1,7 +1,7 @@
#!/bin/sh
filter() {
if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then
song=$(mpc current -f "%artist% - %title%" | xargs -0 )
song=$(mpc current -f "%artist% - %title%" | xargs -0)
[ ${#song} -gt 35 ] && song="$(printf %.35s "$song")…"
mpc | awk 'NR==2' | grep -q playing && icon="" || icon=""
echo "$icon $song"

View File

@ -2,13 +2,13 @@
update() {
sum=0
for arg; do
read -r i < "$arg"
sum=$(( sum + i ))
read -r i <"$arg"
sum=$((sum + i))
done
cache=/tmp/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
printf %d\\n $(( sum - old ))
[ -f "$cache" ] && read -r old <"$cache" || old=0
printf %d\\n "$sum" >"$cache"
printf %d\\n $((sum - old))
}
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)

View File

@ -1,18 +1,21 @@
#!/bin/sh
# A dmenu wrapper script for system functions.
case "$(readlink -f /sbin/init)" in
*systemd*) ctl='systemctl' ;;
*) ctl='loginctl' ;;
*systemd*) ctl='systemctl' ;;
*) ctl='loginctl' ;;
esac
case "$(printf " lock\nﴚ leave dwm\n累 renew dwm\nﭦ hibernate\n sleep\nﰇ reboot\n襤 shutdown\n display off" | dmenu -i -p 'Action: ')" in
' lock') xset s activate & gpg-connect-agent --no-autostart reloadagent /bye;;
'ﴚ leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
'累 renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
' lock')
xset s activate &
gpg-connect-agent --no-autostart reloadagent /bye
;;
'ﴚ leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
'累 renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
# 'ﭦ hibernate') slock $ctl hibernate -i ;;
# ' sleep') slock $ctl suspend -i ;;
'ﰇ reboot') $ctl reboot ;;
'襤 shutdown') $ctl poweroff ;;
' display off') xset dpms force off ;;
*) exit 1 ;;
'ﰇ reboot') $ctl reboot ;;
'襤 shutdown') $ctl poweroff ;;
' display off') xset dpms force off ;;
*) exit 1 ;;
esac

View File

@ -4,12 +4,12 @@
# I have vim run this file whenever I exit a .tex file.
case "$1" in
*.tex)
*.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" ;;
*) printf "Give .tex file as argument.\\n" ;;
esac

View File

@ -8,19 +8,19 @@ getfsroot() {
filepath="$(realpath "$1")"
filename="$(basename "$1")"
fsroot="$(getfsroot "$1")"
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|| basedir="${fsroot}/.Trash"
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] &&
basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" ||
basedir="${fsroot}/.Trash"
infodir="$basedir/info"
filedir="$basedir/files"
mkdir -p "$infodir" 1>/dev/null 2>&1
mkdir -p "$filedir" 1>/dev/null 2>&1
find "$filedir" -regex ".*$filename.*" | grep -oP '(?<=.\.~)\d+(?=~$)' | sort -n | tail -1 | (
ext=$(($(cat /dev/stdin)+1))
filedest="$filedir/$filename.~$ext~"
command mv -f "$filepath" "$filedest"
cat <<EOF > "$infodir/$(basename "$filedest")"
ext=$(($(cat /dev/stdin) + 1))
filedest="$filedir/$filename.~$ext~"
command mv -f "$filepath" "$filedest"
cat <<EOF >"$infodir/$(basename "$filedest")"
[Trash Info]
Path=$filepath
DeletionDate=$(date +%Y%m%dT%T)

View File

@ -7,10 +7,10 @@ list() {
# 1st arg is trash files directory
# 2nd arg is directory to match trash files for
[ ! "$(ls -A "$1")" ] && exit 1
for file in "$1"/* ; do
[ "$(head -1 "$file")" = "[Trash Info]" ] && \
fpath=$(grep Path "$file" | cut -d '=' -f2) && \
echo "$fpath" | grep -qP "^$2/[^/]+$" && \
for file in "$1"/*; do
[ "$(head -1 "$file")" = "[Trash Info]" ] &&
fpath=$(grep Path "$file" | cut -d '=' -f2) &&
echo "$fpath" | grep -qP "^$2/[^/]+$" &&
printf "%s %s %s\n" \
"$(basename "$file")" \
"$fpath" \
@ -20,9 +20,9 @@ list() {
[ -n "$1" ] && dir="$(realpath "$1")" || dir="$(getfsroot "$PWD")"
fsroot="$(getfsroot "$dir")"
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|| basedir="${fsroot}/.Trash"
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] &&
basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" ||
basedir="${fsroot}/.Trash"
sel="$(list "$basedir/info" "$dir" | fzf)"
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"

View File

@ -4,11 +4,14 @@
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
echo "Enter the album/book title:"; read -r booktitle
echo "Enter the album/book title:"
read -r booktitle
echo "Enter the artist/author:"; read -r author
echo "Enter the artist/author:"
read -r author
echo "Enter the publication year:"; read -r year
echo "Enter the publication year:"
read -r year
inputaudio="$1"
@ -22,10 +25,9 @@ ext="opus"
#ext="${1#*.}"
# Get the total number of tracks from the number of lines.
total="$(wc -l < "$2")"
total="$(wc -l <"$2")"
while read -r x;
do
while read -r x; do
end="$(echo "$x" | cut -d' ' -f1)"
[ -n "$start" ] &&
@ -36,9 +38,9 @@ do
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
title="$(echo "$x" | cut -d' ' -f 2-)"
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
track="$((track+1))"
track="$((track + 1))"
start="$end"
done < "$2"
done <"$2"
# The last track must be done outside the loop.
echo "From $start to the end: $title"
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"

View File

@ -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:.*" -m 1) ||
doi=$(pdftotext "$1" - 2>/dev/null | grep -io "doi:.*" -m 1) ||
exit 1
else
doi="$1"

View File

@ -1,33 +1,35 @@
#!/usr/bin/sh
usage ()
{
usage() {
printf "Usage : noisereduce <input video file> <output video file>\n"
exit
}
# Tests for requirements
ifinstalled ffmpeg || { echo >&2 "We require 'ffmpeg' but it's not installed."; exit 1; }
ifinstalled sox || { echo >&2 "We require 'ffmpeg' but it's not installed."; exit 1; }
ifinstalled ffmpeg || {
echo >&2 "We require 'ffmpeg' but it's not installed."
exit 1
}
ifinstalled sox || {
echo >&2 "We require 'ffmpeg' but it's not installed."
exit 1
}
if [ "$#" -ne 2 ]
then
if [ "$#" -ne 2 ]; then
usage
fi
if [ ! -e "$1" ]
then
if [ ! -e "$1" ]; then
printf "File not found: %s\n" "$1"
exit
fi
if [ -e "$2" ]
then
if [ -e "$2" ]; then
printf "File %s already exists, overwrite? [y/N]\n: " "$2"
read -r yn
case $yn in
[Yy]* ) ;;
* ) exit;;
[Yy]*) ;;
*) exit ;;
esac
fi
@ -35,8 +37,7 @@ inBasename=$(basename "$1")
inExt="${inBasename##*.}"
isVideoStr=$(ffprobe -v warning -show_streams "$1" | grep codec_type=video)
if [ -n "$isVideoStr" ]
then
if [ -n "$isVideoStr" ]; then
isVideo=1
printf "Detected %s as a video file\n" "$inBasename"
else
@ -46,14 +47,13 @@ fi
printf "Sample noise start time [00:00:00]: "
read -r sampleStart
if [ -z "$sampleStart" ] ; then sampleStart="00:00:00"; fi
if [ -z "$sampleStart" ]; then sampleStart="00:00:00"; fi
printf "Sample noise end time [00:00:00.900]: "
read -r sampleEnd
if [ -z "$sampleEnd" ] ; then sampleEnd="00:00:00.900"; fi
if [ -z "$sampleEnd" ]; then sampleEnd="00:00:00.900"; fi
printf "Noise reduction amount [0.21]: "
read -r sensitivity
if [ -z "$sensitivity" ] ; then sensitivity="0.21"; fi
if [ -z "$sensitivity" ]; then sensitivity="0.21"; fi
tmpVidFile="/tmp/noiseclean_tmpvid.$inExt"
tmpAudFile="/tmp/noiseclean_tmpaud.wav"

View File

@ -13,10 +13,14 @@ ifinstalled pass pass-otp
dir="${PASSWORD_STORE_DIR}"
choice="$({ echo "🆕add" ; echo "🕙sync-time" ; ls ${dir}/*-otp.gpg ;} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")"
choice="$({
echo "🆕add"
echo "🕙sync-time"
ls ${dir}/*-otp.gpg
} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")"
case $choice in
🆕add )
🆕add)
ifinstalled maim zbar xclip || exit 1
temp="$dir/temp.png"
@ -32,7 +36,7 @@ case $choice in
name="${issuer#issuer=}"
if echo "$info" | pass otp insert "$otp"; then
while true ; do
while true; do
export name="$(prinf | dmenu -p "Give this One Time Password a one-word name:")"
echo "$name" | grep -q -- "^[A-z0-9-]\+$" && break
done
@ -43,11 +47,11 @@ case $choice in
fi
;;
🕙sync-time )
🕙sync-time)
ifinstalled ntp || exit 1
notify-send -u low "🕙 Synchronizing Time..." "Synching time with remote NTP servers..."
updatedata="$(sudo ntpdate pool.ntp.org)" &&
notify-send -u low "🕙 Synchronizing Time..." "Done. Time changed by ${updatedata#*offset }"
;;
*) pass otp -c ${choice}-otp ;;
*) pass otp -c ${choice}-otp ;;
esac

View File

@ -20,14 +20,18 @@ while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
r) redo="$OPTARG" ;;
s) ppt="$OPTARG" ;;
e) endtime="$OPTARG" ;;
x) res="$OPTARG"
x)
res="$OPTARG"
echo "$res" | grep -qv "^[0-9]\+x[0-9]\+$" &&
echo "Resolution must be dimensions separated by a 'x': 1280x720, etc." &&
exit 1 ;;
p) echo "Purge old build files in $cache? [y/N]"
exit 1
;;
p)
echo "Purge old build files in $cache? [y/N]"
read -r confirm
echo "$confirm" | grep -iq "^y$" && rm -rf "$cache" && echo "Done."
exit ;;
exit
;;
v) verbose=True ;;
*) echo "$(basename "$0") usage:
-i input timecode list (required)
@ -42,12 +46,12 @@ while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
-d tmp directory
-r rerun imagemagick commands even if done previously (in case files or background has changed)
-p purge old build files instead of running
-v be verbose" && exit 1
-v be verbose" && exit 1 ;;
esac done
esac done
# Check that the input file looks like it should.
{ head -n 1 "$file" 2>/dev/null | grep -q "^00:00:00 " ;} || {
{ head -n 1 "$file" 2>/dev/null | grep -q "^00:00:00 "; } || {
echo "Give an input file with -i." &&
echo "The file should look as this example:
@ -58,16 +62,19 @@ etc...
Timecodes and filenames must be separated by Tabs." &&
exit 1
}
}
if [ -n "${audio+x}" ]; then
# Check that the audio file looks like an actual audio file.
case "$(file --dereference --brief --mime-type -- "$audio")" in
audio/*) ;;
*) echo "That doesn't look like an audio file."; exit 1 ;;
*)
echo "That doesn't look like an audio file."
exit 1
;;
esac
totseconds="$(date '+%s' -d $(ffmpeg -i "$audio" 2>&1 | awk '/Duration/ {print $2}' | sed s/,//))"
endtime="$((totseconds-seconds))"
endtime="$((totseconds - seconds))"
fi
prepdir="${prepdir:-$cache/$file}"
@ -78,8 +85,7 @@ prepfile="$prepdir/$file.prep"
mkdir -p "$prepdir"
{
while read -r x;
do
while read -r x; do
# Get the time from the first column.
time="${x%% *}"
seconds="$(date '+%s' -d "$time")"
@ -94,10 +100,10 @@ do
if [ -f "$content" ]; then
# If images have already been made in a previous run, do not recreate
# them unless -r was given.
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ]; } &&
convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base"
else
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ]; } &&
convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -font "${font:-Sans}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
fi
@ -109,12 +115,12 @@ duration $duration"
prevbase="$base"
prevtime="$time"
prevseconds="$(date '+%s' -d "$prevtime")"
done < "$file"
# Do last file which must be given twice as follows
echo "file '$base'
done <"$file"
# Do last file which must be given twice as follows
echo "file '$base'
duration ${endtime:-5}
file '$base'"
} > "$prepfile"
} >"$prepfile"
if [ -n "${audio+x}" ]; then
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -i "$audio" -c:a aac -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
else

View File

@ -11,7 +11,7 @@ Options:
-d: year of publication
-g: genre
-c: comment
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
You will be prompted for title, artist, album and track if not given." && exit 1; }
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
a) artist="${OPTARG}" ;;
@ -24,7 +24,7 @@ while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
c) comment="${OPTARG}" ;;
f) file="${OPTARG}" ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
esac done
esac done
shift $((OPTIND - 1))
@ -38,7 +38,7 @@ file="$1"
[ -z "$track" ] && echo "Enter a track number." && read -r track
case "$file" in
*.ogg) echo "Title=$title
*.ogg) echo "Title=$title
Artist=$artist
Album=$album
Track=$track
@ -46,7 +46,7 @@ Total=$total
Date=$date
Genre=$genre
Comment=$comment" | vorbiscomment -w "$file" ;;
*.opus) echo "Title=$title
*.opus) echo "Title=$title
Artist=$artist
Album=$album
Track=$track
@ -54,8 +54,8 @@ Total=$total
Date=$date
Genre=$genre
Comment=$comment" | opustags -i -S "$file" ;;
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
*.flac) echo "TITLE=$title
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
*.flac) echo "TITLE=$title
ARTIST=$artist
ALBUM=$album
TRACKNUMBER=$track
@ -63,5 +63,5 @@ TOTALTRACKS=$total
DATE=$date
GENRE=$genre
DESCRIPTION=$comment" | metaflac --remove-all-tags --import-tags-from=- "$file" ;;
*) echo "File type not implemented yet." ;;
*) echo "File type not implemented yet." ;;
esac

View File

@ -35,4 +35,3 @@ json="$(jq -r --arg "$movie" "$thumbnail" ". + {\"$movie\": \"$thumbnail\"}" <"$
echo "$json" >"$index"
echo "$cache/$thumbnail"