mirror of
https://github.com/tiyn/dotfiles.git
synced 2025-10-09 19:11:15 +02:00
tools: restructured
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && (echo "Error: missing argument (what to remain)" && exit)
|
||||
for oldname in "$@"
|
||||
do
|
||||
newname=`echo "$oldname" | tr '[:upper:]' '[:lower:]' | sed 's/\ /_/g; s/Ö/oe/g; s/Ä/ae/g; s/Ü/ue/g; s/ö/oe/g; s/ä/ae/g; s/ü/ue/g; s/ß/ss/g'`;
|
||||
if [ "$oldname" != "$newname" ]; then
|
||||
if [ -f "$newname" ]; then
|
||||
echo "skipping $newname, because it already exists"
|
||||
rm "$oldname";
|
||||
else
|
||||
echo "renaming file $oldname to $newname"
|
||||
if [ -f "$oldname" ]; then
|
||||
echo "using mv"
|
||||
mv "$oldname" "$newname";
|
||||
elif [ -d "$oldname" ]; then
|
||||
if [ -e "$newname" ]; then
|
||||
echo "using cp"
|
||||
cp -r "$oldname/." "$newname" && rm -r "$oldname";
|
||||
else
|
||||
echo "using mv"
|
||||
mv "$oldname" "$newname";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
5
.local/bin/etc/dmenupass
Executable file
5
.local/bin/etc/dmenupass
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
dmenu -P -p "$1" <&- && echo
|
61
.local/bin/etc/dwm/dmenumount
Executable file
61
.local/bin/etc/dwm/dmenumount
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Gives a dmenu prompt to mount unmounted drives.
|
||||
# If they're in /etc/fstab, they'll be mounted automatically.
|
||||
# Otherwise, you'll be prompted to give a mountpoint from already existsing directories.
|
||||
# If you input a novel directory, it will prompt you to create that directory.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
getmount() { \
|
||||
[ -z "$chosen" ] && exit 1
|
||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")"
|
||||
[ "$mp" = "" ] && exit 1
|
||||
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
|
||||
}
|
||||
|
||||
mountusb() { \
|
||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
|
||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}')
|
||||
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;;
|
||||
*) 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."
|
||||
}
|
||||
|
||||
mountandroid() { \
|
||||
chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1)
|
||||
getmount "$HOME -maxdepth 3 -type d"
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in
|
||||
USB) mountusb ;;
|
||||
Android) mountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||
|
||||
if [ -z "$usbdrives" ]; then
|
||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||
echo "Android device(s) detected."
|
||||
mountandroid
|
||||
else
|
||||
if [ -z "$anddrives" ]; then
|
||||
echo "USB drive(s) detected."
|
||||
mountusb
|
||||
else
|
||||
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
43
.local/bin/etc/dwm/dmenuumount
Executable file
43
.local/bin/etc/dwm/dmenuumount
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu prompt to unmount drives.
|
||||
# Provides you with mounted partitions, select one to unmount.
|
||||
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
unmountusb() {
|
||||
[ -z "$drives" ] && exit
|
||||
chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
|
||||
[ -z "$chosen" ] && exit
|
||||
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?")
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in
|
||||
USB) unmountusb ;;
|
||||
Android) unmountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||
|
||||
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
|
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
## Toggle the state of the fnmode.
|
||||
## Useful for using keyboards with different fn functionality.
|
||||
|
||||
curr=$(cat /sys/module/hid_apple/parameters/fnmode)
|
||||
|
||||
if [ "$curr" = "1" ]
|
||||
then
|
||||
echo "0" | sudo tee -a /sys/module/hid_apple/parameters/fnmode > /dev/null
|
||||
elif [ "$curr" = "0" ]
|
||||
then
|
||||
echo "1" | sudo tee -a /sys/module/hid_apple/parameters/fnmode > /dev/null
|
||||
fi
|
16
.local/bin/etc/newsboat/dmenuhandler
Executable file
16
.local/bin/etc/newsboat/dmenuhandler
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Feed this script a link and it will give dmenu
|
||||
# some choice programs to use to open it.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
case "$(printf "copy url\\nmpv\\nmpv (loop)\\nqueue download\\n\\nqueue youtube-dl\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?")" in
|
||||
"copy url") echo "$1" | xclip -selection clipboard ;;
|
||||
mpv) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;;
|
||||
"mpv (loop)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet --loop "$1" >/dev/null 2>&1 & ;;
|
||||
"queue download") tsp curl -LO "$1" >/dev/null 2>&1 ;;
|
||||
"queue youtube-dl") tsp youtube-dl --write-metadata -ic "$1" >/dev/null 2>&1 ;;
|
||||
browser) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;;
|
||||
feh) setsid feh "$1" >/dev/null 2>&1 & ;;
|
||||
w3m) w3m "$1" >/dev/null 2>&1 ;;
|
||||
"mpv (float)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;;
|
||||
esac
|
23
.local/bin/etc/newsboat/linkhandler
Executable file
23
.local/bin/etc/newsboat/linkhandler
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Feed script a url or file location.
|
||||
# If an image, it will view in sxiv,
|
||||
# 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.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
# If no url given. Opens browser. For using script as $BROWSER.
|
||||
[ -z "$1" ] && { "$BROWSER"; exit; }
|
||||
|
||||
case "$1" in
|
||||
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
|
||||
setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;;
|
||||
*png|*jpg|*jpe|*jpeg|*gif)
|
||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
|
||||
*mp3|*flac|*opus|*mp3?source*)
|
||||
setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
|
||||
*)
|
||||
if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
|
||||
else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;;
|
||||
esac
|
6
.local/bin/etc/nvim/cclear
Executable file
6
.local/bin/etc/nvim/cclear
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -d .ccls-cache ]
|
||||
then
|
||||
rm -r '.ccls-cache'
|
||||
fi
|
46
.local/bin/etc/nvim/compiler
Executable file
46
.local/bin/etc/nvim/compiler
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env 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. Opens .sent files as sent
|
||||
# presentations. Runs scripts based on extention or shebang
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
base="${file%.*}"
|
||||
basenodir="${1%.*}"
|
||||
|
||||
cd "$dir" || exit
|
||||
|
||||
textype() { \
|
||||
command="pdflatex"
|
||||
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
grep -i addbibresource "$file" >/dev/null &&
|
||||
biber --input-directory "$dir" "$base" &&
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
makeglossaries "$basenodir" &&
|
||||
$command --output-directory="$dir" "$base"
|
||||
}
|
||||
|
||||
case "$file" in
|
||||
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
||||
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
|
||||
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
|
||||
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||||
*\.m) octave -qW "$file" ;;
|
||||
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||||
*config.h) sudo make install ;;
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.java) java "$file" ;;
|
||||
*\.js) node "$file" ;;
|
||||
*\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;;
|
||||
*\.nim) nim c -r -d:noColors "$file" ;;
|
||||
*\.py) python "$file" ;;
|
||||
*\.go) go run "$file" ;;
|
||||
*\.lua) lua "$file" ;;
|
||||
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||||
*\.r|*\.R) Rscript "$file" ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
esac
|
16
.local/bin/etc/nvim/texclear
Executable file
16
.local/bin/etc/nvim/texclear
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||
# I have vim run this file whenever I exit a .tex file.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
case "$1" in
|
||||
*.tex)
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
base="${file%.*}"
|
||||
if [ -f "$dir/indent.log" ]; then rm "$dir/indent.log"; fi
|
||||
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|loa|bcf|run\\.xml|synctex\\.gz|blg|bbl|glg|glo|gls|glsdefs|ilg|ist|acn|acr|alg|toc)" -delete ;
|
||||
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex ".*\\.aux" -delete ;;
|
||||
*) printf "Give .tex file as argument.\\n" ;;
|
||||
esac
|
9
.local/bin/etc/prompt
Executable file
9
.local/bin/etc/prompt
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu binary prompt script.
|
||||
# Gives a dmenu prompt labeled with $1 to perform command $2.
|
||||
# For example:
|
||||
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "$1" )" = "Yes" ] && $2
|
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Open a terminal window in the same directory as the currently active window.
|
||||
# Obtained from https://github.com/lukesmithxyz/voidrice
|
||||
|
||||
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
||||
PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
|
||||
cd "$(readlink /proc/"$PID"/cwd)" || return 1
|
||||
setsid "$TERMINAL"
|
3
.local/bin/etc/screen_capture/record_replay_save
Executable file
3
.local/bin/etc/screen_capture/record_replay_save
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
killall -SIGUSR1 gpu-screen-recorder && notify-send 'Screen record' 'Replay saved'
|
14
.local/bin/etc/screen_capture/record_replay_start
Executable file
14
.local/bin/etc/screen_capture/record_replay_start
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
window=$(xdotool getwindowfocus)
|
||||
fps=60
|
||||
audio_1="easyeffects_sink.monitor"
|
||||
audio_2="easyeffects_source"
|
||||
format="mp4"
|
||||
v_codec="h264"
|
||||
a_codec="opus"
|
||||
lenght=20
|
||||
output="$HOME/downloads"
|
||||
|
||||
gpu-screen-recorder -w $window -f $fps -a $audio_1 -a $audio_2 -c $format -k $v_codec -ac $a_codec -r $lenght -o $output &
|
||||
notify-send 'Screen record' 'Replay started'
|
13
.local/bin/etc/screen_capture/record_start
Executable file
13
.local/bin/etc/screen_capture/record_start
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
window=$(xdotool getwindowfocus)
|
||||
fps=30
|
||||
audio_1="easyeffects_sink.monitor"
|
||||
audio_2="easyeffects_source"
|
||||
format="mp4"
|
||||
v_codec="h264"
|
||||
a_codec="opus"
|
||||
output="$HOME/downloads/recording-$(date '+%Y-%m-%d_%H-%M-%S').$format"
|
||||
|
||||
gpu-screen-recorder -w $window -c $format -k $v_codec -ac $a_codec -f $fps -a $audio_1 -a $audio_2 -o $output &
|
||||
notify-send 'Screen record' 'Recording started'
|
3
.local/bin/etc/screen_capture/record_stop
Executable file
3
.local/bin/etc/screen_capture/record_stop
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
killall -SIGINT gpu-screen-recorder && notify-send 'Screen record' 'Recording stopped'
|
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
ssh_host=$(cat ~/.ssh/config | grep "Host " | sed "s/Host\ //g" | dmenu)
|
||||
|
||||
[[ -z ssh_host ]] || st -e ssh -t $ssh_host
|
35
.local/bin/etc/statusbar/battery
Executable file
35
.local/bin/etc/statusbar/battery
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
acpi=$(acpi -b)
|
||||
|
||||
if [ "$acpi" = "" ]; then
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
total=$(echo $acpi | sed 's/.*:\ //')
|
||||
|
||||
status="$(echo $total | cut -d',' -f1)"
|
||||
capacity="$(echo $total | cut -d',' -f2 | sed 's/%//')"
|
||||
|
||||
if [ "$status" = "Discharging" ] && [ $capacity -le 15 ] ; then
|
||||
notify-send -u critical "Battery" "Below 15%"
|
||||
fi
|
||||
|
||||
case "$status" in
|
||||
"Discharging")
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^";;
|
||||
"Not charging")
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^";;
|
||||
"Charging")
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^";;
|
||||
"Unknown")
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^";;
|
||||
"Full")
|
||||
icon="^b#282828^^c#dfdfdf^ ⚡ ^d^";;
|
||||
esac
|
||||
|
||||
capacity=$(echo "$capacity" | sed -e 's/$//')
|
||||
capacity=$(printf %3s $capacity | tr ' ' ' ')
|
||||
|
||||
echo "$icon $capacity%"
|
3
.local/bin/etc/statusbar/clock
Executable file
3
.local/bin/etc/statusbar/clock
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
date +"^b#282828^^c#dfdfdf^ ^d^ %d %b %H:%M"
|
15
.local/bin/etc/statusbar/cpu
Executable file
15
.local/bin/etc/statusbar/cpu
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
model=$(cat /proc/cpuinfo | grep "model name" | head -n1)
|
||||
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^"
|
||||
|
||||
if printf "$model " | grep -Fqe "AMD"; then
|
||||
temp=$(sensors | awk '/Tctl/ {print $2}')
|
||||
else
|
||||
temp=$(sensors | awk '/Package id 0/ {print $4}')
|
||||
fi
|
||||
|
||||
temp=$(printf %3s $(echo ${temp##*+} | sed "s/\..*//") | tr ' ' ' ')
|
||||
|
||||
echo "$icon $temp°C"
|
11
.local/bin/etc/statusbar/disk
Executable file
11
.local/bin/etc/statusbar/disk
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint
|
||||
|
||||
disk="/"
|
||||
[ ! -z "$1" ] && disk="$1"
|
||||
|
||||
icon="$disk"
|
||||
|
||||
printf "^b#282828^^c#dfdfdf^ ^d^ %s\n" "$(df -h "$disk" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
15
.local/bin/etc/statusbar/gpu
Executable file
15
.local/bin/etc/statusbar/gpu
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^"
|
||||
|
||||
temp=""
|
||||
|
||||
if command -v nvidia-smi > /dev/null; then
|
||||
temp=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader)
|
||||
temp=$(printf %3s $(echo ${temp##*+} | sed "s/\..*//") | tr ' ' ' ')
|
||||
else
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$icon $temp°C"
|
10
.local/bin/etc/statusbar/internet
Executable file
10
.local/bin/etc/statusbar/internet
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
wifipercent=" 0"
|
||||
|
||||
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="^c#ff0000^ ^d^"
|
||||
|
||||
[ ! -n "${wifiicon+var}" ] && wifiicon="^c#dfdfdf^ ^d^" && wifipercent=$(grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
|
||||
|
||||
wifipercent=$(printf %3s $wifipercent | tr ' ' ' ')
|
||||
echo "$(cat /sys/class/net/e*/operstate | sed "s/down/^b#282828^^c#ff0000^ /;s/up/^b#282828^^c#dfdfdf^ /")" "$wifiicon" "$wifipercent%"
|
6
.local/bin/etc/statusbar/memory
Executable file
6
.local/bin/etc/statusbar/memory
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
icon="^b#282828^^c#dfdfdf^ ^d^ "
|
||||
total=$(free -h | awk '/^Mem:/ {print $3/$2}')
|
||||
percent=$(printf %3s $(printf %-4s $total | tr ' ' '0' | cut -c1-4 | sed -e 's/\.//g' | sed -e 's/^0//g') | tr ' ' ' ')%
|
||||
echo "$icon$percent"
|
22
.local/bin/etc/statusbar/volume
Executable file
22
.local/bin/etc/statusbar/volume
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}' | sed -e 's/\.//g' | sed 's/^0*//')"
|
||||
|
||||
if [ "$vol" -eq "0" ]; then
|
||||
vol_info="^c#dfdfdf^ ^d^"
|
||||
elif [ "$vol" -gt "70" ]; then
|
||||
vol_info="^c#dfdfdf^ ^d^"
|
||||
else
|
||||
vol_info="^c#dfdfdf^ ^d^"
|
||||
fi
|
||||
|
||||
$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q '\[MUTED\]') && vol_info="^c#ff0000^ ^d^"
|
||||
|
||||
if wpctl get-volume @DEFAULT_SOURCE@ | grep -q '\[MUTED\]'; then
|
||||
mic="^b#282828^^c#ff0000^ "
|
||||
else
|
||||
mic="^b#282828^^c#dfdfdf^ "
|
||||
fi
|
||||
|
||||
vol=$(printf %3s $vol | tr ' ' ' ')
|
||||
printf "%s %s %s %s\\n" "$mic" "$vol_info" "$vol%"
|
30
.local/bin/etc/sxhkd/audio/lmc
Executable file
30
.local/bin/etc/sxhkd/audio/lmc
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A general audio interface for LARBS.
|
||||
# Based on a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
[ -z "$2" ] && num="5" || num="$2"
|
||||
|
||||
case "$1" in
|
||||
up) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%+ ;;
|
||||
down) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%- ;;
|
||||
deaf) wpctl set-mute @DEFAULT_SINK@ 1;;
|
||||
undeaf) wpctl set-mute @DEFAULT_SINK@ 0;;
|
||||
mute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1;;
|
||||
unmute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0;;
|
||||
*) cat << EOF
|
||||
lmc: cli music interface for pulse for those with divine intellect too
|
||||
grand to remember the pamixer commands.
|
||||
|
||||
Allowed options:
|
||||
up NUM Increase volume (5% default)
|
||||
down NUM Decrease volume (5% default)
|
||||
mute mute microphone
|
||||
unmute unmute microphone
|
||||
deaf deaf sound
|
||||
undeaf undeaf sound
|
||||
all else Print this message
|
||||
|
||||
EOF
|
||||
esac
|
||||
pkill -RTMIN+4 $STATUSBAR
|
BIN
.local/bin/etc/sxhkd/audio/mic_activated.wav
Normal file
BIN
.local/bin/etc/sxhkd/audio/mic_activated.wav
Normal file
Binary file not shown.
BIN
.local/bin/etc/sxhkd/audio/mic_muted.wav
Normal file
BIN
.local/bin/etc/sxhkd/audio/mic_muted.wav
Normal file
Binary file not shown.
10
.local/bin/etc/sxhkd/audio/mic_toggle
Executable file
10
.local/bin/etc/sxhkd/audio/mic_toggle
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
if amixer get Capture | tail -2 | grep -q '\[on\]'; then
|
||||
paplay ~/.local/bin/tools/audio/mic_muted.wav
|
||||
lmc mute
|
||||
lmc undeaf
|
||||
else
|
||||
lmc unmute
|
||||
lmc undeaf
|
||||
paplay ~/.local/bin/tools/audio/mic_activated.wav
|
||||
fi
|
BIN
.local/bin/etc/sxhkd/audio/sound_muted.wav
Normal file
BIN
.local/bin/etc/sxhkd/audio/sound_muted.wav
Normal file
Binary file not shown.
BIN
.local/bin/etc/sxhkd/audio/sound_resumed.wav
Normal file
BIN
.local/bin/etc/sxhkd/audio/sound_resumed.wav
Normal file
Binary file not shown.
10
.local/bin/etc/sxhkd/audio/sound_toggle
Executable file
10
.local/bin/etc/sxhkd/audio/sound_toggle
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
if amixer get Master | tail -2 | grep -q '\[on\]'; then
|
||||
notify-send -u low 'sxhkd' 'Sound muted\nMicrophone muted'
|
||||
lmc mute
|
||||
lmc deaf
|
||||
else
|
||||
lmc mute
|
||||
lmc undeaf
|
||||
paplay ~/.local/bin/tools/audio/sound_resumed.wav
|
||||
fi
|
18
.local/bin/etc/sxhkd/screenshotmenu
Executable file
18
.local/bin/etc/sxhkd/screenshotmenu
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires maim. It lets you choose the kind of screenshot to take,
|
||||
# including copying the image or even highlighting an area to copy.
|
||||
|
||||
output="$HOME/downloads/screenshot-$(date '+%Y-%m-%d_%H-%M-%S').png"
|
||||
xclip_img="xclip -sel clip -t image/png"
|
||||
xclip_txt="xclip -sel clip -t text/plain"
|
||||
|
||||
case "$(printf "a selected area\\na selected area (copy)\\ncurrent window\\ncurrent window (copy)\\nfull screen\\nfull screen (copy)\\ncolor picker (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
||||
"a selected area") maim -s $output ;;
|
||||
"a selected area (copy)") maim -s | ${xclip_img} ;;
|
||||
"current window") maim -i "$(xdotool getactivewindow)" $output ;;
|
||||
"current window (copy)") maim -i "$(xdotool getactivewindow)" | ${xclip_img} ;;
|
||||
"full screen") maim $output ;;
|
||||
"full screen (copy)") maim | ${xclip_img} ;;
|
||||
"color picker (copy)") xcolor |tr -d '\n' | ${xclip_txt} ;;
|
||||
esac
|
6
.local/bin/etc/sxiv/ifinstalled
Executable file
6
.local/bin/etc/sxiv/ifinstalled
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If $1 command is not available, error code and notify.
|
||||
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||||
|
||||
command -v "$1" >/dev/null || { notify-send "📦 $1" "must be installed for this function." && exit 1 ;}
|
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
# copying tex templates
|
||||
|
||||
latexdir=~/code/main/latextemplates/
|
||||
|
||||
[ -z "$2" ] && echo "missing argument: filename (no ending)" && return 1
|
||||
|
||||
articletemp=${latexdir}latex_article/article.tex
|
||||
beamertemp=${latexdir}latex_beamer/beamer.tex
|
||||
exercisetemp=${latexdir}latex_exercise_header/header.tex
|
||||
handouttemp=${latexdir}latex_handout/handout.tex
|
||||
|
||||
case "$1" in
|
||||
a*) cp "$articletemp" $2.tex ;;
|
||||
b*) cp "$beamertemp" $2.tex ;;
|
||||
e*) cp "$exercisetemp" $2.tex ;;
|
||||
h*) cp "$handouttemp" $2.tex ;;
|
||||
*) cat << EOF
|
||||
|
||||
Allowed options
|
||||
article NAME get article-template with given NAME
|
||||
beamer NAME get beamer-template with given NAME
|
||||
exercise NAME get exercise-template with given NAME
|
||||
handout NAME get handout-template with given NAME
|
||||
|
||||
All of these commands can be truncated,
|
||||
i.e. \`textemp a\` for \`textemp article`\.
|
||||
EOF
|
||||
esac
|
56
.local/bin/etc/vifm/vifmimg
Executable file
56
.local/bin/etc/vifm/vifmimg
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
|
||||
PCACHE="$HOME/.cache/vifm/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$PWD/$6")" | sha256sum)"
|
||||
export PCACHE="${PCACHE%% *}"
|
||||
|
||||
pclear() {
|
||||
printf '{"action": "remove", "identifier": "vifm-preview"}\n' > "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
image() {
|
||||
printf '{"action": "add", "identifier": "vifm-preview", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$2" "$3" "$4" "$5" "$6" > "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
main() {
|
||||
case "$1" in
|
||||
"clear")
|
||||
pclear "$@"
|
||||
;;
|
||||
"draw")
|
||||
FILE="$PWD/$6"
|
||||
image "$1" "$2" "$3" "$4" "$5" "$FILE"
|
||||
;;
|
||||
"video")
|
||||
[ ! -f "$PCACHE" ] && \
|
||||
ffmpegthumbnailer -i "$6" -o "${PCACHE}.jpg" -s 0 -q 5
|
||||
image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
|
||||
;;
|
||||
"epub")
|
||||
[ ! -f "$PCACHE" ] && \
|
||||
epub-thumbnailer "$6" "$PCACHE" 1024
|
||||
image "$1" "$2" "$3" "$4" "$5" "$PCACHE"
|
||||
;;
|
||||
"pdf")
|
||||
[ ! -f "${PCACHE}.jpg" ] && \
|
||||
pdftoppm -jpeg -f 1 -singlefile "$6" "$PCACHE"
|
||||
image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
|
||||
;;
|
||||
"djvu")
|
||||
[ ! -f "${PCACHE}.jpg" ] && \
|
||||
ddjvu -format=tiff -quality=90 -page=1 "$6" "$PCACHE.jpg"
|
||||
image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
|
||||
;;
|
||||
"audio")
|
||||
[ ! -f "${PCACHE}.jpg" ] && \
|
||||
ffmpeg -hide_banner -i "$6" "${PCACHE}.jpg" -y >/dev/null
|
||||
image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
|
||||
;;
|
||||
"font")
|
||||
[ ! -f "${PCACHE}.jpg" ] && \
|
||||
fontpreview -i "$6" -o "${PCACHE}.jpg"
|
||||
image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
}
|
||||
main "$@"
|
21
.local/bin/etc/vifm/vifmrun
Executable file
21
.local/bin/etc/vifm/vifmrun
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$(command -v vifm)" ]; then
|
||||
printf "vifm isn't installed on your system!\n"
|
||||
exit 1
|
||||
elif [ -z "$(command -v ueberzug)" ]; then
|
||||
exec vifm "$@"
|
||||
else
|
||||
cleanup() {
|
||||
exec 3>&-
|
||||
rm "$FIFO_UEBERZUG"
|
||||
}
|
||||
[ ! -d "$HOME/.cache/vifm" ] && mkdir -p "$HOME/.cache/vifm"
|
||||
export FIFO_UEBERZUG="$HOME/.cache/vifm/ueberzug-${$}"
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
|
||||
exec 3>"$FIFO_UEBERZUG"
|
||||
trap cleanup EXIT
|
||||
vifm "$@" 3>&-
|
||||
vifmimg clear
|
||||
fi
|
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
active=$(nmcli connection show --active | grep vpn | cut -d' ' -f1)
|
||||
[[ ! -z "$active" ]] && { prompt "disconnect from $active?" || exit 1; }
|
||||
[[ ! -z "$active" ]] && nmcli connection down $active
|
||||
conn=$(nmcli connection | grep vpn | cut -d' ' -f1 | dmenu)
|
||||
nmcli connection up $conn
|
Reference in New Issue
Block a user