aboutsummaryrefslogtreecommitdiff
path: root/x
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2023-05-31 22:46:32 -0600
committerBryson Steck <brysonsteck@protonmail.com>2023-05-31 22:46:32 -0600
commit698a8a7f30b2a22672b677078fcfe5ac698020da (patch)
treefb4d9096733b9dba52620f72fe1d3fe22ed53626 /x
parent3991ac66a5269986b066338c404daea026b4ecbb (diff)
downloaddotfiles-698a8a7f30b2a22672b677078fcfe5ac698020da.tar
dotfiles-698a8a7f30b2a22672b677078fcfe5ac698020da.tar.gz
dotfiles-698a8a7f30b2a22672b677078fcfe5ac698020da.tar.bz2
some more x scripts
Diffstat (limited to 'x')
-rwxr-xr-xx/battery.pl6
-rwxr-xr-xx/quitconf8
-rwxr-xr-xx/spawn-alacritty.sh37
3 files changed, 48 insertions, 3 deletions
diff --git a/x/battery.pl b/x/battery.pl
index b98707a..10a3673 100755
--- a/x/battery.pl
+++ b/x/battery.pl
@@ -22,13 +22,13 @@ while (1) {
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.\""
+ system "notify-send -i \"battery-empty-symbolic\" -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.\""
+ system "notify-send -i \"battery-caution-symbolic\" -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.\"";
@@ -40,7 +40,7 @@ while (1) {
$CRITICAL = undef;
$LOW = undef;
system "doas shutdown -c";
- system "notify-send -t 3000 -i \"battery-good-charging\" \"System is now charging\"";
+ system "notify-send -t 3000 -i \"battery-good-charging-symbolic\" \"System is now charging\"";
}
}
diff --git a/x/quitconf b/x/quitconf
new file mode 100755
index 0000000..68f8e61
--- /dev/null
+++ b/x/quitconf
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+input=$(printf "no\nyes" | dmenu -m $1 -fn "JetBrains Mono NF:style=medium:size=11" -nb $2 -nf $3 -sb "#cc241d" -sf $4 -p "Quit dwm?")
+
+if [ "$input" = "yes" ]; then
+ killall dwm
+fi
+
diff --git a/x/spawn-alacritty.sh b/x/spawn-alacritty.sh
new file mode 100755
index 0000000..7292478
--- /dev/null
+++ b/x/spawn-alacritty.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Stole from https://github.com/alacritty/alacritty/issues/808#issuecomment-334200570
+#
+# Spawn a new instance of Alacritty using the CWD of the currently focused
+# Alacritty process.
+#
+# This is useful in environment like i3 where terminals are opened using a
+# key-combination while another terminal is already focused.
+#
+# If the script is run with a non-Alacritty window in focus or a non-compliant
+# version of Alacritty, an instance will be spawned in the user's $HOME.
+
+ACTIVE_WINDOW=$(xdotool getactivewindow)
+ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS)
+if [[ $ACTIVE_WM_CLASS == *"Alacritty"* ]]
+then
+ # Get PID. If _NET_WM_PID isn't set, bail.
+ PID=$(xprop -id $ACTIVE_WINDOW | grep _NET_WM_PID | grep -oP "\d+")
+ if [[ "$PID" == "" ]]
+ then
+ WINIT_X11_SCALE_FACTOR=1 alacritty
+ fi
+ # Get first child of terminal
+ CHILD_PID=$(pgrep -P $PID)
+ if [[ "$PID" == "" ]]
+ then
+ WINIT_X11_SCALE_FACTOR=1 alacritty
+ fi
+ # Get current directory of child. The first child should be the shell.
+ pushd "/proc/${CHILD_PID}/cwd"
+ SHELL_CWD=$(pwd -P)
+ popd
+ # Start alacritty with the working directory
+ WINIT_X11_SCALE_FACTOR=1 alacritty --working-directory "$SHELL_CWD"
+else
+ WINIT_X11_SCALE_FACTOR=1 alacritty
+fi