Files
dotfiles/autostart.sh

123 lines
2.8 KiB
Bash
Raw Normal View History

2018-12-28 18:19:00 +01:00
#!/usr/bin/env bash
set -o nounset
run_raw() {
name="$1"
shift
systemd-run \
--user \
--unit "${name}" \
--no-block \
--remain-after-exit \
--setenv=DISPLAY=${DISPLAY} \
"${@}"
}
run() {
name="$1"
shift
run_raw "$name" --property=Restart=always "${@}"
}
run_oneshot_multiple() {
name="$1"
shift
cmd=()
# hacky way to start two processes in oneshot mode
for c in "${@}" ; do
cmd+=(--property "ExecStart=/usr/bin/env ${c}")
done
cmd+=(true)
run_oneshot "$name" "${cmd[@]}"
}
run_oneshot() {
name="$1"
shift
run_raw "$name" --service-type=oneshot "${@}"
}
schedule() {
name="$1"; shift
spec="$1"; shift
systemd-run \
--user \
--unit "${name}" \
--no-block \
--setenv=DISPLAY=${DISPLAY} \
--on-calendar="${spec}" \
"${@}"
}
# redshift settings
redshift_lat_long="49.5:11"
redshift_colortemp="6000:4000"
# wallpaper config
wallpaper="$LIBDIR/wallpaper/current"
# keyboard settings
keyboard_layout=de
keyboard_variant=nodeadkeys
keyboard_repeat_delay=150
keyboard_repeat_speed=50
run_oneshot acpi bash -c 'grep "^${ACPI_LID_NAME}.*enabled" /proc/acpi/wakeup && echo " ${ACPI_LID_NAME}" | sudo tee /proc/acpi/wakeup'
run_oneshot xresources xrdb -merge -I${HOME} ~/.Xresources
run_oneshot_multiple keyboard \
"setxkbmap -layout $keyboard_layout -variant $keyboard_variant" \
"xset r rate $keyboard_repeat_delay $keyboard_repeat_speed"
run_oneshot_multiple touchpad \
"synclient VertEdgeScroll=0" \
"synclient VertTwoFingerScroll=1" \
"synclient MaxSpeed=2.2" \
"synclient AccelFactor=0.08" \
"synclient TapButton1=1" \
"synclient CoastingSpeed=0" \
"synclient PalmDetect=1" \
"synclient PalmMinWidth=20" \
"synclient PalmMinZ=180"
run_oneshot pulseaudio start-pulseaudio-x11 --start --daemonize=false --fail=true --log-target=stderr
2019-04-16 20:10:47 +02:00
run gpg-agent gpg-agent --homedir "$HOME/.gnupg" --no-detach --daemon
2018-12-28 18:19:00 +01:00
# a service called dunst already exists and conflicts
run dunst_user dunst -config ~/.config/dunstrc
2019-04-16 20:11:24 +02:00
run compton compton --backend glx --vsync opengl --no-dock-shadow --no-dnd-shadow
2018-12-28 18:19:00 +01:00
2019-04-16 20:11:24 +02:00
run_oneshot wallpaper --property=ExecStartPre="/bin/sleep 1" feh --bg-scale "${wallpaper}"
2018-12-28 18:19:00 +01:00
run blueman blueman-applet
run nm-applet nm-applet
run pasystray pasystray
run redshift redshift-gtk -b 1 -l "$redshift_lat_long" -t "$redshift_colortemp"
if [[ "${MACHINE_HAS_KEEPASSX}" ]] ; then
run keepassx keepassx --keyfile ~/.secret/main.key ~/.secret/main.kdbx
fi
2018-12-28 18:19:00 +01:00
run spotify spotify
if [[ "${MACHINE_HAS_NEXTCLOUD}" ]] ; then
run nextcloud nextcloud
fi
2019-04-16 20:11:24 +02:00
if [[ "${MACHINE_HAS_GDRIVE_BACKUP}" ]] ; then
[[ -x ~/bin/gdrive-backup ]] && schedule backup "Mon..Fri 12:00:00" ~/bin/gdrive-backup
fi