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

View file

@ -1,29 +1,42 @@
conky-clock = 'conky --config="$HOME/.config/conky/clock.conf"'
conky-system = 'conky --config="$HOME/.config/conky/system.conf"'
# General
discord = 'flatpak run com.discordapp.Discord'
dunst = 'dunst'
element = 'flatpak run im.riot.Riot'
kdeconnect = '$HOME/.nix-profile/libexec/kdeconnectd'
parcellite = 'parcellite'
polkit = '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
qutebrowser = 'qutebrowser'
spotifyd = 'spotifyd --no-daemon'
sxhkd = 'sxhkd'
syncthing = 'syncthing -no-browser'
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'
xcompmgr = 'xcompmgr -cnfFn -D3'
# Wayland
hyprland-handler = '$XDG_CONFIG_HOME/hypr/handler.sh'
swww = 'swww init --no-daemon'
waybar = 'waybar'
[portalo]
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'
signal = 'flatpak run org.signal.Signal'
solaar = 'solaar --window hide'
steam = 'flatpak run com.valvesoftware.Steam -silent'
sxhkd = ''
thunderbird = 'thunderbird'
swww = 'swww init --no-daemon'
waybar = 'waybar'
conky-clock = false
conky-system = false
sxhkd = false
unclutter = false
xcompmgr = false
clipboard-manager = 'wl-paste --watch cliphist store'