mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 06:32:40 +00:00
feat: Adds battery monitor service, timer, and execution script.
This commit is contained in:
15
TODO.md
15
TODO.md
@@ -12,7 +12,18 @@
|
|||||||
|
|
||||||
- Separate scripts that are used for configurations / store them somewhere aside
|
- Separate scripts that are used for configurations / store them somewhere aside
|
||||||
from `~/.local/bin`
|
from `~/.local/bin`
|
||||||
- Remove system-d stuff (don't think it's needed).
|
|
||||||
- Clipse didn't work when installed on a new machine when I try to use the
|
- Clipse didn't work when installed on a new machine when I try to use the
|
||||||
config in the dotfiles, but works if I use the default config. Need to explore
|
config in the dotfiles, but works if I use the default config. Need to explore
|
||||||
why.
|
why (current thoughts are it has to do with creating the
|
||||||
|
clipboard_history.json file and not letting clipse do it automatically).
|
||||||
|
- Set sddm login theme, currently it doesn't allow me to echo values into the
|
||||||
|
/etc/sddm.conf file, also need to edit the theme in
|
||||||
|
`/usr/share/sddm/themes/catppuccin-mocha/theme.conf` to use the wallpaper as a
|
||||||
|
background image.
|
||||||
|
- Note: The background needs to be copied into the theme's background
|
||||||
|
directory. It didn't seem to work when I just set the path to somewhere in
|
||||||
|
my home directory.
|
||||||
|
- Add script to generate yubikey authentication using the pam-u2f module
|
||||||
|
[documentation](https://wiki.archlinux.org/title/Universal_2nd_Factor).
|
||||||
|
- Note: that the directory this is stored in MUST be ~/.config/Yubico (I tried
|
||||||
|
using ~/.config/yubico and it didn't work)
|
||||||
|
|||||||
@@ -12,6 +12,5 @@ exec-once = uwsm app -- elephant
|
|||||||
exec-once = uwsm app -- swaync
|
exec-once = uwsm app -- swaync
|
||||||
exec-once = uwsm app -- walker --gapplication-service &
|
exec-once = uwsm app -- walker --gapplication-service &
|
||||||
exec-once = uwsm app -- waybar
|
exec-once = uwsm app -- waybar
|
||||||
exec-once = clipse -listen
|
exec-once = uwsm app -- clipse -listen
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
scripts/arch/battery-monitor
Executable file
32
scripts/arch/battery-monitor
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
# Used with the systemd battery monitor service and timer to alert
|
||||||
|
# when the battery has dropped below the threshold and is not currently
|
||||||
|
# charging.
|
||||||
|
|
||||||
|
THRESHOLD=20 # Notify when below 20%
|
||||||
|
NOTIFICATION_FLAG="/run/user/${UID}/user_battery_notified"
|
||||||
|
|
||||||
|
function get-battery-percentage() {
|
||||||
|
local battery=$(upower --battery | grep percentage)
|
||||||
|
echo "${battery//[^0-9]/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function send-battery-alert() {
|
||||||
|
notify-send -u critical \
|
||||||
|
"Recharge battery!" "Batttery is down to ${1}" \
|
||||||
|
-i battery-caution \
|
||||||
|
-t 30000
|
||||||
|
}
|
||||||
|
|
||||||
|
battery_percentage=$(get-battery-percentage)
|
||||||
|
battery_state=$(upower --battery | grep -E state | awk '{print $2}')
|
||||||
|
|
||||||
|
if [[ "$battery_state" == "discharging" && "$battery_percentage" -le "$THRESHOLD" ]]; then
|
||||||
|
if [ ! -f "$NOTIFICATION_FLAG" ]; then
|
||||||
|
send-battery-alert "$battery_percentage"
|
||||||
|
touch "$NOTIFICATION_FLAG"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
rm -f "$NOTIFICATION_FLAG"
|
||||||
|
fi
|
||||||
@@ -6,3 +6,4 @@ espanso service register
|
|||||||
sudo setcap "cap_dac_override+p" $(which espanso)
|
sudo setcap "cap_dac_override+p" $(which espanso)
|
||||||
|
|
||||||
systemctl --user enable --now logout-task.service
|
systemctl --user enable --now logout-task.service
|
||||||
|
systemctl --user enable --now batter-monitor.timer
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ yay -S --noconfirm --needed \
|
|||||||
bc \
|
bc \
|
||||||
btop \
|
btop \
|
||||||
catppuccin-gtk-theme-mocha \
|
catppuccin-gtk-theme-mocha \
|
||||||
|
sddm-theme-catppuccin \
|
||||||
eza \
|
eza \
|
||||||
fastfetch \
|
fastfetch \
|
||||||
fzf \
|
fzf \
|
||||||
@@ -34,6 +35,7 @@ yay -S --noconfirm --needed \
|
|||||||
nodejs \
|
nodejs \
|
||||||
npm \
|
npm \
|
||||||
nwg-look \
|
nwg-look \
|
||||||
|
pam-u2f \
|
||||||
pcsc-tools \
|
pcsc-tools \
|
||||||
starship \
|
starship \
|
||||||
swaync \
|
swaync \
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ ln -sfv ~/.dotfiles/systemd ~/.config
|
|||||||
ln -sfv ~/.dotfiles/tree-sitter ~/.config
|
ln -sfv ~/.dotfiles/tree-sitter ~/.config
|
||||||
ln -sfv ~/.dotfiles/walker ~/.config
|
ln -sfv ~/.dotfiles/walker ~/.config
|
||||||
ln -sfv ~/.dotfiles/waybar ~/.config
|
ln -sfv ~/.dotfiles/waybar ~/.config
|
||||||
|
ln -sfv ~/.dotfiles/yubico ~/.config
|
||||||
|
|
||||||
# Espanso
|
# Espanso
|
||||||
espanso service stop
|
espanso service stop
|
||||||
|
|||||||
8
systemd/user/battery-monitor.service
Normal file
8
systemd/user/battery-monitor.service
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Battery Monitor Service
|
||||||
|
After=graphical-session.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=%h/.local/bin/battery-monitor
|
||||||
|
Environment=DISPLAY=:0
|
||||||
11
systemd/user/battery-monitor.timer
Normal file
11
systemd/user/battery-monitor.timer
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Battery Monitor Timer
|
||||||
|
Requires=battery-monitor.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1min
|
||||||
|
OnUnitActiveSec=30sec
|
||||||
|
AccuracySec=10sec
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
@define-color yellow #f9e2af;
|
@define-color yellow #f9e2af;
|
||||||
@define-color peach #fab387;
|
@define-color peach #fab387;
|
||||||
@define-color maroon #eba0ac;
|
@define-color maroon #eba0ac;
|
||||||
|
@define-color green #a6e3a1;
|
||||||
|
|
||||||
* {
|
* {
|
||||||
font-family: JetbrainsMono Nerd Font;
|
font-family: JetbrainsMono Nerd Font;
|
||||||
@@ -93,15 +94,15 @@
|
|||||||
|
|
||||||
#battery {
|
#battery {
|
||||||
border-radius: 10px 0px 0px 10px;
|
border-radius: 10px 0px 0px 10px;
|
||||||
color: #a6d189;
|
color: @green;
|
||||||
}
|
|
||||||
|
|
||||||
#battery.charging {
|
|
||||||
color: #a6d189;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#battery.warning:not(.charging) {
|
#battery.warning:not(.charging) {
|
||||||
color: #e78284;
|
color: @yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
#battery.critical:not(.charging) {
|
||||||
|
color: @red;
|
||||||
}
|
}
|
||||||
|
|
||||||
#backlight {
|
#backlight {
|
||||||
|
|||||||
Reference in New Issue
Block a user