Refactor autostart system

This commit is contained in:
Tobias Reisinger 2023-07-15 13:54:52 +02:00
parent b1814d3a5f
commit 0d82914d42
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 178 additions and 113 deletions

View file

@ -6,25 +6,17 @@ _systemctl () {
systemctl --user "${@:2}" "autostart@$1.service"
}
_dasel () {
dasel -f "$HOME/.config/autostart.toml" -r toml -w plain "${@}"
_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" \
"$HOME/.config/autostart.toml"
}
_list () {
part_root='all().filter(not(equal(type(),object))).key()'
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)
for program in $programs
do
cmd=$(_get_autostart_cmd "$program")
if [ -n "$cmd" ]; then
echo "$program"
fi
done
_query_autostart_toml '.key'
}
_echo_table () {
@ -71,20 +63,7 @@ _autostart_manage_sync () {
}
_get_autostart_cmd () {
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))"
cmd=$(_dasel "$selector_base.$selector_entry")
cmd_local=$(_dasel "$selector_host.$selector_entry")
if [ -n "$cmd_local" ]; then
if [ "$cmd_local" = "false" ]; then
cmd=""
else
cmd="$cmd_local"
fi
fi
echo "$cmd"
_query_autostart_toml 'select(.key == "'"$1"'") | .value.command'
}
_autostart_manage_exec () {

View file

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

View file

@ -6,13 +6,14 @@
bat # cat-alternative
direnv # tool to load custom environments
docker-credential-helpers
doggo # dns client
dogdns # dns client
exa # ls-alternative
faas-cli # cli for openfaas
fzf # fuzzy finder
git # git
gitflow # tool for git workflow
git-lfs # git support for large files
jq # tool for json
moar # moar is less
nix-direnv # allow better nix and direnv integration
libnotify # allows sending notifications