aboutsummaryrefslogtreecommitdiff
path: root/x
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2022-12-11 01:03:47 -0700
committerBryson Steck <brysonsteck@protonmail.com>2022-12-11 01:03:47 -0700
commitc32ed90899dd1047bc8bab171a60d7de6f4af34f (patch)
tree5cfeb8677f468814eae9ca29fad2fe39a46098f5 /x
parent173a51d4ae7ebca7e9b7d175ba314ff35a60d5ab (diff)
downloaddotfiles-c32ed90899dd1047bc8bab171a60d7de6f4af34f.tar
dotfiles-c32ed90899dd1047bc8bab171a60d7de6f4af34f.tar.gz
dotfiles-c32ed90899dd1047bc8bab171a60d7de6f4af34f.tar.bz2
update stuff, add relevant x scripts
Diffstat (limited to 'x')
-rw-r--r--x/.xinitrc2
-rw-r--r--x/.xinitrc-not-docked1
-rwxr-xr-xx/battery.pl48
-rwxr-xr-xx/startdwm.sh16
4 files changed, 66 insertions, 1 deletions
diff --git a/x/.xinitrc b/x/.xinitrc
index efd3270..dee608b 100644
--- a/x/.xinitrc
+++ b/x/.xinitrc
@@ -46,7 +46,7 @@ fi
#spotifyd &
# set up monitors
-sh ~/.screenlayout/screenlayout.sh &
+sh ~/.config/screenlayout.sh &
# set default audio device to be dock audio jack
pulseaudio -k && pacmd set-default-sink alsa_output.usb-0c76_USB_PnP_Audio_Device-00.analog-stereo &
diff --git a/x/.xinitrc-not-docked b/x/.xinitrc-not-docked
index 51aa3ae..b18ab1c 100644
--- a/x/.xinitrc-not-docked
+++ b/x/.xinitrc-not-docked
@@ -1,3 +1,4 @@
+#!/bin/sh
# executed by startx-not-docked
# for use when dingo is NOT docked
export DOCKED=false
diff --git a/x/battery.pl b/x/battery.pl
new file mode 100755
index 0000000..b98707a
--- /dev/null
+++ b/x/battery.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/env perl
+$| = 1;
+
+my $CRITICAL = undef;
+my $LOW = undef;
+my $CHARGING = undef;
+my $DEAD_LEVEL = 2;
+my $CRITICAL_LEVEL = 5;
+my $LOW_LEVEL = 10;
+
+while (1) {
+ my @acpi = split " ", `acpi | grep "Discharging" | grep -v "rate information"`;
+ my $battery_level = $acpi[3];
+ my $status = $acpi[2];
+ my $sent = undef;
+ $battery_level =~ s/%,//g;
+ $status =~ s/,//g;
+
+ if ($status =~ "Discharging") {
+ $CHARGING = undef;
+ if (!$CRITICAL) {
+ if (int($battery_level) <= int($CRITICAL_LEVEL)) {
+ $CRITICAL = 'def';
+ $sent = 'def';
+ system "notify-send -i \"battery-empty\" -t 0 -u critical \"BATTERY CRITICAL\" \"Battery level is ${battery_level}%\n\nCharge the system NOW.\""
+ }
+ } if (!$LOW && !$sent) {
+ if (int($battery_level) <= int($LOW_LEVEL)) {
+ $LOW = 'def';
+ $sent = 'def';
+ system "notify-send -i \"battery-caution\" -t 0 -u normal \"BATTERY LOW\" \"Battery level is ${battery_level}%\n\nCharge the system soon.\""
+ }
+ } if (int($battery_level) <= int($DEAD_LEVEL)) {
+ system "notify-send -t 0 -u critical \"SHUTTING DOWN\" \"Battery level is too low. The system will shutdown in 2 minutes to prevent corruption.\n\nCharge the system NOW to cancel the shutdown.\"";
+ system "doas shutdown -Ph 2 &";
+ }
+ } else {
+ if (!$CHARGING) {
+ $CHARGING = 'def';
+ $CRITICAL = undef;
+ $LOW = undef;
+ system "doas shutdown -c";
+ system "notify-send -t 3000 -i \"battery-good-charging\" \"System is now charging\"";
+ }
+ }
+
+ sleep 30;
+}
diff --git a/x/startdwm.sh b/x/startdwm.sh
new file mode 100755
index 0000000..4625951
--- /dev/null
+++ b/x/startdwm.sh
@@ -0,0 +1,16 @@
+# stolen from https://wiki.archlinux.org/title/Dwm#Restart_dwm
+# relaunch DWM if the binary changes, otherwise bail
+csum=""
+new_csum=$(sha1sum $(which dwm))
+while true
+do
+ if [ "$csum" != "$new_csum" ]
+ then
+ csum=$new_csum
+ dbus-launch dwm
+ else
+ exit 0
+ fi
+ new_csum=$(sha1sum $(which dwm))
+ sleep 0.5
+done