Finalize autostart refactor

This commit is contained in:
Tobias Reisinger 2022-10-13 23:50:13 +02:00
parent e1ef91b696
commit 423b1821a7
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
2 changed files with 21 additions and 37 deletions

View file

@ -10,8 +10,15 @@ _systemctl () {
systemctl --user "${@:2}" "$(_filename "$1")" systemctl --user "${@:2}" "$(_filename "$1")"
} }
_list () {
systemctl --user list-unit-files \
| grep "autostart-" \
| awk '{print $1}' \
| sed -e 's/^autostart-//' -e 's/.service$//'
}
_echo_table () { _echo_table () {
printf "Unit\tFilename\tEnabled\n" printf "Unit\tFilename\tStatus\n"
for unit in "$@" for unit in "$@"
do do
printf "%s\t%s\t%s\n" \ printf "%s\t%s\t%s\n" \
@ -32,23 +39,20 @@ EOF
} }
_autostart_manage_list () { _autostart_manage_list () {
systemctl --user list-unit-files \ _list
| grep "autostart-" \
| awk '{print $1}' \
| sed -e 's/^autostart-//' -e 's/.service$//'
} }
_autostart_manage_info () { _autostart_manage_info () {
mapfile -t autostart_units < <( _autostart_manage_list ) mapfile -t autostart_units < <( _list )
_echo_table "${autostart_units[@]}" | column -t -s$'\t' _echo_table "${autostart_units[@]}" | column -t -s$'\t'
} }
_autostart_manage_enable () { _autostart_manage_enable_all () {
_systemctl "$1" add-wants autostart.target mapfile -t autostart_units < <( _list )
} for unit in "${autostart_units[@]}"
do
_autostart_manage_disable () { _systemctl "$unit" add-wants autostart.target
_systemctl "$1" disable done
} }
_autostart_manage_rm () { _autostart_manage_rm () {
@ -59,8 +63,11 @@ case $1 in
list) _autostart_manage_list ;; list) _autostart_manage_list ;;
info) _autostart_manage_info ;; info) _autostart_manage_info ;;
add) _autostart_manage_add "$2" "$3" ;; add) _autostart_manage_add "$2" "$3" ;;
enable) _autostart_manage_enable "$2" ;;
disable) _autostart_manage_disable "$2" ;;
rm) _autostart_manage_rm "$2" ;; rm) _autostart_manage_rm "$2" ;;
enable-all) _autostart_manage_enable_all "$2" ;;
show) _systemctl "$2" cat ;;
edit) _systemctl "$2" edit --full ;;
enable) _systemctl "$2" add-wants autostart.target ;;
disable) _systemctl "$2" enable ;;
*) echo "'$1' is not valid" ;; *) echo "'$1' is not valid" ;;
esac esac

View file

@ -5,27 +5,6 @@ numlockx on
setxkbmap de setxkbmap de
setxkbmap -option caps:none setxkbmap -option caps:none
_autostart_apps()
{
dunst &
parcellite &
solaar --window hide &
conky --daemonize --config="$HOME/.config/conky/clock.conf"
conky --daemonize --config="$HOME/.config/conky/system.conf"
conky --daemonize --config="$HOME/.config/conky/archlinux-updates.conf"
syncthing -no-browser &
/usr/lib/kdeconnectd &
qbittorrent &
qutebrowser &
mopidy &
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
}
_autostart() _autostart()
{ {
### wait for audio ### wait for audio
@ -38,8 +17,6 @@ _autostart()
(pass notes/keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) & (pass notes/keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
pass x && sleep 5 pass x && sleep 5
_autostart_apps &
systemctl --user start autostart.target systemctl --user start autostart.target
} }