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" systemctl --user "${@:2}" "autostart@$1.service"
} }
_dasel () { _query_autostart_toml() {
dasel -f "$HOME/.config/autostart.toml" -r toml -w plain "${@}" 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 () { _list () {
part_root='all().filter(not(equal(type(),object))).key()' _query_autostart_toml '.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
} }
_echo_table () { _echo_table () {
@ -71,20 +63,7 @@ _autostart_manage_sync () {
} }
_get_autostart_cmd () { _get_autostart_cmd () {
selector_base="all()" _query_autostart_toml 'select(.key == "'"$1"'") | .value.command'
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"
} }
_autostart_manage_exec () { _autostart_manage_exec () {

View file

@ -1,42 +1,127 @@
# General [hosts.portalo]
discord = 'flatpak run com.discordapp.Discord' groups = ['common', 'wayland', 'chat', 'messenger']
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'
#clipboard-manager = 'parcellite' # X11 [apps.ckb-next]
#clipboard-manager = 'wl-paste --watch cliphist store' # Wayland command = 'ckb-next --background'
hosts = ['portalo']
group = ''
# X11 [apps.clipboard-manager-wayland]
conky-clock = 'conky --config="$HOME/.config/conky/clock.conf"' command = 'wl-paste --watch cliphist store'
conky-system = 'conky --config="$HOME/.config/conky/system.conf"' hosts = []
sxhkd = 'sxhkd' group = 'wayland'
unclutter = 'unclutter --timeout=3 --ignore-scrolling --exclude-root'
xcompmgr = 'xcompmgr -cnfFn -D3'
# Wayland [apps.clipboard-manager-x11]
hyprland-handler = '$XDG_CONFIG_HOME/hypr/handler.sh' command = 'parcellite'
swww = 'swww init --no-daemon' hosts = []
waybar = 'waybar' group = 'x11'
[apps.conky-clock]
command = 'conky --config="$HOME/.config/conky/clock.conf"'
hosts = []
group = 'conky'
[portalo] [apps.conky-system]
ckb-next = 'ckb-next --background' command = 'conky --config="$HOME/.config/conky/system.conf"'
qbittorrent = 'flatpak run org.qbittorrent.qBittorrent' hosts = []
signal = 'flatpak run org.signal.Signal' group = 'conky'
solaar = 'solaar --window hide'
steam = 'flatpak run com.valvesoftware.Steam -silent'
conky-clock = false [apps.discord]
conky-system = false command = 'flatpak run com.discordapp.discord'
sxhkd = false hosts = []
unclutter = false group = 'chat'
xcompmgr = false
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

@ -1,56 +1,57 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Packages that should be installed to the user profile. # Packages that should be installed to the user profile.
home.packages = with pkgs; [ home.packages = with pkgs; [
bat # cat-alternative bat # cat-alternative
direnv # tool to load custom environments direnv # tool to load custom environments
docker-credential-helpers docker-credential-helpers
doggo # dns client dogdns # dns client
exa # ls-alternative exa # ls-alternative
faas-cli # cli for openfaas faas-cli # cli for openfaas
fzf # fuzzy finder fzf # fuzzy finder
git # git git # git
gitflow # tool for git workflow gitflow # tool for git workflow
git-lfs # git support for large files git-lfs # git support for large files
moar # moar is less jq # tool for json
nix-direnv # allow better nix and direnv integration moar # moar is less
libnotify # allows sending notifications nix-direnv # allow better nix and direnv integration
lsof # who uses that drive/directory libnotify # allows sending notifications
openssh # ssh client and server lsof # who uses that drive/directory
pass # password-store openssh # ssh client and server
playerctl # control media players pass # password-store
p7zip # tool to extract 7z archives playerctl # control media players
rclone # tool for remote storages p7zip # tool to extract 7z archives
restic # backup tool rclone # tool for remote storages
ripgrep # grep-alternative restic # backup tool
rmtrash # rm wrapper to use trash ripgrep # grep-alternative
shellcheck # tool for shell-syntax rmtrash # rm wrapper to use trash
(spotifyd.override { withMpris = true; }) # spotify-daemon shellcheck # tool for shell-syntax
tokei # project-language statistics (spotifyd.override { withMpris = true; }) # spotify-daemon
trash-cli # trash utils tokei # project-language statistics
unzip # unzip trash-cli # trash utils
vimHugeX # vim with clipboard support unzip # unzip
xdg-user-dirs # tool manage user directories vimHugeX # vim with clipboard support
yq # tool for YAML xdg-user-dirs # tool manage user directories
yt-dlp # tool to download videos from the internet yq # tool for YAML
zip # zip yt-dlp # tool to download videos from the internet
]; zip # zip
];
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards # when a new Home Manager release introduces backwards
# incompatible changes. # incompatible changes.
# #
# You can update Home Manager without changing this value. See # You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version # the Home Manager release notes for a list of state version
# changes in each release. # changes in each release.
home.stateVersion = "22.11"; home.stateVersion = "22.11";
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
programs.home-manager.enable = true; programs.home-manager.enable = true;
targets.genericLinux.enable = true; targets.genericLinux.enable = true;
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
} }