diff --git a/facts/general/package.yml b/facts/general/package.yml index 77e2166..25b27e1 100644 --- a/facts/general/package.yml +++ b/facts/general/package.yml @@ -20,6 +20,7 @@ ca_certificates: ca-certificates locate: mlocate alsa: alsa-utils + stress: stress - name: General | Facts | Package | Parrot OS Fixes set_fact: @@ -157,6 +158,11 @@ pacman) echo "*** Pacman ***" + auto_accept="" + if [[ -n "$accept" ]]; then + auto_accept="{{ update_accept_var }}" + fi + sudo pacman -Syu {{ update_accept_var }} || return 1 echo -e "\n" diff --git a/files/scripts/battery_nag.sh b/files/scripts/battery_nag.sh new file mode 100755 index 0000000..073168e --- /dev/null +++ b/files/scripts/battery_nag.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +# 20260819 - Hyperling +# Alert the user every so often once the battery is low. + +## Setup ## + +echo "`date` - Checking Active Programs" + +ps -ef | grep battery_nag.sh | grep -v grep | grep -v "sh -c" | grep -v kill | grep -v $$ + +active=`ps -ef | grep battery_nag.sh | grep -v grep | grep -v "sh -c" | grep -v kill | grep -vc $$` +if (( "$active" >= 1 )); then + echo "Program already running, exiting. Number of processes: $active" + exit 1 +fi + +echo "`date` - Loading Functions" + +which battery.function || { + echo "ERROR: Battery function not found, exiting." + exit 2 +} +source battery.function + +## Params ## + +echo "`date` - Parsing Parameters" + +typeset -i alert sleep + +# Default to 20%. +alert=20 +if [[ -n "$1" ]]; then + echo -n "alert changed from '$alert' " + alert="$1" + echo "to '$alert'" +fi + +# Default to 5 minutes. +sleep=300 +if [[ -n "$2" ]]; then + echo -n "sleep changed from '$sleep' " + sleep="$2" + echo "to '$sleep'" +fi + +# Default to true. +accelerate="Y" +if [[ -n "$3" ]]; then + echo -n "accelerate changed from '$accelerate' " + accelerate="$3" + echo "to '$accelerate'" +fi + +echo "Alerting when under ${alert}%." +echo "Notifying every ${sleep} seconds." +if [[ "$accelerate" == "Y" ]]; then + echo -n "Speeding up notifications as % gets lower." +else + echo -n "Notifcations staying persistent." +fi +echo " (accelerate == $accelerate)" + +## Main ## + +echo "`date` - Starting Loop" + +while true; do + + batt=`battery-display` + batt=${batt//%/} + + if (( batt <= alert )); then + title="Battery is below ${alert}%" + message="Currently at ${batt}%" + cmd="`which fyi 2>/dev/null || which notify-send 2>/dev/null`" + if [[ -z "$cmd" ]]; then + echo "ERROR: No command found to send notification, exiting." + echo "Please install 'fyi' or 'notify-send' to use this script." + echo "If not using a DE, also ensure 'dunst' or similar is running." + exit 3 + fi + echo "`date` - Attempting to report battery level at ${batt}." + + $cmd "$title" "$message" + status="$?" + + if [[ "$status" == 0 ]]; then + echo -n "`date` - Success! " + else + echo -n "`date` - ERROR: " + fi + echo "Nag returned status ${status}." + else + echo "`date` - Battery at ${batt}%, did not nag." + fi + + time=$sleep + if [[ "$accelerate" == "Y" && $batt -lt $alert ]]; then + # Bash only returns whole numbers, so things like 20/11 only provide 1. + # Likewise, if the battery is full, 20/100 returns 0, which is bad. :) + if (( batt > 0 )); then + time=$(( time / (alert / batt) )) + else + time=10 + fi + fi + # Showing a notification every 10 seconds makes it persistent. + # Any more than that casues multiple to stack which is unnecessary. + if (( time < 10 )); then + time=10 + fi + echo "`date` - Sleeping for ${time}." + sleep $time +done diff --git a/files/settings/i3.config b/files/settings/i3.config index 6b7d5e9..d7f601e 100644 --- a/files/settings/i3.config +++ b/files/settings/i3.config @@ -141,54 +141,66 @@ bindsym $mod+c exec codium-flatpak ## Brightness ## -# Use the bracket keys to change the brightness. # light requires sudo privileges unless video group and udev are configured. -bindsym $mod+bracketleft exec --no-startup-id "light -U 05 && notify-send 'Brightness - ' $(light -G)" -bindsym $mod+bracketright exec --no-startup-id "light -A 05 && notify-send 'Brightness + ' $(light -G)" -bindsym $shift+$mod+bracketleft exec --no-startup-id "light -U 20 && notify-send 'Brightness ---' $(light -G)" -bindsym $shift+$mod+bracketright exec --no-startup-id "light -A 20 && notify-send 'Brightness +++' $(light -G)" + +set $b_time 3000 +set $b_small 10 +set $b_large 20 + +# Use the bracket keys to change the brightness. +bindsym $mod+bracketleft exec --no-startup-id "light -U $b_small && notify-send -t $b_time 'Brightness - ' $(light -G)" +bindsym $mod+bracketright exec --no-startup-id "light -A $b_small && notify-send -t $b_time 'Brightness + ' $(light -G)" +bindsym $shift+$mod+bracketleft exec --no-startup-id "light -U $b_large && notify-send -t $b_time 'Brightness ---' $(light -G)" +bindsym $shift+$mod+bracketright exec --no-startup-id "light -A $b_large && notify-send -t $b_time 'Brightness +++' $(light -G)" # Also get the actual brightness keys to work!! -bindsym XF86MonBrightnessUp exec --no-startup-id "light -A 05 && notify-send 'Brightness + ' $(light -G)" -bindsym XF86MonBrightnessDown exec --no-startup-id "light -U 05 && notify-send 'Brightness - ' $(light -G)" -bindsym $shift+XF86MonBrightnessUp exec --no-startup-id "light -A 20 && notify-send 'Brightness +++' $(light -G)" -bindsym $shift+XF86MonBrightnessDown exec --no-startup-id "light -U 20 && notify-send 'Brightness ---' $(light -G)" +bindsym XF86MonBrightnessUp exec --no-startup-id "light -A $b_small && notify-send -t $b_time 'Brightness + ' $(light -G)" +bindsym XF86MonBrightnessDown exec --no-startup-id "light -U $b_small && notify-send -t $b_time 'Brightness - ' $(light -G)" +bindsym $shift+XF86MonBrightnessUp exec --no-startup-id "light -A $b_large && notify-send -t $b_time 'Brightness +++' $(light -G)" +bindsym $shift+XF86MonBrightnessDown exec --no-startup-id "light -U $b_large && notify-send -t $b_time 'Brightness ---' $(light -G)" + + +## Keyboard Brightness ## + +# Use same timing and step size settings as above. + +# Macbooks tend to use 'sysfs/leds/smc::kbd_backlight' +# NovaCustom laptop is 'sysfs/leds/system76_acpi::kbd_backlight' +# Some other laptops may be 'sysfs/class/leds/...', use ìght -L`to find out. +bindsym XF86KbdBrightnessUp exec "light -s sysfs/leds/smc::kbd_backlight -A $b_small && notify-send -t $b_time 'Keyboard Brightness + ' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym XF86KbdBrightnessDown exec "light -s sysfs/leds/smc::kbd_backlight -U $b_small && notify-send -t $b_time 'Keyboard Brightness - ' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym $shift+XF86KbdBrightnessUp exec "light -s sysfs/leds/smc::kbd_backlight -A $b_large && notify-send -t $b_time 'Keyboard Brightness +++' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym $shift+XF86KbdBrightnessDown exec "light -s sysfs/leds/smc::kbd_backlight -U $b_large && notify-send -t $b_time 'Keyboard Brightness ---' $(light -s sysfs/leds/smc::kbd_backlight -G)" + +bindsym $mod+apostrophe exec "light -s sysfs/leds/smc::kbd_backlight -A $b_small && notify-send -t $b_time 'Keyboard Brightness + ' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym $mod+semicolon exec "light -s sysfs/leds/smc::kbd_backlight -U $b_small && notify-send -t $b_time 'Keyboard Brightness - ' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym $shift+$mod+apostrophe exec "light -s sysfs/leds/smc::kbd_backlight -A $b_large && notify-send -t $b_time 'Keyboard Brightness +++' $(light -s sysfs/leds/smc::kbd_backlight -G)" +bindsym $shift+$mod+semicolon exec "light -s sysfs/leds/smc::kbd_backlight -U $b_large && notify-send -t $b_time 'Keyboard Brightness ---' $(light -s sysfs/leds/smc::kbd_backlight -G)" ## Volume ## # The volume function is from https://git.hyperling.com/me/env-ansible +set $v_time 1500 +set $v_small 5 +set $v_large 25 + # Use the comma and period keys to change volume. -bindsym $mod+comma exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -05 && notify-send "Volume - " $(volume)' -bindsym $mod+period exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +05 && notify-send "Volume + " $(volume)' -bindsym $shift+$mod+comma exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -25 && notify-send "Volume ---" $(volume)' -bindsym $shift+$mod+period exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +25 && notify-send "Volume +++" $(volume)' +bindsym $mod+comma exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -$v_small && notify-send -t $v_time "Volume - " $(volume)' +bindsym $mod+period exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +$v_small && notify-send -t $v_time "Volume + " $(volume)' +bindsym $shift+$mod+comma exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -$v_large && notify-send -t $v_time "Volume ---" $(volume)' +bindsym $shift+$mod+period exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +$v_large && notify-send -t $v_time "Volume +++" $(volume)' # Actual volume keys. -bindsym XF86AudioMute exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume mute && notify-send "Volume Muted" $(volume)' -bindsym XF86AudioRaiseVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +05 && notify-send "Volume + " $(volume)' -bindsym XF86AudioLowerVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -05 && notify-send "Volume - " $(volume)' -bindsym $shift+XF86AudioRaiseVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +25 && notify-send "Volume +++ " $(volume)' -bindsym $shift+XF86AudioLowerVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -25 && notify-send "Volume --- " $(volume)' +bindsym XF86AudioMute exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume mute && notify-send -t $v_time "Volume Muted" $(volume)' +bindsym XF86AudioRaiseVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +$v_small && notify-send -t $v_time "Volume + " $(volume)' +bindsym XF86AudioLowerVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -$v_small && notify-send -t $v_time "Volume - " $(volume)' +bindsym $shift+XF86AudioRaiseVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume +$v_large && notify-send -t $v_time "Volume +++ " $(volume)' +bindsym $shift+XF86AudioLowerVolume exec --no-startup-id bash -c 'source /usr/local/bin/volume.function && volume -$v_large && notify-send -t $v_time "Volume --- " $(volume)' bindsym $mod+slash exec pavucontrol -## Keyboard Brightness ## - -# Macbooks tend to use 'sysfs/leds/smc::kbd_backlight' -# NovaCustom laptop is 'sysfs/leds/system76_acpi::kbd_backlight' -# Some other laptops may be 'sysfs/class/leds/...', use ìght -L`to find out. -bindsym XF86KbdBrightnessUp exec "light -s sysfs/leds/smc::kbd_backlight -A 05 && notify-send 'Keyboard Brightness + ' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym XF86KbdBrightnessDown exec "light -s sysfs/leds/smc::kbd_backlight -U 05 && notify-send 'Keyboard Brightness - ' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym $shift+XF86KbdBrightnessUp exec "light -s sysfs/leds/smc::kbd_backlight -A 20 && notify-send 'Keyboard Brightness +++' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym $shift+XF86KbdBrightnessDown exec "light -s sysfs/leds/smc::kbd_backlight -U 20 && notify-send 'Keyboard Brightness ---' $(light -s sysfs/leds/smc::kbd_backlight -G)" - -bindsym $mod+apostrophe exec "light -s sysfs/leds/smc::kbd_backlight -A 05 && notify-send 'Keyboard Brightness + ' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym $mod+semicolon exec "light -s sysfs/leds/smc::kbd_backlight -U 05 && notify-send 'Keyboard Brightness - ' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym $shift+$mod+apostrophe exec "light -s sysfs/leds/smc::kbd_backlight -A 20 && notify-send 'Keyboard Brightness +++' $(light -s sysfs/leds/smc::kbd_backlight -G)" -bindsym $shift+$mod+semicolon exec "light -s sysfs/leds/smc::kbd_backlight -U 20 && notify-send 'Keyboard Brightness ---' $(light -s sysfs/leds/smc::kbd_backlight -G)" - ## Workspaces ## @@ -361,7 +373,7 @@ exec --no-startup-id light -N 0 exec_always --no-startup-id setxkbmap -layout us -variant altgr-intl # Notifications (allows fyi and notify-send to work) -exec --no-startup-id dunst +exec_always --no-startup-id "killall dunst; dunst" # Audio exec --no-startup-id "sleep 00; dbus-launch --exit-with-session i3" @@ -374,4 +386,7 @@ exec_always --no-startup-id "sleep 03; pipewire-pulse >~/Reports/pipewire-pulse. exec_always --no-startup-id feh --recursive --randomize --bg-fill ~/Pictures/Wallpapers # Compositor -exec_always --no-startup-id picom -f --backend xrender +exec_always --no-startup-id "killall picom; picom -f --backend xrender" + +# Battery +exec_always --no-startup-id bash -c 'pkill -ef "bash `which battery_nag.sh`" >~/Reports/battery_nag.log 2>&1; battery_nag.sh >>~/Reports/battery_nag.log 2>&1' diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 92e7513..d34e018 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -141,6 +141,11 @@ if [[ -n "$XDG_SESSION_ID" ]]; then setxkbmap -layout us -variant altgr-intl fi + export_notify: | + export NOTIFY="`which fyi 2>/dev/null || which notify-send 2>/dev/null`" + function notify() { + $NOTIFY $@ + } - name: General | Account Management | Users | Files | RC Variables set_fact: @@ -1199,7 +1204,8 @@ {{ export_path_sbin }} {{ export_terminal }} {{ export_browser }} - {{ keyboard_settings}} + {{ keyboard_settings }} + {{ export_notify }} rc_common: | # Fixes "command not found" when using aliases within functions. shopt -s expand_aliases diff --git a/tasks/general/software/packages.yml b/tasks/general/software/packages.yml index b1f2e7c..9694101 100644 --- a/tasks/general/software/packages.yml +++ b/tasks/general/software/packages.yml @@ -66,6 +66,7 @@ - "{{ sendmail_mta }}" - "{{ ca_certificates }}" - "{{ alsa }}" + - "{{ stress }}" state: present - name: General | Software | Packages | Install Software (DEV) @@ -111,17 +112,6 @@ state: present when: ansible_pkg_mgr == "pacman" -- name: General | Software | Packages | Install Audio (Looking at you, Artix) - package: - name: - - pipewire - - pipewire-pulse - - wireplumber - - pipewire-alsa - state: present - when: ansible_pkg_mgr == "pacman" - and ansible_service_mgr == "runit" - - name: General | Software | Packages | Install Fix (Looking at you, openSUSE) package: name: diff --git a/tasks/workstation/linux/software/packages.yml b/tasks/workstation/linux/software/packages.yml index 6fca4bc..d909912 100644 --- a/tasks/workstation/linux/software/packages.yml +++ b/tasks/workstation/linux/software/packages.yml @@ -50,6 +50,17 @@ - "{{ mpv }}" state: present +- name: Workstation | Linux | Software | Packages | Install Audio (Looking at you, Artix) + package: + name: + - pipewire + - pipewire-pulse + - wireplumber + - pipewire-alsa + state: present + when: ansible_pkg_mgr == "pacman" + and ansible_service_mgr == "runit" + - name: Workstation | Linux | Software | Packages | Extra For Liberated Init Systems package: name: diff --git a/tasks/workstation/linux/software/vpn.yml b/tasks/workstation/linux/software/vpn.yml index c9a4e68..4930142 100644 --- a/tasks/workstation/linux/software/vpn.yml +++ b/tasks/workstation/linux/software/vpn.yml @@ -81,6 +81,11 @@ set_fact: mullvad_exe_new: "{{ global_bin }}/{{ mullvad_exe }}" +- name: Workstation | Software | VPN | Mullvad | PATH | Facts (pacman) + set_fact: + mullvad_exe_dir: '/usr/bin' + when: ansible_pkg_mgr == "pacman" + - name: Workstation | Software | VPN | Mullvad | PATH | Install shell: "{{ item }}" loop: