summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-11-21 12:37:35 +0200
committerKyren223 <Kyren223@proton.me>2024-11-21 12:37:35 +0200
commit43e8afe80486b805a3d93b1f46d17cb886455f81 (patch)
treed5267ad8efd2cc0bcb15985cea0057fcefa88f32
parent979a45d376bb120724bf28a0bbaed03321169ffa (diff)
Trying some stuff with clipboard and battery notification
-rw-r--r--.zshrc2
-rw-r--r--hosts/laptop-nixos/configuration.nix23
-rw-r--r--hosts/laptop-nixos/home.nix3
-rwxr-xr-xscripts/battery_notifier.sh23
4 files changed, 50 insertions, 1 deletions
diff --git a/.zshrc b/.zshrc
index 97eda7d..d2ab55e 100644
--- a/.zshrc
+++ b/.zshrc
@@ -54,7 +54,7 @@ setopt hist_ignore_dups
setopt hist_find_no_dups
# Aliases
-alias cat='bat'
+# alias cat='bat'
alias ls='eza'
alias tree='eza --tree'
alias c='clear'
diff --git a/hosts/laptop-nixos/configuration.nix b/hosts/laptop-nixos/configuration.nix
index 4a80055..949f643 100644
--- a/hosts/laptop-nixos/configuration.nix
+++ b/hosts/laptop-nixos/configuration.nix
@@ -109,6 +109,29 @@
# Services
services.openssh.enable = true;
+ # battery levels notifier
+ systemd.timers."battery-notifier" = {
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ OnBootSec = "1m";
+ OnUnitActiveSec = "1m";
+ Unit = "battery-notifier.service";
+ };
+ };
+
+ systemd.services."battery-notifier" = {
+ script = ''
+ set -eu
+ export DISPLAY=:0.0
+ touch $HOME/Desktop/EEEEEEE
+ $HOME/scripts/battery_notifier.sh
+ '';
+ serviceConfig = {
+ Type = "oneshot";
+ User = "kyren";
+ };
+ };
+
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
diff --git a/hosts/laptop-nixos/home.nix b/hosts/laptop-nixos/home.nix
index f89e297..7b31b5a 100644
--- a/hosts/laptop-nixos/home.nix
+++ b/hosts/laptop-nixos/home.nix
@@ -48,6 +48,9 @@
python3Full
watchexec
golangci-lint
+ kdePackages.kdialog
+ xclip
+ libnotify
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
diff --git a/scripts/battery_notifier.sh b/scripts/battery_notifier.sh
new file mode 100755
index 0000000..17e77f8
--- /dev/null
+++ b/scripts/battery_notifier.sh
@@ -0,0 +1,23 @@
+set -eu
+export DISPLAY=:0.0
+export XAUTHORIRTY=/home/kyren/.Xauthority
+
+
+echo "$DISPLAY, $XAUTHORIRTY" >> "$HOME/Desktop/debug.log"
+
+battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
+battery_status=$(cat /sys/class/power_supply/BAT0/status)
+echo "$battery_level% $battery_status" >> "$HOME/Desktop/debug.log"
+
+/etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
+ --app-name="Battery Notifier" \
+ --expire-time=5000 \
+ "Battery at $battery_level%, unplug!" >> "$HOME/Desktop/debug.log" 2>&1
+
+if [ "$battery_status" = "Charging" ] && [ "$battery_level" -ge 80 ]; then
+ touch "$HOME/Desktop/WHY"
+ /etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
+ --app-name="Battery Notifier" \
+ --expire-time=5000 \
+ "Battery at $battery_level%, unplug!" >> "$HOME/Desktop/debug.log" 2>&1
+fi