57 lines
1.3 KiB
Bash
57 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
_systemctl () {
|
|
systemctl --user "${@:2}" "autostart@$1.service"
|
|
}
|
|
|
|
_query_autostart_toml() {
|
|
tomlq -r --arg host "$HOSTNAME" \
|
|
'.hosts[$host].groups as $groups | .apps | to_entries[] | select(
|
|
(.value.hosts | contains([$host])) or
|
|
([.value.group] | inside($groups))
|
|
) | '"$1" \
|
|
"$XDG_CONFIG_HOME/autostart.toml"
|
|
}
|
|
|
|
_list () {
|
|
_query_autostart_toml '.value.alias // .key'
|
|
}
|
|
|
|
_autostart_run_graphical () {
|
|
pass x # Try to unlock yubikey asap
|
|
|
|
start-audio pipewire
|
|
wait-for-service "network-online.target"
|
|
|
|
# Execute only if not already running
|
|
# Don't match keepassxc-proxy
|
|
if ! (pgrep -l keepassxc | grep -v prox) >/dev/null
|
|
then
|
|
if pass x
|
|
then
|
|
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
|
|
fi
|
|
fi
|
|
|
|
autoinstall graphical
|
|
autostart-manage run
|
|
}
|
|
|
|
_echo_table () {
|
|
for unit in "$@"
|
|
do
|
|
printf "%s\t%s\t%s\t%s\n" \
|
|
"$unit" \
|
|
"$(_systemctl "$unit" is-enabled)" \
|
|
"$(_systemctl "$unit" is-active)" \
|
|
"$(_get_autostart_cmd "$unit")"
|
|
done
|
|
}
|
|
|
|
_get_autostart_cmd () {
|
|
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.command'
|
|
}
|
|
|
|
_get_autostart_delay () {
|
|
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.delay // 0'
|
|
}
|