1
0
Fork 0

create scripts to be used by dwm autostart

This commit is contained in:
Luca Bilke 2024-01-31 01:00:36 +01:00
parent a279b37728
commit ca86ba3b64
4 changed files with 139 additions and 0 deletions

39
.config/dwm/autostart.sh Normal file
View file

@ -0,0 +1,39 @@
#!/bin/sh
# Set keymaps
remaps -qd
# Set wallpaper
xwallpaper --zoom "$XDG_DATA_HOME/bg"
# Autohide mouse cursor
unclutter -noevents &
# Set up xsecurelock
xset s 300
env \
XSECURELOCK_AUTH_BACKGROUND_COLOR="#24283b" \
XSECURELOCK_AUTH_FOREGROUND_COLOR="#c0caf5" \
XSECURELOCK_AUTH_WARNING_COLOR="#f7768e" \
XSECURELOCK_BACKGROUND_COLOR="#15161E" \
XSECURELOCK_DATETIME_FORMAT="%d.%m.%Y %H:%M" \
XSECURELOCK_PASSWORD_PROMPT="time_hex" \
XSECURELOCK_AUTH_TIMEOUT=5 \
XSECURELOCK_BLANK_TIMEOUT=30 \
XSECURELOCK_BLANK_DPMS_STATE="off" \
XSECURELOCK_BURNIN_MITIGATION=0 \
XSECURELOCK_DIM_FPS=60 \
XSECURELOCK_SHOW_DATETIME=1 \
XSECURELOCK_SAVER="/usr/libexec/xscreensaver/cubicgrid" \
XSECURELOCK_SHOW_USERNAME=1 \
XSECURELOCK_SHOW_HOSTNAME=1 \
xss-lock -n /usr/libexec/xsecurelock/dimmer -l -- sh -c "xsecurelock -- playerctl pause || kill -9 -1" &
# Run host autostart
"$XDG_CONFIG_HOME/dwm/host.sh" &
# Check for updates
checkup &
# start some programs

50
.config/dwm/default.sh Normal file
View file

@ -0,0 +1,50 @@
#!/bin/sh
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" &
# shellcheck disable=2068
pidof -sx "$1" || $@ >"$stdout" 2>"$stderr"
}
# Set up xsecurelock
xset s 300
env \
XSECURELOCK_AUTH_BACKGROUND_COLOR="#24283b" \
XSECURELOCK_AUTH_FOREGROUND_COLOR="#c0caf5" \
XSECURELOCK_AUTH_WARNING_COLOR="#f7768e" \
XSECURELOCK_BACKGROUND_COLOR="#15161E" \
XSECURELOCK_DATETIME_FORMAT="%d.%m.%Y %H:%M" \
XSECURELOCK_PASSWORD_PROMPT="time_hex" \
XSECURELOCK_AUTH_TIMEOUT=5 \
XSECURELOCK_BLANK_TIMEOUT=30 \
XSECURELOCK_BLANK_DPMS_STATE="off" \
XSECURELOCK_BURNIN_MITIGATION=0 \
XSECURELOCK_DIM_FPS=60 \
XSECURELOCK_SHOW_DATETIME=1 \
XSECURELOCK_SAVER="/usr/libexec/xscreensaver/cubicgrid" \
XSECURELOCK_SHOW_USERNAME=1 \
XSECURELOCK_SHOW_HOSTNAME=1 \
xss-lock -n /usr/libexec/xsecurelock/dimmer -l -- sh -c "xsecurelock -- playerctl pause || kill -9 -1" &

10
.config/dwm/host.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
xrandr \
--output HDMI-0 --mode 1920x1080 --pos 0x360 --rotate normal \
--output DP-0 --off \
--output DP-1 --off \
--output DP-2 --mode 2560x1440 --pos 1920x0 --rotate normal \
--output DP-3 --off \
--output DP-4 --off \
--output DP-5 --off \
--output USB-C-0 --off

40
.config/dwm/start Executable file
View file

@ -0,0 +1,40 @@
#!/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
}
# shellcheck disable=1073,1072
() {
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" &
# shellcheck disable=2068
pidof -sx "$1" || $@ >"$stdout" 2>"$stderr"
} $@