1
0
Fork 0

move dwm scripts

This commit is contained in:
Luca Bilke 2024-02-03 17:52:59 +01:00
parent 229a242c97
commit 7b560c9966
3 changed files with 34 additions and 47 deletions

View file

@ -1,36 +0,0 @@
#!/bin/sh
# This script is used by DWM to start programs when it starts
# It's meant as a sort of wrapper script to start a long running program and have it log to a file.
# Some examples:
# env LOGFILE=~/test.log start pipewire
# start pipewire; tail -f ~/.local/log/pipewire.log
LOGFILE="${LOGFILE:-${HOME}/.local/log/${1}.log}"
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
NC="$(tput sgr0)"
infolog() {
while IFS= read -r line; do
echo "[$(date +%X)][${BOLD}${GREEN}INF${NC}][$1] $line" >>"${LOGFILE}"
done
}
errorlog() {
while IFS= read -r line; do
echo "[$(date +%X)][${BOLD}${RED}ERR${NC}][$1] $line" >>"${LOGFILE}"
done
}
stdout="$XDG_RUNTIME_DIR/dwm-stdout"
stderr="$XDG_RUNTIME_DIR/dwm-stderr"
[ -p "$stdout" ] || mkfifo "$stdout"
[ -p "$stderr" ] || mkfifo "$stderr"
cat <"$stdout" | infolog "$1" &
cat <"$stderr" | errorlog "$1" &
pidof -sx "$1" || "$@" >"$stdout" 2>"$stderr"

View file

@ -1,17 +1,43 @@
#!/bin/sh
# This script is executed by DWM on start.
# It should be used to start programs that need access to the session dbus or the display
# Set keymaps
LOGFILE="${LOGFILE:-${HOME}/.local/log/${1}.log}"
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
NC="$(tput sgr0)"
infolog() {
while IFS= read -r line; do
echo "[$(date +%X)][${BOLD}${GREEN}INF${NC}][$1] $line" >>"${LOGFILE}"
done
}
errorlog() {
while IFS= read -r line; do
echo "[$(date +%X)][${BOLD}${RED}ERR${NC}][$1] $line" >>"${LOGFILE}"
done
}
start() {
stdout="$XDG_RUNTIME_DIR/dwm-stdout"
stderr="$XDG_RUNTIME_DIR/dwm-stderr"
[ -p "$stdout" ] || mkfifo "$stdout"
[ -p "$stderr" ] || mkfifo "$stderr"
cat <"$stdout" | infolog "$1" &
cat <"$stderr" | errorlog "$1" &
pidof -sx "$1" || "$@" >"$stdout" 2>"$stderr"
}
remaps -qd
# Set wallpaper
xwallpaper --zoom "$XDG_DATA_HOME/bg"
# Autohide mouse cursor
unclutter -noevents &
start gpgconf --launch gpg-agent
start dwmlocks
start pipewire
start dunst
# Set up xsecurelock
xset s 300
env \

View file

@ -3,10 +3,7 @@
ctl='loginctl'
case "$(printf "󰌾 lock\n󰗼 leave dwm\n󰑙 renew dwm\n󰜉 reboot\n⏻ shutdown\n󰶐 display off" | dmenu -i -p 'Action: ')" in
'󰌾 lock')
xset s activate &
gpg-connect-agent --no-autostart reloadagent /bye
;;
'󰌾 lock') xset s activate ;;
'󰗼 leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
'󰑙 renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
'⏼ hibernate') $ctl hibernate -i ;;