diff options
| Commit | 3056b07286c61833f8caa5a2d7e784c441a29647 (patch) | |
|---|---|---|
| Author | 2026-11-01 18:07:05 +0200 | |
| Committer | 2026-11-01 18:07:05 +0200 | |
| Files | 88ad62aff3773850fbffab06a2d5c8f793a2c6f4 /openbox_de | |
| .files-3056b07286c61833f8caa5a2d7e784c441a29647.tar .files-3056b07286c61833f8caa5a2d7e784c441a29647.tar.gz .files-3056b07286c61833f8caa5a2d7e784c441a29647.zip | ||
| Parent | 442733b9e46e7adbd85709a53dfb85462896af7f (diff) | |
fix(openbox_de): Move openbox_de-related scripts to openbox_de
7 files changed, 232 insertions, 0 deletions
| -rwxr-xr-x | openbox_de/bin/autostart | 36 | ||||
| -rwxr-xr-x | openbox_de/bin/battery-status | 65 | ||||
| -rwxr-xr-x | openbox_de/bin/brightness-control | 28 | ||||
| -rwxr-xr-x | openbox_de/bin/lock | 51 | ||||
| -rwxr-xr-x | openbox_de/bin/on-logout | 18 | ||||
| -rwxr-xr-x | openbox_de/bin/start-panels | 27 | ||||
| -rwxr-xr-x | openbox_de/bin/toggle-desktop | 7 |
diff --git a/openbox_de/bin/autostart b/openbox_de/bin/autostart new file mode 100755 index 0000000..f6f75d5 --- /dev/null +++ b/openbox_de/bin/autostart @@ -0,0 +1,36 @@ +#!/bin/bash + +device="desktop" + +#[ $device = "desktop" ] && xrandr --output HDMI-A-0 --mode 1920x1080 --rate 100 --primary + +xhost +local: +~/.fehbg & # wallpaper +# lead & # hot corners, this is MageJohn's fork: https://github.com/MageJohn/lead +xcape -e 'Super_L=Super_L|P' & # used for the "windows" menu +rm -rf ~/.tmp/* + +$HOME/bin/start-panels & +picom & # compositor + +if [[ $device == "desktop" ]]; then + xset m 1 1 # disable mouse acceleration (not a very proper way to do it, I know) +fi + +if [[ $device == "laptop" ]]; then + # while :; do if grep -Fq "closed" /proc/acpi/button/lid/LID0/state; then ~/.a/sys/lock.sh suspend && sleep 3; fi; sleep 0.5; done & # lock screen on lid closing; you'll also need to uncomment the HandleLidSwitch variable and assign to it "lock" (HandleLidSwitch=lock) inside /etc/systemd/logind.conf + libinput-gestures-setup start & # start gestures + blueberry & # bluetooth app +fi + +pnmixer & # volume applet +nm-applet & # network applet +dunst-applet & # notification toggler https://gitlab.com/Syndamia/dunst-applet + +flameshot & # screenshot utility +redshift-gtk & # screen color temperature changer +copyq & # clipboard manager +barrier & # share mouse and keyboard between devices +nextcloud & # cloud/source control + +firefox-bin & diff --git a/openbox_de/bin/battery-status b/openbox_de/bin/battery-status new file mode 100755 index 0000000..4201b58 --- /dev/null +++ b/openbox_de/bin/battery-status @@ -0,0 +1,65 @@ +#!/bin/bash +[ "$HOSTNAME" == 'ceres' -o "$HOSTNAME" == 'vesta' ] && exit + +# Check for dependencies +for comm in upower awk; do + command -v upower >/dev/null 2>&1 || (echo "Error, missing command dependencies: $comm" && exit) +done + +# Prepare battery informatoin +for bat in BAT0 BAT1; do + upower -i "/org/freedesktop/UPower/devices/battery_$bat" > "/tmp/$bat" + [ "$(awk '/native-path/{print $2}' "/tmp/$bat")" = '(null)' ] && continue + + bat_state="$(awk '/state/{print substr($2, 1, 1)}' "/tmp/$bat")" + if [ $bat_state = 'c' ]; then bat_power_ind='' + elif [ $bat_state = 'd' ]; then bat_power_ind='' + else bat_power_ind='' + fi + + bat_per="$(awk '/percentage/{print strtonum($2)}' "/tmp/$bat")" + # bat_per=$((bat_per * 5 / 4 - 25)) # compensation for failing battery + + [ $bat_state = 'd' ] \ + && bat_time="$(awk '/time to empty/{print $4 substr($5, 1, 1)}' "/tmp/$bat")" \ + || bat_time="$(awk '/time to full/ {print $4 substr($5, 1, 1)}' "/tmp/$bat")" + + echo -n " $bat_power_ind ${bat_per}% $bat_time" + + # + # Notifications + # + + command -v notify-send >/dev/null 2>&1 || exit + [ ! -e "/tmp/bat_notif$bat" ] && touch "/tmp/bat_notif$bat" + bat_notif="$(cat "/tmp/bat_notif$bat")" + + + # Notify when battery is charged to 80% + if [ $bat_state = 'c' ]; then + if [ "$bat_notif" != 80 ] && [ $bat_per -ge 80 ]; then + notify-send -u normal -i battery-charging -t 999999 "$bat at 80%" + echo 80 > "/tmp/bat_notif$bat" + fi + + # Notify when battery discharges to 5%, 10%, 15% and 20% + elif [ $bat_state = 'd' ]; then + for per in 5 10 15 20; do + if [ "$bat_notif" = $per ]; then + break + elif [ $bat_per -le $per ]; then + notify-send -u critical -i battery-low -t 999999 "$bat at ${per}%" + echo $per > "/tmp/bat_notif$bat" + break + fi + done + + # Notify when battery is full + else + if [ "$bat_notif" != 100 ]; then + notify-send -u normal -i battery-full -t 999999 "$bat fully charged!" + echo 100 > "/tmp/bat_notif$bat" + fi + fi +done +echo diff --git a/openbox_de/bin/brightness-control b/openbox_de/bin/brightness-control new file mode 100755 index 0000000..3aa2139 --- /dev/null +++ b/openbox_de/bin/brightness-control @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ -z "$@" ] || ([ "$1" != "+" ] && [ "$1" != "-" ]); then + echo "Expected + or - as argument!" + exit 1 +fi + +# Percentage change depending on brightness +info=$(brightnessctl -m i | cut -d , -f 4) +info=${info::-1} + +change=5 +if [ "$info" -ge 70 ]; then + change=10 +fi + +# Brightness change +if [ "$1" == "+" ]; then + brightnessctl -q set "+${change}%" +elif [ "$info" -gt 5 ]; then # don't allow brightness to decrease to 0% + brightnessctl -q set "${change}%-" +fi + +# Notification for brightness +info=$(brightnessctl -m i) +perbright=$(echo $info | cut -d , -f 4) +notify-send "$(echo $info | cut -d , -f 1) +Brightness: $perbright" -t 1000 -h int:value:$perbright -h string:x-canonical-private-synchronous:anything -h string:x-canonical-private-synchronous:anything diff --git a/openbox_de/bin/lock b/openbox_de/bin/lock new file mode 100755 index 0000000..37fd08f --- /dev/null +++ b/openbox_de/bin/lock @@ -0,0 +1,51 @@ +#!/bin/bash +# Suspend is managed by elogind +# Refer to ~/.b/etc/elogind/logind.conf +# ~/.b/etc/elogind/system-sleep/run-lock.sh + +# ++=================================++ +# || Actions before and after unlock || +# ++=================================++ + +before_locking () { + # Disables dunst, my notification daemon, so I don't see notification on lock screen + # https://github.com/dunst-project/dunst/issues/697 + # https://wiki.archlinux.org/title/Dunst#Disable_dunst_temporarily + dunstctl set-paused true + + touch ~/.tmp/locksh-locked +} + +before_suspend () { + # Keep track of time when machine is suspended, as well as how long it has been up for + echo "$(date) $(uptime)" >> ~/bin/suspend-history +} + +when_unlocked () { + dunstctl set-paused false # Enables my notification daemon + + # Resets programs, in case resolution changes + ~/.fehbg # wallpaper + + rm ~/.tmp/locksh-locked +} + +# ++============================++ +# || Lock if not locked already || +# ++============================++ + +if [ ! -f ~/.tmp/locksh-locked ]; then + [ "$1" == 'suspend' ] && before_suspend + # The first line of i3lock arguments uses standard arguments, while the rest of the lines are i3lock-color ones + # If you want to use i3lock, remove those lines (and the \ at the end) + # But I highly advise you to use i3lock-color, it's amazing: https://github.com/Raymo111/i3lock-color + before_locking && \ + i3lock -f -c d49408 -i ~/bin/lockscreen.png -n \ + -k --indicator --keylayout 1 --radius 95 --pass-volume-keys \ + --date-str='%d.%m.%Y' --verif-text='Verifying…' --wrong-text='Wrong!' --noinput-text='No Input!' \ + --insidever-color d47408cc --ringver-color d47408 --insidewrong-color c35b5bcc --ringwrong-color c35b5b \ + --layout-color ffeede --time-color ffeede --date-color ffeede --greeter-color ffeede --verif-color ffeede --wrong-color ffeede \ + ; when_unlocked +else + echo "Not locking, lockfile exists!" +fi diff --git a/openbox_de/bin/on-logout b/openbox_de/bin/on-logout new file mode 100755 index 0000000..8be0a81 --- /dev/null +++ b/openbox_de/bin/on-logout @@ -0,0 +1,18 @@ +#!/bin/bash + +# Gracefully close certain programs +grace=() +gui=(brave firefox-bin) + +for app in $grace; do + timeout 5 pkill -TERM $app +done + +for app in $gui; do + wmctrl -c $app + while [ -n "$(pidof $app)" ]; do + sleep 1 + done +done + +exit 0 diff --git a/openbox_de/bin/start-panels b/openbox_de/bin/start-panels new file mode 100755 index 0000000..9184f6c --- /dev/null +++ b/openbox_de/bin/start-panels @@ -0,0 +1,27 @@ +#!/bin/bash + +pkill tint2 >/dev/null 2>&1 || true + +local_tint2() { + workspace="$1" + shift + + tint2 "$@" >/dev/null 2>&1 & + + wid="" + while [ -z "$wid" ] + do + wid="$(wmctrl -l | awk '$2 == -1 && $4 == "tint2" && $5 == "" { print $1 }')" + sleep 0.2 + done + + sleep 0.1 + wmctrl -i -r "$wid" -t "$workspace" +} + +local_tint2 0 -c $HOME/.config/tint2/tint2rc +local_tint2 1 -c $HOME/.config/tint2/programmer.tint2rc +local_tint2 2 -c $HOME/.config/tint2/work.tint2rc +local_tint2 3 -c $HOME/.config/tint2/gaming.tint2rc + +tint2 -c $HOME/.config/tint2/switcher.tint2rc >/dev/null 2>&1 & diff --git a/openbox_de/bin/toggle-desktop b/openbox_de/bin/toggle-desktop new file mode 100755 index 0000000..b5906bc --- /dev/null +++ b/openbox_de/bin/toggle-desktop @@ -0,0 +1,7 @@ +#!/bin/bash + +if xprop -root _NET_SHOWING_DESKTOP | egrep '= 1' > /dev/null; then + wmctrl -k off +else + wmctrl -k on +fi |
