diff options
| author | ivan-boikov <ik.boikov.public@protonmail.com> | 2023-11-25 15:34:34 +0100 |
|---|---|---|
| committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2023-11-25 15:34:34 +0100 |
| commit | 16aec06eb45aea4e9d5c127daab6ea281d88006d (patch) | |
| tree | 5ac52c36308a3e1cfc468c60d1d6c9aacba11ce0 /scripts/.local | |
| parent | 3fccdd9602a31a0722d6dc1dd4a046abf919eee4 (diff) | |
Scripts
Diffstat (limited to 'scripts/.local')
| -rwxr-xr-x | scripts/.local/bin/allow-screensaver | 1 | ||||
| -rwxr-xr-x | scripts/.local/bin/benchshell | 10 | ||||
| -rwxr-xr-x | scripts/.local/bin/dmnt | 16 | ||||
| -rwxr-xr-x | scripts/.local/bin/emailclient | 7 | ||||
| -rwxr-xr-x | scripts/.local/bin/forbid-screensaver | 1 | ||||
| -rwxr-xr-x | scripts/.local/bin/ilock | 97 | ||||
| -rwxr-xr-x | scripts/.local/bin/mailsync | 13 | ||||
| -rwxr-xr-x | scripts/.local/bin/protonmail-bridge | 19 | ||||
| -rwxr-xr-x | scripts/.local/bin/repeat | 1 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-cpubars | 7 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-cpufreq | 5 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-cputemp | 2 | ||||
| -rwxr-xr-x | scripts/.local/bin/tab-scale | 2 | ||||
| -rwxr-xr-x | scripts/.local/bin/to60fps | 3 |
14 files changed, 96 insertions, 88 deletions
diff --git a/scripts/.local/bin/allow-screensaver b/scripts/.local/bin/allow-screensaver index 0824816..6ad137f 100755 --- a/scripts/.local/bin/allow-screensaver +++ b/scripts/.local/bin/allow-screensaver @@ -1,5 +1,4 @@ #!/bin/sh -export DISPLAY=:0.0 xset s on xset s blank xset +dpms diff --git a/scripts/.local/bin/benchshell b/scripts/.local/bin/benchshell new file mode 100755 index 0000000..697089e --- /dev/null +++ b/scripts/.local/bin/benchshell @@ -0,0 +1,10 @@ +#!/bin/bash + +shell=${1:-sh} +steps=${2:-10000} + +echo "Starting '$shell' $steps times" + +# there's an external 'time' program and there's one in bash +# I won't pull a dep just for that, hence bash in shebang +time for i in $(seq 1 $steps); do $shell -c true; done diff --git a/scripts/.local/bin/dmnt b/scripts/.local/bin/dmnt index 1350023..7175b6e 100755 --- a/scripts/.local/bin/dmnt +++ b/scripts/.local/bin/dmnt @@ -90,8 +90,22 @@ case "$chosen" in echo "$mp" attemptmount "/dev/mapper/usb$num" || getmount - sudo -A mount -o uid="$(id -u)",gid="$(id -g)" "/dev/mapper/usb$num" "$mp" + + if [ "$(lsblk -n -ofstype /dev/mapper/usb$num)" == "btrfs" ]; then + # BTRFS can't list subvolumes of unmounted partitions + sudo -A mount -o ro "/dev/mapper/usb$num" "$mp" + subvol="$(sudo btrfs subvolume list $mp | cut -d' ' -f9 | $DMENU -i -p 'Which subvolume to mount')" + # "mount -o remount,rw" does not change the subvolume, so remount ourselves + sudo umount "$mp" + # default zstd:3 is fast enough even for solid-state drives and compression is OK + # autodefrag is broken in 5.16 kernel + sudo -A mount -o compress-force=zstd,autodefrag,subvol="$subvol" "/dev/mapper/usb$num" "$mp" + else + sudo -A mount -o uid="$(id -u)",gid="$(id -g)" "/dev/mapper/usb$num" "$mp" + fi + notify-send "🔓Decrypted drive Mounted." "$chosen decrypted and mounted to $mp." + ;; 📱*) diff --git a/scripts/.local/bin/emailclient b/scripts/.local/bin/emailclient new file mode 100755 index 0000000..23d2fce --- /dev/null +++ b/scripts/.local/bin/emailclient @@ -0,0 +1,7 @@ +#!/bin/sh + +for file in $XDG_CONFIG_HOME/mutt/accounts/*; do + title="mutt: $(grep "set my_email" $file | cut -d'=' -f2 | xargs)" + "$TERMINAL" -T "$title" mutt -F "$file" & +done + diff --git a/scripts/.local/bin/forbid-screensaver b/scripts/.local/bin/forbid-screensaver index 4ca55a6..f509cb9 100755 --- a/scripts/.local/bin/forbid-screensaver +++ b/scripts/.local/bin/forbid-screensaver @@ -1,5 +1,4 @@ #!/bin/sh -export DISPLAY=:0.0 xset s off xset s noblank xset -dpms diff --git a/scripts/.local/bin/ilock b/scripts/.local/bin/ilock index 6bf0a02..884ab34 100755 --- a/scripts/.local/bin/ilock +++ b/scripts/.local/bin/ilock @@ -1,63 +1,46 @@ #!/bin/sh -# flush passwords -if [ -n "$(which gnome-keyring-daemon)" ]; then - gnome-keyring-daemon -r -d >/dev/null -fi -if [ -n "$(which ssh-agent)" ]; then - ssh-agent -k >/dev/null -fi -if [ -n "$(which gpgconf)" ]; then - gpgconf --kill gpg-agent >/dev/null -fi - -# stop sounds -if [ -n "$(which playerctl)" ]; then - playerctl -a pause >/dev/null -fi -if [ -n "$(which mpc)" ]; then - mpc pause >/dev/null -fi +# assumption: the user is not an ADHD-riddled zoomer and does not use >1 mpv instance +# flush secrets +gnome-keyring-daemon -r -d +ssh-agent -k +gpgconf --kill gpg-agent -# generate fancy lock screen - -#icon_file="$HOME/.local/share/icons/lock.png" -#icon_scaled_file='/tmp/lock-icon.png' -#scr_png='/tmp/screen.png' -#scr_bmp='/tmp/screen.bmp' -#scr_gl_bmp="/tmp/sclock_g.bmp" -# -#(( $# )) && { icon=$1; } - -#rm "$scr_png" -#maim > "$scr_png" - -# pixelate -#convert "$scr_png" -scale 10% -scale 1000% "$scr_png" - -# heavy distortion -#convert "$scr_png" -resize 500x "$scr_png" -#convert -rotate -90 $scr_png $scr_bmp -#for a in {1,2,4,5,2} -#do -# # Glitch it with sox FROM: https://maryknize.com/blog/glitch_art_with_sox_imagemagick_and_vim/ -# sox -t ul -c 1 -r 48k $scr_bmp -t ul $scr_gl_bmp trim 0 90s : echo 0.2 0.3 $((a*3)) 0.7 -# # Rotate it by 90 degrees -# convert -scale $((100/(a)))% -scale $((100*(a)))% -rotate 90 $scr_gl_bmp $scr_bmp -#done -#convert -gamma 0.1 -gravity center -font "Liberation-Mono" \ -# -pointsize 200 -channel RGBA -fill '#bf616a' \ -# $scr_bmp $scr_png - -# add lock icon -# first, rescale to match half screen height -#resolutiony=$(xrandr | fgrep '*' | cut -d'x' -f2 | awk '{print $1}') -#locksizey=$(echo "$resolutiony / 2" | bc -l) -#convert "$icon_file" -resize x"$locksizey" "$icon_scaled_file" -# and add icon on top of screenshot -#convert "$scr_png" "$icon_scaled_file" -gravity center -composite -matte "$scr_png" - -#i3lock --nofork -u -i "$scr_png" +# stop sounds +playerctl_get_playing() { + for player in $(playerctl -l) + do + if [ "$(playerctl -p "$player" status)" = "Playing" ]; then + echo "$player" + fi + done +} +playerctl_playing="$(playerctl_get_playing)" +for player in $playerctl_playing; do + playerctl -p "$player" pause >/dev/null && echo "playerctl: pause" "$player" +done + +# playerctl for mpd requires mpd-mpris running = BLOAT +mpc_on="$(mpc | grep '\[playing\]')" +mpc pause >/dev/null && echo "mpc: pause" + +ismuted="$(pamixer --get-mute)" +pamixer --mute && echo "Sound server: mute" + + +echo "Locking..." slock + + +# continue if something was playing +for player in $playerctl_playing; do + playerctl -p "$player" play >/dev/null && echo "playerctl: play" "$player" +done +if [ -n "$mpc_on" ]; then + mpc play >/dev/null && echo "mpc: play" +fi +if [ "$ismuted" = "false" ]; then + pamixer --unmute && echo "Sound server: unmute" +fi diff --git a/scripts/.local/bin/mailsync b/scripts/.local/bin/mailsync new file mode 100755 index 0000000..cb00bb7 --- /dev/null +++ b/scripts/.local/bin/mailsync @@ -0,0 +1,13 @@ +#!/bin/sh + +MBSYNC=$(pgrep mbsync) + +if [ -n "$MBSYNC" ]; then + echo "Already running one instance of mbsync or notmuch. Exiting..." + exit 0 +fi + +mbsync -c "$XDG_CONFIG_HOME/mbsync/config" -a + +printf "%s " "Press enter to continue" +read diff --git a/scripts/.local/bin/protonmail-bridge b/scripts/.local/bin/protonmail-bridge deleted file mode 100755 index e45c0a1..0000000 --- a/scripts/.local/bin/protonmail-bridge +++ /dev/null @@ -1,19 +0,0 @@ -#!/sbin/openrc-run -# Copyright 2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 -# by ivan - -name="protonmail-bridge daemon" -description="" -command=/usr/bin/proton-mail-bridge -#command_args="${protonmail-bridge_args}" -command_args="--no-window --noninteractive" -command_user="protonmail:protonmail" -# protonmail-bridge does not daemonize itself -command_background=true -pidfile=/run/protonmail-bridge.pid - -depend() { - need net - use dns -} diff --git a/scripts/.local/bin/repeat b/scripts/.local/bin/repeat new file mode 100755 index 0000000..371121a --- /dev/null +++ b/scripts/.local/bin/repeat @@ -0,0 +1 @@ +for i in $(seq 1 $2); do $1; done diff --git a/scripts/.local/bin/sb-cpubars b/scripts/.local/bin/sb-cpubars index 946f9ef..64cf8b0 100755 --- a/scripts/.local/bin/sb-cpubars +++ b/scripts/.local/bin/sb-cpubars @@ -1,12 +1,7 @@ #!/bin/sh -# Module showing CPU load as a changing bars. -# Just like in polybar. -# Each bar represents amount of load on one core since -# last run. - # Cache in tmpfs to improve speed and reduce SSD load -cache=/tmp/cpubarscache +cache="$XDG_CACHE_HOME/cpubarscache" # id total idle stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) diff --git a/scripts/.local/bin/sb-cpufreq b/scripts/.local/bin/sb-cpufreq new file mode 100755 index 0000000..820e366 --- /dev/null +++ b/scripts/.local/bin/sb-cpufreq @@ -0,0 +1,5 @@ +#!/bin/sh + +# based on https://github.com/Orienfish/RPi_Useful_Script/blob/master/get_cpu_freq.sh + +awk -F " " '{ total += $1; count++ } END { printf "%.1f\n", total/count/1e6 }' /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq diff --git a/scripts/.local/bin/sb-cputemp b/scripts/.local/bin/sb-cputemp index 4594826..03d7f89 100755 --- a/scripts/.local/bin/sb-cputemp +++ b/scripts/.local/bin/sb-cputemp @@ -1,3 +1,3 @@ #!/bin/sh -sensors | awk '/CPU:/ {print $2}' | sed 's/....$//' +sensors | awk '/^CPU/ {print $2}' | sed 's/....$//' diff --git a/scripts/.local/bin/tab-scale b/scripts/.local/bin/tab-scale index e5a1a4d..7ae1aad 100755 --- a/scripts/.local/bin/tab-scale +++ b/scripts/.local/bin/tab-scale @@ -49,7 +49,7 @@ xsetwacom --set "${stylus}" button 3 3 # map tablet buttons -pad=$(xsetwacom list | grep pad | cut -f 1 | xargs) +pad=$(xsetwacom list | grep 'Pad pad' | cut -f 1 | xargs) xsetwacom --set "$pad" Button 1 "key +shift +alt p -alt -shift" xsetwacom --set "$pad" Button 2 "key +shift +alt a -alt -shift" diff --git a/scripts/.local/bin/to60fps b/scripts/.local/bin/to60fps index 928a609..c43264c 100755 --- a/scripts/.local/bin/to60fps +++ b/scripts/.local/bin/to60fps @@ -20,7 +20,8 @@ echo "Input file extension:" $ifext echo "Temporary full filename:" $tffname echo "Output full filename:" $offname -vsscript="$HOME/.local/share/SVP4/scripts/$(ls $HOME/.local/share/SVP4/scripts)" +#vsscript="$HOME/.local/share/SVP4/scripts/$(ls $HOME/.local/share/SVP4/scripts)" +vsscript="$HOME/.local/share/SVP4/scripts/ffff.py" # --vf=vapoursynth=$(echo $HOME)/.local/share/SVP4/scripts/ffff.py \ mpv \ |
