Author: Adam Evyčędo <git@apiote.xyz>
alpine on framework
.config/sh/functions | 155 +++++++++++++++++++++++-------------- .config/sway/config | 17 +-- .config/sway/sway_startup.sh | 2
diff --git a/.config/sh/functions b/.config/sh/functions index 3c84010f5fc59857df08865e1071e4bcba696c4a..6bcdc40ea40ef4833bbbc88b3ee2b2c85b560505 100644 --- a/.config/sh/functions +++ b/.config/sh/functions @@ -125,7 +125,8 @@ i=$((i+=1)) nanosleep 100000000 done nanosleep 125 - swaymsg "[pid=${pid}] floating enable, resize set 1920 400, move position center, move up 340 px" + swaymsg "[pid=${pid}] floating enable, resize set 1504 400, move position center, move up 300 px" + # TODO size and move is `swaymgs -t get_outputs * / scale_factor } guakIsVisible() { @@ -217,8 +218,8 @@ elif [ "$1" = '+' ] then cmd='-A' fi - light "$cmd" -s sysfs/backlight/auto 5 - light -s sysfs/backlight/auto -G | cut -d'.' -f1 > /tmp/wob.sock + brillo "$cmd" 5 + brillo -G | cut -d'.' -f1 > /tmp/wob.sock sleep 1 printf '' > /tmp/wob.sock } @@ -316,6 +317,10 @@ elif [ "$1" = 't' ] then # TODO not master; headphones or speaker result=$(amixer $cmd "$ctl" toggle) + if amixer sget "$ctl" | grep -qF '[off]' + then + result="[0%]" + fi fi echo "$result" | sed -En 's/.*\[([0-9]+)%\].*/\1/p' | head -n1 > /tmp/wob.sock sleep 1 @@ -399,28 +404,28 @@ esac exit 0 fi - if [ "$(id -u)" -ne 0 ] + if ! (id -Gn | grep -q backup) then - printf 'run as root' + printf 'run as a member of group ‘backup’' exit 1 fi case "$(hostname)" in mycroft) cd / - btrfs subvolume snapshot -r / "root_$(date '+%Y%m%d')" - btrfs send root_* | btrfs receive /media/usb/adam/H500/ - btrfs subvolume delete "root_$(date '+%Y%m%d')" + doas btrfs subvolume snapshot -r / "root_$(date '+%Y%m%d')" + doas btrfs send root_* | doas btrfs receive /media/usb/adam/H500/ + doas btrfs subvolume delete "root_$(date '+%Y%m%d')" cd /home || exit 1 - btrfs subvolume snapshot -r /home/ "home_$(date '+%Y%m%d')" - btrfs send home_* | btrfs receive /media/usb/adam/H500/ - btrfs subvolume delete "home_$(date '+%Y%m%d')" + doas btrfs subvolume snapshot -r /home/ "home_$(date '+%Y%m%d')" + doas btrfs send home_* | doas btrfs receive /media/usb/adam/H500/ + doas btrfs subvolume delete "home_$(date '+%Y%m%d')" ;; esac } connected() { - if connmanctl services | grep -qE '(O|R) ' + if iwctl station list | grep wlan0 | grep -q 'connected' then return 0 else @@ -483,8 +488,6 @@ bar_bluetooth } bt() { - # TODO https://github.com/arkq/bluez-alsa/wiki/Using-BlueALSA-as-default-ALSA-PCM#automation - trap bar_bluetooth INT if [ "$1" = 'on' ] @@ -497,6 +500,7 @@ sleep 1 bluetoothctl power on || (sleep 2; bluetoothctl power on) sleep 1 bluetoothctl connect 9C:19:C2:95:5D:E1 + # TODO set volume 50% ) elif [ "$1" = 'off' ] then @@ -536,7 +540,7 @@ mntblk() { set -e # shellcheck disable=SC2010 - disks=$(ls -l /dev/disk/by-uuid/ | grep -v dm | grep -v sda | cut -d '>' -f 2 | tail -n+2 | cut -d '/' -f 3) + disks=$(ls -l /dev/disk/by-uuid/ | grep -v dm | grep -v nvme0n1 | cut -d '>' -f 2 | tail -n+2 | cut -d '/' -f 3) labels=$(ls -l /dev/disk/by-label/) if [ -z "$disks" ] @@ -1219,55 +1223,34 @@ 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 +# 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 +# if [ "$has_sway" ] +# then +# case "$*" in +# *--no-video*) ;; +# *--profile=mpa*) ;; +# *) swaymsg bar mode hide +# esac +# fi - /usr/bin/mpv "$@" +# /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 +# 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 -} +# if [ "$has_sway" ] && [ "$mpv_count" -eq 0 ] +# then +# swaymsg bar mode overlay +# bar_all_once +# fi +# } waterInit() { mkdir -p "$HOME/.local/state/water" @@ -1426,4 +1409,56 @@ larynx -m /usr/share/larynx2/en/gb/northern_english_male/en_GB-northern_english_male-medium.onnx else echo "$1" | larynx -m /usr/share/larynx2/en/gb/northern_english_male/en_GB-northern_english_male-medium.onnx fi +} + +signImage() { + if [ -f /media/nextcloud/me@cloud.apiote.xyz/Pictutes/IDs/logo/waterSign.svg ] + then + echo 'water sign not mounted' + exit 1 + fi + + width=$(ffprobe "$1" -show_entries stream=width -of csv=p=0 -v error -select_streams v:0) + waterWidth=$(dc -e "$width 3 /n"); + height=$(ffprobe "$1" -show_entries stream=height -of csv=p=0 -v error -select_streams v:0) + inkscape -w "$waterWidth" --export-filename=waterSign.png /media/nextcloud/me@cloud.apiote.xyz/Pictutes/IDs/logo/waterSign.svg + waterHeight=$(ffprobe waterSign.png -show_entries stream=height -of csv=p=0 -v error -select_streams v:0) + y=$(dc -e "$height 100 - $waterHeight - n") + magick \( -page +0+0 "$1" \) \( -page "+100+$y" waterSign.png \) -flatten "$1.signed.jpg" +} + +autoBrightness() { + min_il=0 + monitor-sensor --light | while read -r line + do + ilumination=$(echo "$line" | grep 'Light changed' | tr -s ' ' | cut -d ' ' -f 3) + brightness=$(echo "scale=2; l($ilumination - $min_il + 1) * 3" | bc -l | cut -d '.' -f1) + if [ "$brightness" -gt 100 ] + then + brightness=100 + elif [ "$brightness" -lt 0 ] + then + brightness=0 + fi + brillo -u 1000000 -S "$brightness" + done +} + +barHider() { + # TODO subscribe to workspace too, but jq throws some error + swaymsg -t subscribe -m "['window']" | script -E never -qfc "jq '[.change, .container.app_id] | @csv' -r" | while read -r line + do + change=$(echo "$line" | cut -d',' -f1 | tr -d '"') + app=$(echo "$line" | cut -d',' -f2 | tr -d '"' | sed 's/\r//') + + if [ "$app" = 'null' ] || { [ "$app" = 'mpv' ] && { [ "$change" = 'fullscreen_mode' ] || [ "$change" = 'close' ]; }; } + then + if swaymsg -t get_tree -r | jq '.. | objects | select(.app_id == "mpv") | [ .focused, .fullscreen_mode ] | @csv' | grep -q 'true,1' + then + swaymsg bar mode hide + else + swaymsg bar mode overlay + fi + fi + done } \ No newline at end of file diff --git a/.config/sway/config b/.config/sway/config index 19852044afd652cf761a33e28d204bc60e62274f..63ebd6be8b88225ae2da3231ab8bd6a628d3a7bb 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -2,7 +2,7 @@ set $mod Mod4 xwayland disable -input "2:14:ETPS/2_Elantech_Touchpad" { +input "2362:628:PIXA3854:00_093A:0274_Touchpad" { tap enabled natural_scroll enabled middle_emulation enabled @@ -13,6 +13,10 @@ input "1:1:AT_Translated_Set_2_keyboard" { xkb_layout plde,ucteng xkb_options grp:shifts_toggle,compose:caps +} + +output eDP-1 { + scale 1.5 } bar { @@ -82,9 +86,6 @@ 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 @@ -95,23 +96,17 @@ bindsym $mod+n exec playerctl -p $(playerctl -l | tail -n1) next 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 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 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 fun screenshot_area +bindsym Mod4+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 diff --git a/.config/sway/sway_startup.sh b/.config/sway/sway_startup.sh index e51dcf7c3e189536a9cbd63508f09a91476211eb..1afee74b494bf6a6c380e7f8f900673445fa8ffd 100755 --- a/.config/sway/sway_startup.sh +++ b/.config/sway/sway_startup.sh @@ -48,5 +48,7 @@ bar_all_once bt off alsa_usb +autoBrightness & +barHider & # network_backup &