Author: Adam Evyčędo <git@apiote.xyz>
move more scripts to functions
.config/luakit/userconf.lua | 2 .config/sh/functions | 455 +++++++++++++++++++++++++++++++++++++ .config/sway/config | 68 ++-- .config/sway/sway_startup.sh | 3 .local/bin/bar_bluetooth | 21 - .local/bin/battery_notify | 35 -- .local/bin/drank | 59 ---- .local/bin/drunk | 1 .local/bin/filemanager | 169 -------------- .local/bin/gmi | 4 .local/bin/installed | 67 ----- .local/bin/kbdBacklight | 20 - .local/bin/lock_listen | 16 - .local/bin/mpv | 30 -- .local/bin/update-git | 122 ---------- .local/bin/whistle | 55 ---- .local/bin/workspace | 14 -
diff --git a/.config/luakit/userconf.lua b/.config/luakit/userconf.lua index 6d25b22d44451de9ba0affbeb72a5d5a16cabeaf..60dad5445aed4676cfa721d5c7a8364a1d141043 100644 --- a/.config/luakit/userconf.lua +++ b/.config/luakit/userconf.lua @@ -56,7 +56,7 @@ luakit.spawn(string.format("%s %q", "transmission-gtk", uri)) return false end if string.match(string.lower(uri), "^gemini://") then - _, stdout, _ = luakit.spawn_sync(string.format("/home/adam/.local/bin/gmi %q", uri)) + _, stdout, _ = luakit.spawn_sync(string.format("/home/adam/.local/bin/fun gmi %q", uri)) view:load_string(stdout, uri) return false end diff --git a/.config/sh/functions b/.config/sh/functions index 596f291e961a04c32faaf15cda42b82902ce61f4..fea6f2ce361a2dc8faa3276935d849f327b59ec1 100644 --- a/.config/sh/functions +++ b/.config/sh/functions @@ -479,7 +479,7 @@ bar_all_once() { ~/.local/bin/bar_clock ~/.local/bin/bar_battery -1 ~/.local/bin/bar_network -1 - ~/.local/bin/bar_bluetooth + bar_bluetooth } bt() { @@ -891,3 +891,456 @@ cd "$oldPath" || exit 1 mv /tmp/photosResult/Result.zip . rm -rf /tmp/photosOne /tmp/photosTwo /tmp/photosResult } + +filemeanager() { + export LF_ICONS="\ + tw=:\ + st=:\ + ow=:\ + dt=:\ + di=:\ + fi=:\ + ln=:\ + or=:\ + ex=:\ + *.c=:\ + *.cc=:\ + *.clj=:\ + *.coffee=:\ + *.cpp=:\ + *.css=:\ + *.d=:\ + *.dart=:\ + *.erl=:\ + *.exs=:\ + *.fs=:\ + *.go=:\ + *.h=:\ + *.hh=:\ + *.hpp=:\ + *.hs=:\ + *.html=:\ + *.java=:\ + *.jl=:\ + *.js=:\ + *.json=:\ + *.lua=:\ + *.md=:\ + *.php=:\ + *.pl=:\ + *.pro=:\ + *.py=:\ + *.rb=:\ + *.rs=:\ + *.scala=:\ + *.ts=:\ + *.vim=:\ + *.cmd=:\ + *.ps1=:\ + *.sh=:\ + *.bash=:\ + *.zsh=:\ + *.fish=:\ + *.tar=:\ + *.tgz=:\ + *.arc=:\ + *.arj=:\ + *.taz=:\ + *.lha=:\ + *.lz4=:\ + *.lzh=:\ + *.lzma=:\ + *.tlz=:\ + *.txz=:\ + *.tzo=:\ + *.t7z=:\ + *.zip=:\ + *.z=:\ + *.dz=:\ + *.gz=:\ + *.lrz=:\ + *.lz=:\ + *.lzo=:\ + *.xz=:\ + *.zst=:\ + *.tzst=:\ + *.bz2=:\ + *.bz=:\ + *.tbz=:\ + *.tbz2=:\ + *.tz=:\ + *.deb=:\ + *.rpm=:\ + *.jar=:\ + *.war=:\ + *.ear=:\ + *.sar=:\ + *.rar=:\ + *.alz=:\ + *.ace=:\ + *.zoo=:\ + *.cpio=:\ + *.7z=:\ + *.rz=:\ + *.cab=:\ + *.wim=:\ + *.swm=:\ + *.dwm=:\ + *.esd=:\ + *.avif=:\ + *.webp=:\ + *.jpg=:\ + *.jpeg=:\ + *.mjpg=:\ + *.mjpeg=:\ + *.gif=:\ + *.bmp=:\ + *.pbm=:\ + *.pgm=:\ + *.ppm=:\ + *.tga=:\ + *.xbm=:\ + *.xpm=:\ + *.tif=:\ + *.tiff=:\ + *.png=:\ + *.svg=:\ + *.svgz=:\ + *.mng=:\ + *.pcx=:\ + *.mov=:\ + *.mpg=:\ + *.mpeg=:\ + *.m2v=:\ + *.mkv=:\ + *.webm=:\ + *.ogm=:\ + *.mp4=:\ + *.m4v=:\ + *.mp4v=:\ + *.vob=:\ + *.qt=:\ + *.nuv=:\ + *.wmv=:\ + *.asf=:\ + *.rm=:\ + *.rmvb=:\ + *.flc=:\ + *.avi=:\ + *.fli=:\ + *.flv=:\ + *.gl=:\ + *.dl=:\ + *.xcf=:\ + *.xwd=:\ + *.yuv=:\ + *.cgm=:\ + *.emf=:\ + *.ogv=:\ + *.ogx=:\ + *.aac=:\ + *.au=:\ + *.flac=:\ + *.m4a=:\ + *.mid=:\ + *.midi=:\ + *.mka=:\ + *.mp3=:\ + *.mpc=:\ + *.ogg=:\ + *.ra=:\ + *.wav=:\ + *.oga=:\ + *.opus=:\ + *.spx=:\ + *.xspf=:\ + *.pdf=:\ + *.nix=:\ + " + + lf +} + +update_git() { + set -e + + pkgs="$1" + if [ "$pkgs" = '' ] + then + echo package not specified + exit 1 + fi + if [ "$pkgs" = 'all' ] + then + pkgs='libasciidoc glider' + fi + + # TODO git clone if not exists + cd ~/Code/dwd + for pkg in $pkgs + do + case "$pkg" in + 'glider') + cd ./glider + git checkout master + git reset --hard HEAD + cat <<END >features.patch + diff --git a/feature.go b/feature.go + index 21b49fc..68aaf6b 100644 + --- a/feature.go + +++ b/feature.go + @@ -5,23 +5,23 @@ import ( + // _ "github.com/nadoo/glider/service/xxx" + + // comment out the protocols you don't need to make the compiled binary smaller. + - _ "github.com/nadoo/glider/proxy/http" + - _ "github.com/nadoo/glider/proxy/kcp" + - _ "github.com/nadoo/glider/proxy/mixed" + - _ "github.com/nadoo/glider/proxy/obfs" + - _ "github.com/nadoo/glider/proxy/pxyproto" + - _ "github.com/nadoo/glider/proxy/reject" + - _ "github.com/nadoo/glider/proxy/smux" + - _ "github.com/nadoo/glider/proxy/socks4" + + // _ "github.com/nadoo/glider/proxy/http" + + // _ "github.com/nadoo/glider/proxy/kcp" + + // _ "github.com/nadoo/glider/proxy/mixed" + + // _ "github.com/nadoo/glider/proxy/obfs" + + // _ "github.com/nadoo/glider/proxy/pxyproto" + + // _ "github.com/nadoo/glider/proxy/reject" + + // _ "github.com/nadoo/glider/proxy/smux" + + // _ "github.com/nadoo/glider/proxy/socks4" + _ "github.com/nadoo/glider/proxy/socks5" + - _ "github.com/nadoo/glider/proxy/ss" + - _ "github.com/nadoo/glider/proxy/ssh" + - _ "github.com/nadoo/glider/proxy/ssr" + - _ "github.com/nadoo/glider/proxy/tcp" + + // _ "github.com/nadoo/glider/proxy/ss" + + // _ "github.com/nadoo/glider/proxy/ssh" + + // _ "github.com/nadoo/glider/proxy/ssr" + + // _ "github.com/nadoo/glider/proxy/tcp" + _ "github.com/nadoo/glider/proxy/tls" + - _ "github.com/nadoo/glider/proxy/trojan" + - _ "github.com/nadoo/glider/proxy/udp" + - _ "github.com/nadoo/glider/proxy/vless" + - _ "github.com/nadoo/glider/proxy/vmess" + + // _ "github.com/nadoo/glider/proxy/trojan" + + // _ "github.com/nadoo/glider/proxy/udp" + + // _ "github.com/nadoo/glider/proxy/vless" + + // _ "github.com/nadoo/glider/proxy/vmess" + _ "github.com/nadoo/glider/proxy/ws" + ) + diff --git a/feature_linux.go b/feature_linux.go + index bbe2eff..1866395 100644 + --- a/feature_linux.go + +++ b/feature_linux.go + @@ -1,12 +1,12 @@ + package main + + import ( + - // comment out the services you don't need to make the compiled binary smaller. + - _ "github.com/nadoo/glider/service/dhcpd" + +// comment out the services you don't need to make the compiled binary smaller. + +// _ "github.com/nadoo/glider/service/dhcpd" + + - // comment out the protocols you don't need to make the compiled binary smaller. + - _ "github.com/nadoo/glider/proxy/redir" + - _ "github.com/nadoo/glider/proxy/tproxy" + - _ "github.com/nadoo/glider/proxy/unix" + - _ "github.com/nadoo/glider/proxy/vsock" + +// comment out the protocols you don't need to make the compiled binary smaller. + +// _ "github.com/nadoo/glider/proxy/redir" + +// _ "github.com/nadoo/glider/proxy/tproxy" + +// _ "github.com/nadoo/glider/proxy/unix" + +// _ "github.com/nadoo/glider/proxy/vsock" + ) +END + + git apply features.patch + go build -v -ldflags "-s -w" + ;; + 'doh') + cd ./dns-over-https/ + git checkout master + git reset --hard HEAD + git pull + /usr/bin/make binary + # doas sv stop doh + # doas cp doh-client/doh-client /usr/local/bin/ + # doas chmod 755 /usr/local/bin/doh-client + # doas sv start doh + /usr/bin/make clean + cd ../ + ;; + 'libasciidoc') + cd ./libasciidoc/ + git checkout master + git reset --hard HEAD + git pull + # export PATH="$HOME/.go/bin/:$PATH" + /usr/bin/make build + # doas cp ./bin/libasciidoc /usr/local/bin/asciidoc + # doas chmod 755 /usr/local/bin/asciidoc + cd ../ + ;; + esac + done +} + +mpv() { + has_sway=$(command -v swaymsg) + touch /tmp/mpv_count + mpv_count=$(cat /tmp/mpv_count) + echo $(( ${mpv_count:-0} + 1 )) > /tmp/mpv_count + + if [ "$has_sway" ] + then + case "$*" in + *--no-video*) ;; + *--profile=mpa*) ;; + *) swaymsg bar mode hide + esac + fi + + /usr/bin/mpv "$@" + + touch /tmp/mpv_count + mpv_count=$(cat /tmp/mpv_count) + mpv_count=$(( ${mpv_count:-0} - 1 )) + echo $mpv_count > /tmp/mpv_count + + if [ "$has_sway" ] && [ "$mpv_count" -eq 0 ] + then + swaymsg bar mode overlay + bar_all_once + fi +} + +kbdBacklight() { + if [ "$#" -lt 1 ] + then + printf "usage: %s (+|-)\n" "$(basename "$0")" + exit 1 + elif [ "$1" = "+" ] + then + light -s sysfs/leds/samsung::kbd_backlight -A 25 + elif [ "$1" = '-' ] + then + light -s sysfs/leds/samsung::kbd_backlight -U 25 + else + printf "usage: %s (+|-)\n" "$(basename "$0")" + exit 1 + fi + + light -s sysfs/leds/samsung::kbd_backlight -G | cut -d'.' -f1 > /tmp/wob.sock + sleep 1 + printf '' > /tmp/wob.sock +} + +waterInit() { + mkdir -p "$HOME/.local/state/water" + + if [ ! -f "$HOME/.local/state/water/water.db" ] + then + sqlite3 "$HOME/.local/state/water/water.db" "create table devices (device_id text, device_type text)" + meID=$(uuidgen -r) + sqlite3 "$HOME/.local/state/water/water.db" "insert into devices values('$meID', 'me')" + sqlite3 "$HOME/.local/state/water/water.db" "create table intakes (date text, time text, amount int, drink text, device_id text)" + fi +} + +drunk() { + waterInit + + if [ -z "$1" ] + then + today=$(date '+%Y%m%d') + else + today="$1" + fi + sqlite3 "$HOME/.local/state/water/water.db" -noheader "select amount, drink, time from devices join intakes using(device_id) where device_type = 'me' and date = '$today'" 2>/dev/null + +} + +drank() { + waterInit + + if [ -z "$1" ] || [ -z "$2" ] + then + echo 'usage drank <amount> <drink> [time]' + exit 1 + fi + if echo "$1" | grep -Eq '^[0-9]+ml$' + then + amount=$(echo "$1" | grep -Eq '^[0-9]+') + elif echo "$1" | grep -Eq '^[0-9.]+$' + then + amount=$(echo "$1" | grep -E '^([0-9]+(\.[0-9]+)?)|(\.[0-9]+)$' -o) + amount=$(echo "$amount * 1000" | bc) + else + case "$1" in + glass) amount=100 ;; + cup) amount=250 ;; + Cup) amount=300 ;; + can) amount=300 ;; + mug) amount=400 ;; + Mug) amount=500 ;; + bottle) amount=700 ;; + esac + fi + if [ -z "$3" ] + then + date=$(date '+%Y%m%d') + time=$(date '+%H%M%S') + else + date=$(echo "$3" | cut -c -8) + time="$(echo "$3" | cut -c 9-12)00" + fi + meID=$(sqlite3 "$HOME/.local/state/water/water.db" -noheader "select device_id from devices where device_type = 'me'" 2>/dev/null) + sqlite3 "$HOME/.local/state/water/water.db" "insert into intakes values('$date', '$time', $amount, '$2', '$meID')" 2>/dev/null + echo "ok, drank ${amount} ml $2" +} + +lock_listen() { + inotifywait -m -e delete /dev/ --format '%f' 2>/dev/null | while read -r dev + do + if [ "$dev" = 'solokey' ] + then + serials=$(lsusb -d 0x0483:0xa2ca -v 2>/dev/null | grep Serial | tr -s ' ' | cut -d ' ' -f 4) + for serial in $serials + do + if [ "$serial" = '208937A0324B' ] || [ "$serial" = '20833771324B' ] + then + continue + fi + done + pgrep swaylock >/dev/null 2>&1 || swaylock -f + fi + done +} + +gmi() { + gemget -o - "$1" | ~/Code/dwd/gmitohtml/gmitohtml -hostname "$1" +} + +render_bar_bluetooth() { + if bluetoothctl info | grep -E '(Connected)' | grep -q 'yes' >/dev/null 2>&1 + then + printf "<span color='#00afff'>█</span>" + elif bluetoothctl show | grep Powered | grep -q 'yes' >/dev/null 2>&1 + then + printf "<span color='#00afff'>░</span>" + else + printf '' + fi +} + + +bar_bluetooth() { + mpv_count=$(cat /tmp/mpv_count 2>/dev/null) + mpv_count=${mpv_count:-0} + + if [ -e /tmp/swaybar/pipe ] && [ "$mpv_count" -eq 0 ] + then + printf "bluetooth|%s\n" "$(render_bar_bluetooth)" >/tmp/swaybar/pipe + fi +} \ No newline at end of file diff --git a/.config/sway/config b/.config/sway/config index fd883ec17a712e218bcb961c552ca9f3bd8e334c..19852044afd652cf761a33e28d204bc60e62274f 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -46,16 +46,16 @@ bindsym $mod+Ctrl+t split v, layout tabbed; bindsym $mod+Ctrl+space floating toggle -bindsym $mod+exclam exec sh -c '. ~/.config/sh/functions; ws 1' -bindsym $mod+at exec sh -c '. ~/.config/sh/functions; ws 2' -bindsym $mod+numbersign exec sh -c '. ~/.config/sh/functions; ws 3' -bindsym $mod+dollar exec sh -c '. ~/.config/sh/functions; ws 4' -bindsym $mod+percent exec sh -c '. ~/.config/sh/functions; ws 5' -bindsym $mod+asciicircum exec sh -c '. ~/.config/sh/functions; ws 6' -bindsym $mod+ampersand exec sh -c '. ~/.config/sh/functions; ws 7' -bindsym $mod+asterisk exec sh -c '. ~/.config/sh/functions; ws 8' -bindsym $mod+parenleft exec sh -c '. ~/.config/sh/functions; ws 9' -bindsym $mod+parenright exec sh -c '. ~/.config/sh/functions; ws 10' +bindsym $mod+exclam exec fun ws 1 +bindsym $mod+at exec fun ws 2 +bindsym $mod+numbersign exec fun ws 3 +bindsym $mod+dollar exec fun ws 4 +bindsym $mod+percent exec fun ws 5 +bindsym $mod+asciicircum exec fun ws 6 +bindsym $mod+ampersand exec fun ws 7 +bindsym $mod+asterisk exec fun ws 8 +bindsym $mod+parenleft exec fun ws 9 +bindsym $mod+parenright exec fun ws 10 bindsym $mod+left workspace prev bindsym $mod+right workspace next @@ -72,19 +72,19 @@ bindsym $mod+Shift+parenleft move window to workspace 9 bindsym $mod+Shift+parenright move window to workspace 10 bindsym $mod+Ctrl+Return exec wezterm -bindsym $mod+f exec exec sh -c '. ~/.config/sh/functions; luakit' +bindsym $mod+f exec exec fun luakit bindsym $mod+Shift+f exec qutebrowser -bindsym $mod+e exec wezterm start -- ~/.local/bin/filemanager +bindsym $mod+e exec wezterm start -- fun filemanager bindsym $mod+Ctrl+r reload bindsym $mod+Ctrl+e exit -bindsym XF86AudioRaiseVolume exec sh -c '. ~/.config/sh/functions; volume +' -bindsym XF86AudioLowerVolume exec sh -c '. ~/.config/sh/functions; volume -' -bindsym XF86AudioMute exec sh -c '. ~/.config/sh/functions; volume t' -bindsym $mod+F8 exec sh -c '. ~/.config/sh/functions; volume +' -bindsym $mod+F7 exec sh -c '. ~/.config/sh/functions; volume -' -bindsym $mod+F6 exec sh -c '. ~/.config/sh/functions; volume t' +bindsym XF86AudioRaiseVolume exec fun volume + +bindsym XF86AudioLowerVolume exec fun volume - +bindsym XF86AudioMute exec fun volume t +bindsym $mod+F8 exec fun volume + +bindsym $mod+F7 exec fun volume - +bindsym $mod+F6 exec fun volume t bindsym XF86AudioPrev exec playerctl -p $(playerctl -l | tail -n1) previous bindsym $mod+p exec playerctl -p $(playerctl -l | tail -n1) previous @@ -93,28 +93,28 @@ bindsym $mod+space exec playerctl -p $(playerctl -l | tail -n1) play-pause bindsym XF86AudioNext exec playerctl -p $(playerctl -l | tail -n1) next bindsym $mod+n exec playerctl -p $(playerctl -l | tail -n1) next -bindsym --locked XF86MonBrightnessUp exec sh -c '. ~/.config/sh/functions; backlight +' -bindsym --locked XF86MonBrightnessDown exec sh -c '. ~/.config/sh/functions; backlight -' -bindsym --locked $mod+F3 exec sh -c '. ~/.config/sh/functions; backlight +' -bindsym --locked $mod+F2 exec sh -c '. ~/.config/sh/functions; backlight -' +bindsym --locked XF86MonBrightnessUp exec fun backlight + +bindsym --locked XF86MonBrightnessDown exec fun backlight - +bindsym --locked $mod+F3 exec fun backlight + +bindsym --locked $mod+F2 exec fun backlight - -bindsym --locked XF86KbdBrightnessUp exec ~/.local/bin/kbdBacklight + -bindsym --locked XF86KbdBrightnessDown exec ~/.local/bin/kbdBacklight - -bindsym --locked $mod+F10 exec ~/.local/bin/kbdBacklight + -bindsym --locked $mod+F9 exec ~/.local/bin/kbdBacklight - +bindsym --locked XF86KbdBrightnessUp exec fun kbdBacklight + +bindsym --locked XF86KbdBrightnessDown exec fun kbdBacklight - +bindsym --locked $mod+F10 exec fun kbdBacklight + +bindsym --locked $mod+F9 exec fun kbdBacklight - -bindsym XF86WLAN exec sh -c '. ~/.config/sh/functions; toggle_wifi' -bindsym $mod+F12 exec sh -c '. ~/.config/sh/functions; toggle_wifi' -bindsym --locked XF86Launch3 exec sh -c '. ~/.config/sh/functions; backlight t' +bindsym XF86WLAN exec fun toggle_wifi +bindsym $mod+F12 exec fun toggle_wifi +bindsym --locked XF86Launch3 exec fun backlight t # todo bindsym XF86Display exec ~/Code/Scripts/changeDisplay # todo bindsym $mod+F4 exec ~/Code/Scripts/changeDisplay bindsym $mod+Ctrl+l exec swaylock -bindsym $mod+F11 exec sh -c '. ~/.config/sh/functions; screenshot_area' -bindsym Shift+F11 exec sh -c '. ~/.config/sh/functions; screenshot_this_window' -bindsym Ctrl+F11 exec sh -c '. ~/.config/sh/functions; screenshot_all' -bindsym Alt+F11 exec sh -c '. ~/.config/sh/functions; screenshot_window' +bindsym $mod+F11 exec fun screenshot_area +bindsym Shift+F11 exec fun screenshot_this_window +bindsym Ctrl+F11 exec fun screenshot_all +bindsym Alt+F11 exec fun screenshot_window default_border pixel 1 titlebar_border_thickness 0 @@ -130,6 +130,6 @@ bindsym $mod+Shift+down focus down bindsym $mod+Shift+left focus left bindsym $mod+Shift+right focus right -bindsym --release Super_L exec sh -c '. ~/.config/sh/functions; guak' +bindsym --release Super_L exec fun guak exec_always ~/.config/sway/sway_startup.sh diff --git a/.config/sway/sway_startup.sh b/.config/sway/sway_startup.sh index 7606fc6355aa1cccd8974251e84dc553b06aa30d..afa593b838f8f8832220adfc6d56ba434348a1ea 100755 --- a/.config/sway/sway_startup.sh +++ b/.config/sway/sway_startup.sh @@ -5,8 +5,7 @@ . "$XDG_CONFIG_HOME/sh/variables.wayland" . "$XDG_CONFIG_HOME/sh/aliases" . "$XDG_CONFIG_HOME/sh/functions" -# pgrep lock_listen || ~/.local/bin/lock_listen & -pgrep battery_notify || ~/.local/bin/battery_notify & +# pgrep lock_listen || lock_listen & swaybg -i "$HOME/Pictures/wallpapers/$(hostname).webp" -m fill & diff --git a/.local/bin/bar_bluetooth b/.local/bin/bar_bluetooth deleted file mode 100755 index 71355aafa3ad74d8a14c2275547e708fe8cc4f31..0000000000000000000000000000000000000000 --- a/.local/bin/bar_bluetooth +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -render() { - if bluetoothctl info | grep -E '(Connected)' | grep -q 'yes' >/dev/null 2>&1 - then - printf "<span color='#00afff'>█</span>" - elif bluetoothctl show | grep Powered | grep -q 'yes' >/dev/null 2>&1 - then - printf "<span color='#00afff'>░</span>" - else - printf '' - fi -} - -mpv_count=$(cat /tmp/mpv_count 2>/dev/null) -mpv_count=${mpv_count:-0} - -if [ -e /tmp/swaybar/pipe ] && [ "$mpv_count" -eq 0 ] -then - printf "bluetooth|%s\n" "$(render)" >/tmp/swaybar/pipe -fi diff --git a/.local/bin/battery_notify b/.local/bin/battery_notify deleted file mode 100755 index d49d61ffc510eefe69edb2fc074195e99ed58b3f..0000000000000000000000000000000000000000 --- a/.local/bin/battery_notify +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -check() { - current=$(acpi | cut -d ',' -f2 | tr -d ' %') - last=$(cat /tmp/last_battery_state 2>/dev/null) - state=$(acpi | cut -d ' ' -f 3 | tr -d ', ') - - if [ "$current" -le 8 ] && [ "$last" != '8' ] && [ "$state" = 'Discharging' ] - then - notify-send -u normal -i /usr/share/icons/Papirus/24x24/panel/xfce4-battery-low.svg Battery 'less than <sub>2</sub>10' - echo '8' > /tmp/last_battery_state - elif [ "$current" -le 4 ] && [ "$last" != '4' ] && [ "$state" = 'Discharging' ] - then - notify-send -u critical -i /usr/share/icons/Papirus/24x24/panel/xfce4-battery-critical.svg Battery 'less than <sub>2</sub>6' - echo '4' > /tmp/last_battery_state - elif [ "$current" -eq 100 ] && [ "$last" != '100' ] && [ "$state" = 'Charging' ] - then - notify-send -u normal -i /usr/share/icons/Papirus/24x24/panel/xfce4-battery-full.svg Battery 'charged' - echo '100' > /tmp/last_battery_state - elif [ "$last" != '100' ] && [ "$state" = 'Full' ] - then - notify-send -u normal -i /usr/share/icons/Papirus/24x24/panel/xfce4-battery-full.svg Battery 'charged' - echo '100' > /tmp/last_battery_state - fi -} - -while true -do - check - if [ "$1" = '-1' ] - then - exit - fi - sleep 300 -done diff --git a/.local/bin/drank b/.local/bin/drank deleted file mode 100755 index 38cd8a1e38a8e0fba58cc79cd684649484aa8273..0000000000000000000000000000000000000000 --- a/.local/bin/drank +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -mkdir -p "$HOME/.local/state/water" - -if [ ! -f "$HOME/.local/state/water/water.db" ] -then - sqlite3 "$HOME/.local/state/water/water.db" "create table devices (device_id text, device_type text)" - meID=$(uuidgen -r) - sqlite3 "$HOME/.local/state/water/water.db" "insert into devices values('$meID', 'me')" - sqlite3 "$HOME/.local/state/water/water.db" "create table intakes (date text, time text, amount int, drink text, device_id text)" -fi - -case "$(basename "$0")" in - drank) - if [ -z "$1" ] || [ -z "$2" ] - then - echo 'usage drank <amount> <drink> [time]' - exit 1 - fi - if echo "$1" | grep -Eq '^[0-9]+ml$' - then - amount=$(echo "$1" | grep -Eq '^[0-9]+') - elif echo "$1" | grep -Eq '^[0-9.]+$' - then - amount=$(echo "$1" | grep -E '^([0-9]+(\.[0-9]+)?)|(\.[0-9]+)$' -o) - amount=$(echo "$amount * 1000" | bc) - else - case "$1" in - glass) amount=100 ;; - cup) amount=250 ;; - Cup) amount=300 ;; - can) amount=300 ;; - mug) amount=400 ;; - Mug) amount=500 ;; - bottle) amount=700 ;; - esac - fi - if [ -z "$3" ] - then - date=$(date '+%Y%m%d') - time=$(date '+%H%M%S') - else - date=$(echo "$3" | cut -c -8) - time="$(echo "$3" | cut -c 9-12)00" - fi - meID=$(sqlite3 "$HOME/.local/state/water/water.db" -noheader "select device_id from devices where device_type = 'me'" 2>/dev/null) - sqlite3 "$HOME/.local/state/water/water.db" "insert into intakes values('$date', '$time', $amount, '$2', '$meID')" 2>/dev/null - echo "ok, drank ${amount} ml $2" - ;; - drunk) - if [ -z "$1" ] - then - today=$(date '+%Y%m%d') - else - today="$1" - fi - sqlite3 "$HOME/.local/state/water/water.db" -noheader "select amount, drink, time from devices join intakes using(device_id) where device_type = 'me' and date = '$today'" 2>/dev/null - ;; -esac diff --git a/.local/bin/drunk b/.local/bin/drunk deleted file mode 120000 index e01cd44bbdca69eb8687a3ff62156522f058611d..0000000000000000000000000000000000000000 --- a/.local/bin/drunk +++ /dev/null @@ -1 +0,0 @@ -drank \ No newline at end of file diff --git a/.local/bin/filemanager b/.local/bin/filemanager deleted file mode 100755 index c478ceb319396c1cfa5f9446b439c60a4b9ce724..0000000000000000000000000000000000000000 --- a/.local/bin/filemanager +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh - -export LF_ICONS="\ -tw=:\ -st=:\ -ow=:\ -dt=:\ -di=:\ -fi=:\ -ln=:\ -or=:\ -ex=:\ -*.c=:\ -*.cc=:\ -*.clj=:\ -*.coffee=:\ -*.cpp=:\ -*.css=:\ -*.d=:\ -*.dart=:\ -*.erl=:\ -*.exs=:\ -*.fs=:\ -*.go=:\ -*.h=:\ -*.hh=:\ -*.hpp=:\ -*.hs=:\ -*.html=:\ -*.java=:\ -*.jl=:\ -*.js=:\ -*.json=:\ -*.lua=:\ -*.md=:\ -*.php=:\ -*.pl=:\ -*.pro=:\ -*.py=:\ -*.rb=:\ -*.rs=:\ -*.scala=:\ -*.ts=:\ -*.vim=:\ -*.cmd=:\ -*.ps1=:\ -*.sh=:\ -*.bash=:\ -*.zsh=:\ -*.fish=:\ -*.tar=:\ -*.tgz=:\ -*.arc=:\ -*.arj=:\ -*.taz=:\ -*.lha=:\ -*.lz4=:\ -*.lzh=:\ -*.lzma=:\ -*.tlz=:\ -*.txz=:\ -*.tzo=:\ -*.t7z=:\ -*.zip=:\ -*.z=:\ -*.dz=:\ -*.gz=:\ -*.lrz=:\ -*.lz=:\ -*.lzo=:\ -*.xz=:\ -*.zst=:\ -*.tzst=:\ -*.bz2=:\ -*.bz=:\ -*.tbz=:\ -*.tbz2=:\ -*.tz=:\ -*.deb=:\ -*.rpm=:\ -*.jar=:\ -*.war=:\ -*.ear=:\ -*.sar=:\ -*.rar=:\ -*.alz=:\ -*.ace=:\ -*.zoo=:\ -*.cpio=:\ -*.7z=:\ -*.rz=:\ -*.cab=:\ -*.wim=:\ -*.swm=:\ -*.dwm=:\ -*.esd=:\ -*.avif=:\ -*.webp=:\ -*.jpg=:\ -*.jpeg=:\ -*.mjpg=:\ -*.mjpeg=:\ -*.gif=:\ -*.bmp=:\ -*.pbm=:\ -*.pgm=:\ -*.ppm=:\ -*.tga=:\ -*.xbm=:\ -*.xpm=:\ -*.tif=:\ -*.tiff=:\ -*.png=:\ -*.svg=:\ -*.svgz=:\ -*.mng=:\ -*.pcx=:\ -*.mov=:\ -*.mpg=:\ -*.mpeg=:\ -*.m2v=:\ -*.mkv=:\ -*.webm=:\ -*.ogm=:\ -*.mp4=:\ -*.m4v=:\ -*.mp4v=:\ -*.vob=:\ -*.qt=:\ -*.nuv=:\ -*.wmv=:\ -*.asf=:\ -*.rm=:\ -*.rmvb=:\ -*.flc=:\ -*.avi=:\ -*.fli=:\ -*.flv=:\ -*.gl=:\ -*.dl=:\ -*.xcf=:\ -*.xwd=:\ -*.yuv=:\ -*.cgm=:\ -*.emf=:\ -*.ogv=:\ -*.ogx=:\ -*.aac=:\ -*.au=:\ -*.flac=:\ -*.m4a=:\ -*.mid=:\ -*.midi=:\ -*.mka=:\ -*.mp3=:\ -*.mpc=:\ -*.ogg=:\ -*.ra=:\ -*.wav=:\ -*.oga=:\ -*.opus=:\ -*.spx=:\ -*.xspf=:\ -*.pdf=:\ -*.nix=:\ -" - -. "$HOME/.config/sh/variables.$(hostname)" -lf diff --git a/.local/bin/gmi b/.local/bin/gmi deleted file mode 100755 index 4f692487a82d8ad463cb026712d8cc6d88edce70..0000000000000000000000000000000000000000 --- a/.local/bin/gmi +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -gemget -o - "$1" | ~/Code/dwd/gmitohtml/gmitohtml -hostname "$1" - diff --git a/.local/bin/installed b/.local/bin/installed deleted file mode 100755 index adddac9199d0f029097ce56143d3b01c1a836887..0000000000000000000000000000000000000000 --- a/.local/bin/installed +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -check() { - if ! command -v "$1" >/dev/null - then - echo "$1 needed by $2" - return 1 - fi -} - -status=0 - -if command -v sway >/dev/null -then - check acpi 'bar_battery, battery_render' - status=$((status + $?)) - check notify-send battery_notify - status=$((status + $?)) - check sed 'bar_clock' - status=$((status + $?)) -fi - -check fzf 'eeze-find, run, mntblk' -status=$((status + $?)) -check eeze 'eeze-find' -status=$((status + $?)) -check lf 'filemanager' -status=$((status + $?)) -check light 'kdbBacklight' -status=$((status + $?)) -check luakit '' -status=$((status + $?)) -check grep 'mntblk, network, photosArchive, run' -status=$((status + $?)) -check awk 'mntblk' -status=$((status + $?)) -check udisksctl 'mntblk' -status=$((status + $?)) -check mpv '' -status=$((status + $?)) -check connmanctl 'network' -status=$((status + $?)) -check ip 'network' -status=$((status + $?)) -check exiv2 'photosArchive' -status=$((status + $?)) -check ffprobe 'photosArchive' -status=$((status + $?)) -check sed 'photosArchive, run' -status=$((status + $?)) -check convert 'photosArchive' -status=$((status + $?)) -check zip 'photosArchive' -status=$((status + $?)) -check cwebp 'photosArchive' -status=$((status + $?)) -check sha512sum 'photosArchive' -status=$((status + $?)) -check podman 'thumb' -status=$((status + $?)) - -if [ $status -gt 0 ] -then - exit 1 -else - echo 'all installed' -fi diff --git a/.local/bin/kbdBacklight b/.local/bin/kbdBacklight deleted file mode 100755 index 6bd052b55c28c09871feb43c4ecdb089b5f792c0..0000000000000000000000000000000000000000 --- a/.local/bin/kbdBacklight +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -if [ "$#" -lt 1 ] -then - printf "usage: %s (+|-)\n" "$(basename "$0")" - exit 1 -elif [ "$1" = "+" ] -then - light -s sysfs/leds/samsung::kbd_backlight -A 25 -elif [ "$1" = '-' ] -then - light -s sysfs/leds/samsung::kbd_backlight -U 25 -else - printf "usage: %s (+|-)\n" "$(basename "$0")" - exit 1 -fi - -light -s sysfs/leds/samsung::kbd_backlight -G | cut -d'.' -f1 > /tmp/wob.sock -sleep 1 -printf '' > /tmp/wob.sock diff --git a/.local/bin/lock_listen b/.local/bin/lock_listen deleted file mode 100755 index bae1af3f0c66d7590957713987c1774e1b29eaa3..0000000000000000000000000000000000000000 --- a/.local/bin/lock_listen +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -inotifywait -m -e delete /dev/ --format '%f' 2>/dev/null | while read -r dev -do - if [ "$dev" = 'solokey' ] - then - serials=$(lsusb -d 0x0483:0xa2ca -v 2>/dev/null | grep Serial | tr -s ' ' | cut -d ' ' -f 4) - for serial in $serials - do - if [ "$serial" = '208937A0324B' ] || [ "$serial" = '20833771324B' ] - then - continue - fi - done - pgrep swaylock >/dev/null 2>&1 || swaylock -f - fi -done diff --git a/.local/bin/mpv b/.local/bin/mpv deleted file mode 100755 index 807b6ce32b3296ffd2281dcdb302dff573b576ae..0000000000000000000000000000000000000000 --- a/.local/bin/mpv +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -. ~/.config/sh/functions - -has_sway=$(command -v swaymsg) -touch /tmp/mpv_count -mpv_count=$(cat /tmp/mpv_count) -echo $(( ${mpv_count:-0} + 1 )) > /tmp/mpv_count - -if [ "$has_sway" ] -then - case "$*" in - *--no-video*) ;; - *--profile=mpa*) ;; - *) swaymsg bar mode hide - esac -fi - -/usr/bin/mpv "$@" - -touch /tmp/mpv_count -mpv_count=$(cat /tmp/mpv_count) -mpv_count=$(( ${mpv_count:-0} - 1 )) -echo $mpv_count > /tmp/mpv_count - -if [ "$has_sway" ] && [ "$mpv_count" -eq 0 ] -then - swaymsg bar mode overlay - bar_all_once -fi diff --git a/.local/bin/update-git b/.local/bin/update-git deleted file mode 100755 index 8f61cbb96368cb1307147a6cef22b342b214d0d1..0000000000000000000000000000000000000000 --- a/.local/bin/update-git +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/sh - -set -e - -pkgs="$1" -if [ "$pkgs" = '' ] -then - echo package not specified - exit 1 -fi -if [ "$pkgs" = 'all' ] -then - pkgs='doh go-avif libasciidoc libavif qt-avif qview' -fi - -# todo git clone if not exists -cd ~/Code/dwd -for pkg in $pkgs -do - case "$pkg" in - 'glider') - cd ./glider - git checkout master - git reset --hard HEAD - echo <<END -diff --git a/feature.go b/feature.go -index 21b49fc..68aaf6b 100644 ---- a/feature.go -+++ b/feature.go -@@ -5,23 +5,23 @@ import ( - // _ "github.com/nadoo/glider/service/xxx" - - // comment out the protocols you don't need to make the compiled binary smaller. -- _ "github.com/nadoo/glider/proxy/http" -- _ "github.com/nadoo/glider/proxy/kcp" -- _ "github.com/nadoo/glider/proxy/mixed" -- _ "github.com/nadoo/glider/proxy/obfs" -- _ "github.com/nadoo/glider/proxy/pxyproto" -- _ "github.com/nadoo/glider/proxy/reject" -- _ "github.com/nadoo/glider/proxy/smux" -- _ "github.com/nadoo/glider/proxy/socks4" -+ // _ "github.com/nadoo/glider/proxy/http" -+ // _ "github.com/nadoo/glider/proxy/kcp" -+ // _ "github.com/nadoo/glider/proxy/mixed" -+ // _ "github.com/nadoo/glider/proxy/obfs" -+ // _ "github.com/nadoo/glider/proxy/pxyproto" -+ // _ "github.com/nadoo/glider/proxy/reject" -+ // _ "github.com/nadoo/glider/proxy/smux" -+ // _ "github.com/nadoo/glider/proxy/socks4" - _ "github.com/nadoo/glider/proxy/socks5" -- _ "github.com/nadoo/glider/proxy/ss" -- _ "github.com/nadoo/glider/proxy/ssh" -- _ "github.com/nadoo/glider/proxy/ssr" -- _ "github.com/nadoo/glider/proxy/tcp" -+ // _ "github.com/nadoo/glider/proxy/ss" -+ // _ "github.com/nadoo/glider/proxy/ssh" -+ // _ "github.com/nadoo/glider/proxy/ssr" -+ // _ "github.com/nadoo/glider/proxy/tcp" - _ "github.com/nadoo/glider/proxy/tls" -- _ "github.com/nadoo/glider/proxy/trojan" -- _ "github.com/nadoo/glider/proxy/udp" -- _ "github.com/nadoo/glider/proxy/vless" -- _ "github.com/nadoo/glider/proxy/vmess" -+ // _ "github.com/nadoo/glider/proxy/trojan" -+ // _ "github.com/nadoo/glider/proxy/udp" -+ // _ "github.com/nadoo/glider/proxy/vless" -+ // _ "github.com/nadoo/glider/proxy/vmess" - _ "github.com/nadoo/glider/proxy/ws" - ) -diff --git a/feature_linux.go b/feature_linux.go -index bbe2eff..1866395 100644 ---- a/feature_linux.go -+++ b/feature_linux.go -@@ -1,12 +1,12 @@ - package main - - import ( -- // comment out the services you don't need to make the compiled binary smaller. -- _ "github.com/nadoo/glider/service/dhcpd" -+// comment out the services you don't need to make the compiled binary smaller. -+// _ "github.com/nadoo/glider/service/dhcpd" - -- // comment out the protocols you don't need to make the compiled binary smaller. -- _ "github.com/nadoo/glider/proxy/redir" -- _ "github.com/nadoo/glider/proxy/tproxy" -- _ "github.com/nadoo/glider/proxy/unix" -- _ "github.com/nadoo/glider/proxy/vsock" -+// comment out the protocols you don't need to make the compiled binary smaller. -+// _ "github.com/nadoo/glider/proxy/redir" -+// _ "github.com/nadoo/glider/proxy/tproxy" -+// _ "github.com/nadoo/glider/proxy/unix" -+// _ "github.com/nadoo/glider/proxy/vsock" - ) -END >features.patch - git apply features.patch - go build -v -ldflags "-s -w" - 'doh') - cd ./dns-over-https/ - git checkout master - git reset --hard HEAD - git pull - /usr/bin/make binary - # doas sv stop doh - # doas cp doh-client/doh-client /usr/local/bin/ - # doas chmod 755 /usr/local/bin/doh-client - # doas sv start doh - /usr/bin/make clean - cd ../ - ;; - 'libasciidoc') - cd ./libasciidoc/ - git checkout master - git reset --hard HEAD - git pull - # export PATH="$HOME/.go/bin/:$PATH" - /usr/bin/make build - # doas cp ./bin/libasciidoc /usr/local/bin/asciidoc - # doas chmod 755 /usr/local/bin/asciidoc - cd ../ - ;; - esac -done diff --git a/.local/bin/whistle b/.local/bin/whistle deleted file mode 100755 index ebe77a0f4031cbbd0b2bbd525bf45b1e6d6331b2..0000000000000000000000000000000000000000 --- a/.local/bin/whistle +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -set -x - -canonical() { - file=$1 - sed -i -E 's/%.*//g' "$file" - sed -i -E 's/\\break//g' "$file" - sed -i 's/\[//g' "$file" - sed -i 's/\]//g' "$file" - sed -i -E 's/\\barNumberCheck #[0-9]+//g' "$file" - sed -i 's/autoBeaming = ##f//g' "$file" - sed -i 's/\\header[ \t]*{/\\header {\n tagline = ""/' "$file" - sed -i -E 's/(\\version "[0-9.]+")/\1\n\\include "tinwhistle.ly"/' "$file" - sed -i 's/\\stemUp//g' "$file" - sed -i 's/\\stemDown//g' "$file" - sed -i 's/\\set Staff.instrumentName.*//' "$file" - sed -i 's/\\set Staff.shortInstrumentName.*//' "$file" - sed -i -E 's/[ ]+$//g' "$file" - sed -i 's/PartPOneVoiceOne =[ \t]*{/PartPOneVoiceOne = \\withTW {/' "$file" - sed -i -E 's/(repeat volta [0-9] )/\1\\withTW /' "$file" - sed -i -E 's/\\alternative \{ \{/\\alternative { \\withTW {/' "$file" - sed -i -E 's/\\acciaccatura \{/\\acciaccatura \\withTW {/' "$file" - sed -i -E 's/(^[ \t]*)\{$/\1\\withTW {/' "$file" - tr '\n' '@' < "$file" > "$file.tr" - sed -i -E 's/~( |@|\|)*([^ ]+)/~\1{\2}/g' "$file.tr" - tr '@' '\n' < "$file.tr" > "$file" - rm "$file.tr" -} - -if [ "$(basename "$0")" = 'whistle' ] -then - cd ~/Music/ly || exit 1 - - if ls ./*.mxl >/dev/null 2>&1 - then - for mxml in *.mxl - do - sheet="${mxml%.*}" - musicxml2ly -a -o "$sheet.ly" "$mxml" || continue - canonical "$sheet.ly" - lilypond "$sheet.ly" - done - fi - - if ls ./*.musicxml >/dev/null 2>&1 - then - for mxml in *.musicxml - do - sheet="${mxml%.*}_musicxml" - musicxml2ly -a -o "$sheet.ly" "$mxml" || continue - canonical "$sheet.ly" - lilypond "$sheet.ly" - done - fi -fi diff --git a/.local/bin/workspace b/.local/bin/workspace deleted file mode 100755 index 3a411a8df33035739534433d66e98be3afc16c18..0000000000000000000000000000000000000000 --- a/.local/bin/workspace +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -set -x - -if stat "$HOME/Pictures/wallpapers/$(hostname)_w$1.webp" >/dev/null 2>&1 -then - wallpaper="$HOME/Pictures/wallpapers/$(hostname)_w$1.webp" -else - wallpaper="$HOME/Pictures/wallpapers/$(hostname).webp" -fi - -killall swaybg -swaybg -i "$wallpaper" -m fill >/dev/null 2>&1 & -#nanosleep 100000000 -swaymsg workspace "$1"