From 7f1dc166de06dee7f39e6b3b3b282a9c016475ce Mon Sep 17 00:00:00 2001 From: gerblesh <101901964+gerblesh@users.noreply.github.com> Date: Tue, 5 Sep 2023 19:38:34 -0700 Subject: [PATCH] update image --- .github/workflows/build.yml | 1 - config/files/usr/bin/battery.sh | 29 +++++++++++++++++++ config/files/usr/etc/sway/config.d/execs.conf | 5 ++-- config/recipe.yml | 2 +- config/systemd.yml | 7 +++++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100755 config/files/usr/bin/battery.sh create mode 100644 config/systemd.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcf8c137af..b3af981630 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,6 @@ on: # https://docs.github.com/en/actions/using-workflows/events-that-trigger-wor - live - template - main - - modular-rewrite paths-ignore: # don't rebuild if only documentation has changed - "**.md" pull_request: diff --git a/config/files/usr/bin/battery.sh b/config/files/usr/bin/battery.sh new file mode 100755 index 0000000000..eedd61f7ba --- /dev/null +++ b/config/files/usr/bin/battery.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Low battery notifier + +# Kill already running processes +already_running="$(ps -fC 'grep' -N | grep 'battery.sh' | wc -l)" +if [[ $already_running -gt 1 ]]; then + pkill -f --older 1 'battery.sh' +fi + +while [[ 0 -eq 0 ]]; do + battery_status="$(cat /sys/class/power_supply/BAT1/status)" + battery_charge="$(cat /sys/class/power_supply/BAT1/capacity)" + + if [[ $battery_status == 'Discharging' ]]; then + if [[ $battery_charge -le 10 ]]; then + notify-send "Battery Critical!" "Battery is at ${battery_charge}%" --app-name "Power Alerts" --urgency "critical" --icon "battery-000" + pw-cat -p /usr/share/sounds/speech-dispatcher/prompt.wav + powerprofilesctl set power-saver + sleep 180 + elif [[ $battery_charge -le 25 ]]; then + notify-send "Battery Low!" "Battery is at ${battery_charge}%" --app-name "Power Alerts" --urgency "critical" --icon "battery-010" + pw-cat -p /usr/share/sounds/freedesktop/stereo/dialog-warning.oga + powerprofilesctl set power-saver + sleep 240 + fi + else + sleep 600 + fi +done diff --git a/config/files/usr/etc/sway/config.d/execs.conf b/config/files/usr/etc/sway/config.d/execs.conf index 83eec2673c..b204bee50e 100644 --- a/config/files/usr/etc/sway/config.d/execs.conf +++ b/config/files/usr/etc/sway/config.d/execs.conf @@ -1,5 +1,5 @@ - +exec /usr/bin/battery.sh exec blueman-applet exec nm-applet exec wl-paste --watch cliphist store @@ -12,6 +12,5 @@ exec /usr/bin/sway-autoname-workspaces.py before-sleep '/usr/bin/lock.sh' exec /usr/libexec/polkit-gnome-authentication-agent-1 -exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway +exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway XCURSOR_THEME=$XCURSOR_THEME XCURSOR_SIZE=$XCURSOR_SIZE exec systemd-notify --ready - diff --git a/config/recipe.yml b/config/recipe.yml index b85f4a3f93..9b67dcb0ea 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -15,7 +15,6 @@ modules: - type: files files: - usr: /usr - # Copy static configurations and component files. # Warning: If you want to place anything in "/etc" of the final image, you MUST # place them in "./usr/etc" in your repo, so that they're written to "/usr/etc" @@ -27,6 +26,7 @@ modules: - from-file: packages.yml - from-file: bling.yml - from-file: yafti.yml + - from-file: systemd.yml - type: script scripts: diff --git a/config/systemd.yml b/config/systemd.yml new file mode 100644 index 0000000000..edccafe191 --- /dev/null +++ b/config/systemd.yml @@ -0,0 +1,7 @@ +type: systemd + system: + enabled: + - power-profiles-daemon + - mullvad-daemon + disabled: + - rpm-ostree-countme.timer