Improve autostart script

This commit is contained in:
Tobias Reisinger 2023-07-01 16:34:53 +02:00
parent 32a6ce75bd
commit cf24c298e1
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
2 changed files with 43 additions and 24 deletions

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
hostname=$(cat /proc/sys/kernel/hostname)
_systemctl () { _systemctl () {
systemctl --user "${@:2}" "autostart@$1.service" systemctl --user "${@:2}" "autostart@$1.service"
} }
@ -10,15 +12,19 @@ _dasel () {
_list () { _list () {
part_root='all().filter(not(equal(type(),object))).key()' part_root='all().filter(not(equal(type(),object))).key()'
part_host='all().filter(equal(type(),object)).all().key()' part_host="all().filter(equal(type(),object)).filter(equal(key(),$hostname)).all().key()"
arg="merge($part_host,$part_root).all()" query="merge($part_host,$part_root).all()"
_dasel "$arg" \ programs=$(_dasel "$query" \
| sort \ | sort \
| uniq | uniq)
#systemctl --user list-unit-files \
# | grep "autostart-" \ for program in $programs
# | awk '{print $1}' \ do
# | sed -e 's/^autostart-//' -e 's/.service$//' cmd=$(_get_autostart_cmd "$program")
if [ -n "$cmd" ]; then
echo "$program"
fi
done
} }
_echo_table () { _echo_table () {
@ -49,7 +55,9 @@ _autostart_manage_log () {
journalctl --user -fu "autostart@$1.service" journalctl --user -fu "autostart@$1.service"
} }
_autostart_manage_enable_all () { _autostart_manage_sync () {
rm "$HOME/.config/systemd/user/autostart.target.wants/"*
autostart_units=() autostart_units=()
while IFS='' read -r line while IFS='' read -r line
do do
@ -63,8 +71,6 @@ _autostart_manage_enable_all () {
} }
_get_autostart_cmd () { _get_autostart_cmd () {
hostname=$(cat /proc/sys/kernel/hostname)
selector_base="all()" selector_base="all()"
selector_host="all().filter(equal(type(),object)).filter(equal(key(),$hostname)).all()" selector_host="all().filter(equal(type(),object)).filter(equal(key(),$hostname)).all()"
selector_entry="filter(not(equal(type(),object))).filter(equal(key(),$1))" selector_entry="filter(not(equal(type(),object))).filter(equal(key(),$1))"
@ -126,7 +132,7 @@ _autostart_run_xorg () {
case $1 in case $1 in
list) _autostart_manage_list ;; list) _autostart_manage_list ;;
info) _autostart_manage_info ;; info) _autostart_manage_info ;;
enable-all) _autostart_manage_enable_all "$2" ;; sync) _autostart_manage_sync ;;
enable) _systemctl "$2" add-wants autostart.target ;; enable) _systemctl "$2" add-wants autostart.target ;;
disable) _systemctl "$2" disable ;; disable) _systemctl "$2" disable ;;
restart) _systemctl "${2:-*}" restart;; restart) _systemctl "${2:-*}" restart;;

View file

@ -1,29 +1,42 @@
conky-clock = 'conky --config="$HOME/.config/conky/clock.conf"' # General
conky-system = 'conky --config="$HOME/.config/conky/system.conf"'
discord = 'flatpak run com.discordapp.Discord' discord = 'flatpak run com.discordapp.Discord'
dunst = 'dunst' dunst = 'dunst'
element = 'flatpak run im.riot.Riot' element = 'flatpak run im.riot.Riot'
kdeconnect = '$HOME/.nix-profile/libexec/kdeconnectd' kdeconnect = '$HOME/.nix-profile/libexec/kdeconnectd'
parcellite = 'parcellite' polkit = '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
qutebrowser = 'qutebrowser' qutebrowser = 'qutebrowser'
spotifyd = 'spotifyd --no-daemon' spotifyd = 'spotifyd --no-daemon'
sxhkd = 'sxhkd'
syncthing = 'syncthing -no-browser' syncthing = 'syncthing -no-browser'
teamspeak = 'flatpak run com.teamspeak.TeamSpeak -nosingleinstance' teamspeak = 'flatpak run com.teamspeak.TeamSpeak -nosingleinstance'
thunderbird = 'thunderbird'
#clipboard-manager = 'parcellite' # X11
#clipboard-manager = 'wl-paste --watch cliphist store' # Wayland
# X11
conky-clock = 'conky --config="$HOME/.config/conky/clock.conf"'
conky-system = 'conky --config="$HOME/.config/conky/system.conf"'
sxhkd = 'sxhkd'
unclutter = 'unclutter --timeout=3 --ignore-scrolling --exclude-root' unclutter = 'unclutter --timeout=3 --ignore-scrolling --exclude-root'
xcompmgr = 'xcompmgr -cnfFn -D3' xcompmgr = 'xcompmgr -cnfFn -D3'
# Wayland
hyprland-handler = '$XDG_CONFIG_HOME/hypr/handler.sh'
swww = 'swww init --no-daemon'
waybar = 'waybar'
[portalo] [portalo]
ckb-next = 'ckb-next --background' ckb-next = 'ckb-next --background'
conky-clock = ''
conky-system = ''
hyprland-handler = '$XDG_CONFIG_HOME/hypr/handler.sh'
polkit = '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
qbittorrent = 'flatpak run org.qbittorrent.qBittorrent' qbittorrent = 'flatpak run org.qbittorrent.qBittorrent'
signal = 'flatpak run org.signal.Signal' signal = 'flatpak run org.signal.Signal'
solaar = 'solaar --window hide' solaar = 'solaar --window hide'
steam = 'flatpak run com.valvesoftware.Steam -silent' steam = 'flatpak run com.valvesoftware.Steam -silent'
sxhkd = ''
thunderbird = 'thunderbird' conky-clock = false
swww = 'swww init --no-daemon' conky-system = false
waybar = 'waybar' sxhkd = false
unclutter = false
xcompmgr = false
clipboard-manager = 'wl-paste --watch cliphist store'