Summary Files Commits Branches @commit @diff @stats
path: root / scripts
diff options
context:
space:
mode:
Commit375d11b33142e971a82f28ddb4cc7d386e3551cf (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-11-01 17:50:07 +0200
Committer
 Syndamia <kamen@syndamia.com>
2026-11-01 17:50:07 +0200
Files85373ae415fcff7142ee1194594e8bb1e381176b /scripts
.files-375d11b33142e971a82f28ddb4cc7d386e3551cf.tar
.files-375d11b33142e971a82f28ddb4cc7d386e3551cf.tar.gz
.files-375d11b33142e971a82f28ddb4cc7d386e3551cf.zip
Parente41b78ee956a6adcfc07b3c453f70198214ca599 (diff)
feat!: Rework how .files are managed
9 files changed, 417 insertions, 0 deletions
-rwxr-xr-xscripts/bin/autostart36
-rwxr-xr-xscripts/bin/battery-status65
-rwxr-xr-xscripts/bin/brightness-control28
-rwxr-xr-xscripts/bin/lock51
-rwxr-xr-xscripts/bin/on-logout18
-rwxr-xr-xscripts/bin/plumb81
-rwxr-xr-xscripts/bin/rclone.sh104
-rwxr-xr-xscripts/bin/start-panels27
-rwxr-xr-xscripts/bin/toggle-desktop7
diff --git a/scripts/bin/autostart b/scripts/bin/autostart
new file mode 100755
index 0000000..0473e7b
--- /dev/null
+++ b/scripts/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/.scripts/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/scripts/bin/battery-status b/scripts/bin/battery-status
new file mode 100755
index 0000000..4201b58
--- /dev/null
+++ b/scripts/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/scripts/bin/brightness-control b/scripts/bin/brightness-control
new file mode 100755
index 0000000..3aa2139
--- /dev/null
+++ b/scripts/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/scripts/bin/lock b/scripts/bin/lock
new file mode 100755
index 0000000..e0f8365
--- /dev/null
+++ b/scripts/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)" >> ~/.scripts/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 ~/.scripts/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/scripts/bin/on-logout b/scripts/bin/on-logout
new file mode 100755
index 0000000..8be0a81
--- /dev/null
+++ b/scripts/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/scripts/bin/plumb b/scripts/bin/plumb
new file mode 100755
index 0000000..6f42d7c
--- /dev/null
+++ b/scripts/bin/plumb
@@ -0,0 +1,81 @@
+#/bin/bash
+
+
+#
+# Get selection text and go to window directory
+#
+
+selection="$(xclip -o)"
+
+# Copied from https://odysee.com/@Luke:7/plumbing-in-linux-la-plan-9-from-bell:e
+pid=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
+pid1=$(pstree -lpA "$pid" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
+cd "$(readlink /proc/"$pid1"/cwd)"
+
+wname="$(cat /proc/"$pid"/comm)"
+if [ $wname == "terminator" ]; then
+ xdotool key Control+Alt+Page_Up
+ sleep 0.1
+ cd "$(cat /tmp/plumb-cwd)"
+fi
+
+#
+# Create jgmenu menu
+#
+
+menu=""
+if [ -z "$1" ]; then
+ function matches() {
+ echo "$selection" | grep "$1" >/dev/null 2>&1
+ }
+
+ # Settings, 1 for include in menu, 0 for don't include
+ plan9=0
+ runInTerminal=1
+
+ # -= Plan 9 functions =-
+ [ $plan9 -eq 1 ] && menu+="Send,echo 2\nResize,echo 3\nMove,echo 4\n"
+
+ # -= Run =-
+ if [ $runInTerminal -eq 1 ]; then
+ [ $wname == "terminator" ] && [ $plan9 -ne 1 ] && menu+="Send,echo 2\n"
+ [ $wname == "terminator" ] && menu+="Exec,echo 5\n" \
+ || menu+="Exec,echo 6\n"
+ fi
+ #matches "[[:alnum:]]*" && menu+="Run,echo 2\n"
+ #matches ".*\.cpp" && menu+="Build and run,echo 2\n"
+fi
+
+#
+# Execution menu option
+#
+
+if [ -z "$1" ]; then
+ action=$(echo -ne "$menu" | jgmenu --at-pointer --simple --config-file="$HOME/.config/jgmenu/jgmenusimplerc")
+else
+ action="1"
+fi
+
+case "$action" in
+ 1) xdg-open "$selection"
+ ;;
+ 2) xdotool type --delay 0 "$selection"
+ ;;
+ 3) xdotool keydown Alt
+ xdotool mousedown 3
+ xdotool keyup Alt
+ ;;
+ 4) xdotool keydown Alt
+ xdotool mousedown 1
+ xdotool keyup Alt
+ ;;
+ 5) terminator --new-tab --command="zsh $selection" &
+ disown
+ ;;
+ 6) terminator --command="$selection" &
+ disown
+ ;;
+ *)
+ notify-send "Bad action!"
+ ;;
+esac
diff --git a/scripts/bin/rclone.sh b/scripts/bin/rclone.sh
new file mode 100755
index 0000000..c8e0e16
--- /dev/null
+++ b/scripts/bin/rclone.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+: ${PREFIX:=$HOME/mnt} ${TITLE:=rclone helper} ${ICON=rclone-browser}
+FIELDS_BEFORE=1
+
+KDBX_MOUNTED="$PREFIX/FTP marduk.int kamen"
+: ${KDBX_REMOTE_DIR:="Secret"}
+: ${KDBX_LOCAL_DIR:='/mnt/Svalbard/Doc/Adulthood/Vault'}
+
+yad_ok() {
+ echo "$2" | yad --title="$TITLE" --window-icon="$ICON" --borders=10 --text-info \
+ --text="$1" \
+ --button="yad-ok:0" &
+ disown
+}
+
+# Run window
+if [ $# -eq 0 ]
+then
+ eval "yad --title='$TITLE' --window-icon='$ICON' --borders=10 --fixed --no-buttons --form \
+ --field='<span size=\"x-large\" weight=\"bold\">rclone mount</span>:LBL' '' \
+ $(rclone listremotes | awk -v ORS=' ' '
+ {
+ sub(/:$/,"");sub(/^[ \t\v]*/,"");sub(/[ \t\v]*$/,"")
+ print "--field=\"" $0 ":SW\" \"" (system("mount | grep \"" $0 "\" >/dev/null")==0?"TRUE":"FALSE") "\""
+ }') \
+ --changed-action='$0' \
+ --field='<span size=\"x-large\" weight=\"bold\">KDBX sync</span>:LBL' '' \
+ --field='Download KDBX:FBTN' '$0 kdbx download' \
+ --field='Upload KDBX:FBTN' '$0 kdbx upload' \
+ "
+# KDBX sync
+elif [ "$1" = 'kdbx' ]
+then
+ if ! mount | grep "$KDBX_MOUNTED" >/dev/null
+ then
+ yad_ok "Directory not mounted!" "$KDBX_MOUNTED"
+ exit 1
+ fi
+
+ if [ "$2" = 'download' ]
+ then
+ if [ ! -f "$KDBX_MOUNTED/$KDBX_REMOTE_DIR/hash_md5.txt" ]
+ then
+ yad_ok "Missing file!" "$KDBX_MOUNTED/$KDBX_REMOTE_DIR/hash_md5.txt"
+ exit 2
+ fi
+
+ yad --title="$TITLE" --window-icon="$ICON" --borders=10 \
+ --image=dialog-warning --text="Are you sure you want to <b>download</b> KDBX files?\nThis will overwrite <b>local</b> copies!" \
+ --button="yad-yes:0" --button="yad-no:1" || exit 0
+
+ cd "$KDBX_MOUNTED/$KDBX_REMOTE_DIR"
+
+ if ! md5sum -c ./hash_md5.txt >/dev/null 2>&1
+ then
+ yad_ok "Checksum check failed!" "$(md5sum -c --quiet ./hash_md5.txt)"
+ exit 3
+ fi
+
+ while read -r kdbx
+ do
+ kdbx_hash="$(echo "$kdbx" | cut -c-32)"
+ kdbx_path="$(echo "$kdbx" | cut -c35-)"
+
+ cp -f "$kdbx_path" "$KDBX_LOCAL_DIR/$kdbx_path"
+ done <"$KDBX_MOUNTED/$KDBX_REMOTE_DIR/hash_md5.txt"
+ else
+ yad --title="$TITLE" --window-icon="$ICON" --borders=10 \
+ --image=dialog-question --text="Are you sure you want to <b>upload</b> KDBX files?\nThis will overwrite <b>remote</b> copies!" \
+ --button="yad-yes:0" --button="yad-no:1" || exit 0
+
+ mkdir -p "$KDBX_MOUNTED/$KDBX_REMOTE_DIR"
+ cd "$KDBX_MOUNTED/$KDBX_REMOTE_DIR"
+
+ cp -f "$KDBX_LOCAL_DIR"/*.kdbx .
+ md5sum *.kdbx >hash_md5.txt
+ fi
+# Mount/unmount
+else
+ remote_info="$(rclone listremotes --long | awk -v FIELD="$1" -v OFFSET="$FIELDS_BEFORE" 'BEGIN{row=FIELD-OFFSET}NR==row{gsub(/:/,"");print;exit}')"
+
+ if [ -z "$remote_info" ]
+ then
+ yad_ok 'Invalid field data!' "$*"
+ exit 1
+ fi
+
+ remote="$(echo "$remote_info" | awk '{$NF="";sub(/^[ \t\v]*/,"");sub(/[ \t\v]$/,"");print}')"
+ remote_type="$(echo "$remote_info" | awk '{print toupper($NF)}')"
+
+ dir="$PREFIX/$remote_type $remote"
+ mkdir -p "$dir"
+
+ if [ 'FALSE' = "$2" ]
+ then
+ umount "$dir" >/dev/tty
+ elif mount | grep "$dir" >/dev/null
+ then
+ yad_ok 'Directory is already mounted!' "$dir"
+ else
+ rclone mount "$remote:/" "$dir" --daemon &>/dev/null
+ fi
+fi
diff --git a/scripts/bin/start-panels b/scripts/bin/start-panels
new file mode 100755
index 0000000..9184f6c
--- /dev/null
+++ b/scripts/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/scripts/bin/toggle-desktop b/scripts/bin/toggle-desktop
new file mode 100755
index 0000000..b5906bc
--- /dev/null
+++ b/scripts/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