2221 lines
45 KiB
Text
2221 lines
45 KiB
Text
|
#!/usr/bin/env bash
|
||
|
# This script was generated by bashly 1.1.10 (https://bashly.dannyb.co)
|
||
|
# Modifying it manually is not recommended
|
||
|
|
||
|
# :wrapper.bash3_bouncer
|
||
|
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
||
|
printf "bash version 4 or higher is required\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# :command.master_script
|
||
|
|
||
|
# :command.version_command
|
||
|
version_command() {
|
||
|
echo "$version"
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage - Manage autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage - Manage autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage COMMAND\n"
|
||
|
printf " autostart-manage [COMMAND] --help | -h\n"
|
||
|
printf " autostart-manage --version | -v\n"
|
||
|
echo
|
||
|
# :command.usage_commands
|
||
|
printf "%s\n" "$(blue "Commands:")"
|
||
|
printf " %s Generate bash completions\n" "$(green "completions")"
|
||
|
printf " %s List available programs\n" "$(green "list") "
|
||
|
printf " %s Get the current status of all programs\n" "$(green "info") "
|
||
|
printf " %s Remove all programs from autostart and the re-enable all\n" "$(green "sync") "
|
||
|
printf " %s Add a single program to autostart\n" "$(green "enable") "
|
||
|
printf " %s Remove a single program from autostart\n" "$(green "disable") "
|
||
|
printf " %s Restart programs from autostart\n" "$(green "restart") "
|
||
|
printf " %s Start programs from autostart\n" "$(green "start") "
|
||
|
printf " %s Check status of programs from autostart\n" "$(green "status") "
|
||
|
printf " %s Stop programs from autostart\n" "$(green "stop") "
|
||
|
printf " %s Kill the program from autostart\n" "$(green "kill") "
|
||
|
printf " %s Show the log for a single program from autostart\n" "$(green "log") "
|
||
|
printf " %s Execute a single program from autostart\n" "$(green "exec") "
|
||
|
printf " %s Run all programs\n" "$(green "run") "
|
||
|
printf " %s Run all the wayland specific tasks and all programs\n" "$(green "run-wayland")"
|
||
|
printf " %s Run all the xorg specific tasks and all programs\n" "$(green "run-xorg") "
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
printf " %s\n" "$(yellow "--version, -v")"
|
||
|
printf " Show version number\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_environment_variables
|
||
|
printf "%s\n" "$(blue "Environment Variables:")"
|
||
|
|
||
|
# :environment_variable.usage
|
||
|
printf " %s\n" "$(cyan "HOSTNAME")"
|
||
|
printf " The hostname to use. We will try to get the value automatically.\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_completions_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage completions - Generate bash completions\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage completions - Generate bash completions\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage completions\n"
|
||
|
printf " autostart-manage completions --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_list_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage list - List available programs\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage list - List available programs\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage list\n"
|
||
|
printf " autostart-manage list --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_info_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage info - Get the current status of all programs\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage info - Get the current status of all programs\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage info\n"
|
||
|
printf " autostart-manage info --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_sync_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage sync - Remove all programs from autostart and the re-enable all\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage sync - Remove all programs from autostart and the re-enable all\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage sync [GROUPS]\n"
|
||
|
printf " autostart-manage sync --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "GROUPS")"
|
||
|
printf " Extra groups to sync\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_enable_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage enable - Add a single program to autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage enable - Add a single program to autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage enable PROGRAM\n"
|
||
|
printf " autostart-manage enable --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to add to autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_disable_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage disable - Remove a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage disable - Remove a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage disable PROGRAM\n"
|
||
|
printf " autostart-manage disable --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to add to autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_restart_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage restart - Restart programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage restart - Restart programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage restart [PROGRAM]\n"
|
||
|
printf " autostart-manage restart --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to add to autostart\n"
|
||
|
printf " Default: *\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_start_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage start - Start programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage start - Start programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage start [PROGRAM]\n"
|
||
|
printf " autostart-manage start --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to start to autostart\n"
|
||
|
printf " Default: *\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_status_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage status - Check status of programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage status - Check status of programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage status [PROGRAM]\n"
|
||
|
printf " autostart-manage status --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to check status on\n"
|
||
|
printf " Default: *\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_stop_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage stop - Stop programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage stop - Stop programs from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage stop [PROGRAM]\n"
|
||
|
printf " autostart-manage stop --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to stop\n"
|
||
|
printf " Default: *\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_kill_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage kill - Kill the program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage kill - Kill the program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage kill PROGRAM\n"
|
||
|
printf " autostart-manage kill --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to kill\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_log_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage log - Show the log for a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage log - Show the log for a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "Alias: logs\n"
|
||
|
echo
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage log PROGRAM\n"
|
||
|
printf " autostart-manage log --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to log\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_exec_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage exec - Execute a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage exec - Execute a single program from autostart\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage exec PROGRAM\n"
|
||
|
printf " autostart-manage exec --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
# :command.usage_args
|
||
|
printf "%s\n" "$(blue "Arguments:")"
|
||
|
|
||
|
# :argument.usage
|
||
|
printf " %s\n" "$(red "PROGRAM")"
|
||
|
printf " Program to execute\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_run_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage run - Run all programs\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage run - Run all programs\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage run\n"
|
||
|
printf " autostart-manage run --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_run_wayland_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage run-wayland - Run all the wayland specific tasks and all programs\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage run-wayland - Run all the wayland specific tasks and all programs\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage run-wayland\n"
|
||
|
printf " autostart-manage run-wayland --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.usage
|
||
|
autostart_manage_run_xorg_usage() {
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "autostart-manage run-xorg - Run all the xorg specific tasks and all programs\n"
|
||
|
echo
|
||
|
|
||
|
else
|
||
|
printf "autostart-manage run-xorg - Run all the xorg specific tasks and all programs\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
|
||
|
printf "%s\n" "$(blue "Usage:")"
|
||
|
printf " autostart-manage run-xorg\n"
|
||
|
printf " autostart-manage run-xorg --help | -h\n"
|
||
|
echo
|
||
|
|
||
|
# :command.long_usage
|
||
|
if [[ -n $long_usage ]]; then
|
||
|
printf "%s\n" "$(blue "Options:")"
|
||
|
|
||
|
# :command.usage_fixed_flags
|
||
|
printf " %s\n" "$(yellow "--help, -h")"
|
||
|
printf " Show this help\n"
|
||
|
echo
|
||
|
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.normalize_input
|
||
|
# :command.normalize_input_function
|
||
|
normalize_input() {
|
||
|
local arg flags passthru
|
||
|
passthru=false
|
||
|
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
arg="$1"
|
||
|
if [[ $passthru == true ]]; then
|
||
|
input+=("$arg")
|
||
|
elif [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
|
||
|
input+=("${BASH_REMATCH[1]}")
|
||
|
input+=("${BASH_REMATCH[2]}")
|
||
|
elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
|
||
|
input+=("${BASH_REMATCH[1]}")
|
||
|
input+=("${BASH_REMATCH[2]}")
|
||
|
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
||
|
flags="${BASH_REMATCH[1]}"
|
||
|
for ((i = 0; i < ${#flags}; i++)); do
|
||
|
input+=("-${flags:i:1}")
|
||
|
done
|
||
|
elif [[ "$arg" == "--" ]]; then
|
||
|
passthru=true
|
||
|
input+=("$arg")
|
||
|
else
|
||
|
input+=("$arg")
|
||
|
fi
|
||
|
|
||
|
shift
|
||
|
done
|
||
|
}
|
||
|
|
||
|
# :command.inspect_args
|
||
|
inspect_args() {
|
||
|
if ((${#args[@]})); then
|
||
|
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
||
|
echo args:
|
||
|
for k in "${sorted_keys[@]}"; do
|
||
|
echo "- \${args[$k]} = ${args[$k]}"
|
||
|
done
|
||
|
else
|
||
|
echo args: none
|
||
|
fi
|
||
|
|
||
|
if ((${#other_args[@]})); then
|
||
|
echo
|
||
|
echo other_args:
|
||
|
echo "- \${other_args[*]} = ${other_args[*]}"
|
||
|
for i in "${!other_args[@]}"; do
|
||
|
echo "- \${other_args[$i]} = ${other_args[$i]}"
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
if ((${#deps[@]})); then
|
||
|
readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
|
||
|
echo
|
||
|
echo deps:
|
||
|
for k in "${sorted_keys[@]}"; do
|
||
|
echo "- \${deps[$k]} = ${deps[$k]}"
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
if ((${#env_var_names[@]})); then
|
||
|
readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
|
||
|
echo
|
||
|
echo "environment variables:"
|
||
|
for k in "${sorted_names[@]}"; do
|
||
|
echo "- \$$k = ${!k:-}"
|
||
|
done
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# :command.user_lib
|
||
|
# autostart-manage/lib/colors.sh
|
||
|
print_in_color() {
|
||
|
local color="$1"
|
||
|
shift
|
||
|
if [[ -z ${NO_COLOR+x} ]]; then
|
||
|
printf "$color%b\e[0m\n" "$*"
|
||
|
else
|
||
|
printf "%b\n" "$*"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
red() { print_in_color "\e[31m" "$*"; }
|
||
|
green() { print_in_color "\e[32m" "$*"; }
|
||
|
yellow() { print_in_color "\e[33m" "$*"; }
|
||
|
blue() { print_in_color "\e[34m" "$*"; }
|
||
|
magenta() { print_in_color "\e[35m" "$*"; }
|
||
|
cyan() { print_in_color "\e[36m" "$*"; }
|
||
|
bold() { print_in_color "\e[1m" "$*"; }
|
||
|
underlined() { print_in_color "\e[4m" "$*"; }
|
||
|
red_bold() { print_in_color "\e[1;31m" "$*"; }
|
||
|
green_bold() { print_in_color "\e[1;32m" "$*"; }
|
||
|
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
|
||
|
blue_bold() { print_in_color "\e[1;34m" "$*"; }
|
||
|
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
|
||
|
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
|
||
|
red_underlined() { print_in_color "\e[4;31m" "$*"; }
|
||
|
green_underlined() { print_in_color "\e[4;32m" "$*"; }
|
||
|
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
|
||
|
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
|
||
|
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
|
||
|
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
|
||
|
|
||
|
# autostart-manage/lib/common.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
_systemctl () {
|
||
|
systemctl --user "${@:2}" "autostart@$1.service"
|
||
|
}
|
||
|
|
||
|
_query_autostart_toml() {
|
||
|
groups_json=$(echo -n "$2" | tr "," "\n" | jq -R . | jq -s .)
|
||
|
tomlq -r \
|
||
|
--arg host "$HOSTNAME" \
|
||
|
--argjson extra_groups "$groups_json" \
|
||
|
'.hosts[$host].groups as $groups | .apps | to_entries[] | select(
|
||
|
(.value.hosts | contains([$host])) or
|
||
|
([.value.group] | inside($groups)) or
|
||
|
([.value.group] | inside($extra_groups)) or
|
||
|
$extra_groups == ["*"]
|
||
|
) | '"$1" \
|
||
|
"$XDG_CONFIG_HOME/autostart.toml"
|
||
|
}
|
||
|
|
||
|
_list () {
|
||
|
_query_autostart_toml '.value.alias // .key' "$1"
|
||
|
}
|
||
|
|
||
|
_autostart_run_graphical () {
|
||
|
set +e
|
||
|
pass x # Try to unlock yubikey asap
|
||
|
|
||
|
start-audio pipewire
|
||
|
wait-for-service "network-online.target"
|
||
|
|
||
|
# Execute only if not already running
|
||
|
# Don't match keepassxc-proxy
|
||
|
if ! (pgrep -l keepassxc | grep -v prox) >/dev/null
|
||
|
then
|
||
|
if pass x
|
||
|
then
|
||
|
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
autoinstall run graphical
|
||
|
autostart-manage run
|
||
|
}
|
||
|
|
||
|
_echo_table () {
|
||
|
for unit in "$@"
|
||
|
do
|
||
|
if [ "$(_systemctl "$unit" is-enabled)" = "enabled" ]
|
||
|
then
|
||
|
_enabled=$(green "enabled")
|
||
|
else
|
||
|
_enabled=$(red "disabled")
|
||
|
fi
|
||
|
|
||
|
if _systemctl "$unit" is-active --quiet
|
||
|
then
|
||
|
_active=$(green "active")
|
||
|
else
|
||
|
_active=$(red "inactive")
|
||
|
fi
|
||
|
|
||
|
printf "%s\t%s\t%s\t%s\n" \
|
||
|
"$unit" \
|
||
|
"$_enabled" \
|
||
|
"$_active" \
|
||
|
"$(_get_autostart_cmd "$unit")"
|
||
|
done
|
||
|
}
|
||
|
|
||
|
_get_autostart_cmd () {
|
||
|
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.command' "*"
|
||
|
}
|
||
|
|
||
|
_get_autostart_delay () {
|
||
|
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.delay // 0' "*"
|
||
|
}
|
||
|
|
||
|
# autostart-manage/lib/send_completions.sh
|
||
|
send_completions() {
|
||
|
echo $'# autostart-manage completion -*- shell-script -*-'
|
||
|
echo $''
|
||
|
echo $'# This bash completions script was generated by'
|
||
|
echo $'# completely (https://github.com/dannyben/completely)'
|
||
|
echo $'# Modifying it manually is not recommended'
|
||
|
echo $''
|
||
|
echo $'_autostart-manage_completions_filter() {'
|
||
|
echo $' local words="$1"'
|
||
|
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
|
||
|
echo $' local result=()'
|
||
|
echo $''
|
||
|
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
|
||
|
echo $' echo "$words"'
|
||
|
echo $' '
|
||
|
echo $' else'
|
||
|
echo $' for word in $words; do'
|
||
|
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
|
||
|
echo $' done'
|
||
|
echo $''
|
||
|
echo $' echo "${result[*]}"'
|
||
|
echo $''
|
||
|
echo $' fi'
|
||
|
echo $'}'
|
||
|
echo $''
|
||
|
echo $'_autostart-manage_completions() {'
|
||
|
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
|
||
|
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
|
||
|
echo $' local compline="${compwords[*]}"'
|
||
|
echo $''
|
||
|
echo $' case "$compline" in'
|
||
|
echo $' \'completions\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'run-wayland\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'run-xorg\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'restart\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'disable\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'status\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'enable\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'start\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'sync\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'info\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'stop\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'kill\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'logs\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'exec\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'list\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'log\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "$(autostart-manage list) --help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' \'run\'*)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help -h")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' *)'
|
||
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_autostart-manage_completions_filter "--help --version -h -v completions disable enable exec info kill list log logs restart run run-wayland run-xorg start status stop sync")" -- "$cur" )'
|
||
|
echo $' ;;'
|
||
|
echo $''
|
||
|
echo $' esac'
|
||
|
echo $'} &&'
|
||
|
echo $'complete -F _autostart-manage_completions autostart-manage'
|
||
|
echo $''
|
||
|
echo $'# ex: filetype=sh'
|
||
|
}
|
||
|
|
||
|
# autostart-manage/lib/systemd_files.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
_deploy_service_file() {
|
||
|
cat <<EOF > "$1"
|
||
|
[Unit]
|
||
|
Description=Autostart several tools and services
|
||
|
StartLimitIntervalSec=120
|
||
|
StartLimitBurst=10
|
||
|
|
||
|
[Service]
|
||
|
KillMode=process
|
||
|
ExecStart=/bin/sh -c ". \$HOME/.profile && autostart-manage exec '%i'"
|
||
|
Restart=on-failure
|
||
|
RestartSec=5s
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
_deploy_target_file() {
|
||
|
cat <<EOF > "$1"
|
||
|
[Unit]
|
||
|
Description=Current graphical user session
|
||
|
Documentation=man:systemd.special(7)
|
||
|
RefuseManualStart=no
|
||
|
StopWhenUnneeded=no
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
# :command.command_functions
|
||
|
# :command.function
|
||
|
autostart_manage_completions_command() {
|
||
|
# autostart-manage/completions_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
send_completions
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_list_command() {
|
||
|
# autostart-manage/list_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
_list "*"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_info_command() {
|
||
|
# autostart-manage/info_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
autostart_units=()
|
||
|
while IFS='' read -r line
|
||
|
do
|
||
|
autostart_units+=("$line")
|
||
|
done < <(_list "*")
|
||
|
|
||
|
_echo_table "${autostart_units[@]}" | column -t -s$'\t' --table-columns 'Unit,Enabled?,Active?,Command'
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_sync_command() {
|
||
|
# autostart-manage/sync_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
rm -f "$HOME/.config/systemd/user/autostart.target.wants/"*
|
||
|
|
||
|
autostart_units=()
|
||
|
while IFS='' read -r line
|
||
|
do
|
||
|
autostart_units+=("autostart@$line.service")
|
||
|
done < <(_list "${args[groups]:-}")
|
||
|
|
||
|
systemctl --user add-wants autostart.target "${autostart_units[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_enable_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_disable_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_restart_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_start_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_status_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_stop_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_kill_command() {
|
||
|
# autostart-manage/systemctl.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl_args=("$action")
|
||
|
if [[ $action == "enable" ]]; then
|
||
|
systemctl_args=("add-wants" "autostart.target")
|
||
|
fi
|
||
|
|
||
|
#shellcheck disable=SC2068
|
||
|
_systemctl "${args[program]:?}" "${systemctl_args[@]}"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_log_command() {
|
||
|
# autostart-manage/log_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
journalctl --user -fu "autostart@${args[program]:?}.service"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_exec_command() {
|
||
|
# autostart-manage/exec_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
program=${args[program]:?}
|
||
|
|
||
|
sleep "$(_get_autostart_delay "$program")"
|
||
|
bash -c "$(_get_autostart_cmd "$program")"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_run_command() {
|
||
|
# autostart-manage/run_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
systemctl --user start autostart.target
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_run_wayland_command() {
|
||
|
# autostart-manage/run_wayland_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
_autostart_run_graphical
|
||
|
|
||
|
killall -SIGUSR2 waybar
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.function
|
||
|
autostart_manage_run_xorg_command() {
|
||
|
# autostart-manage/run_xorg_command.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
|
||
|
|
||
|
"$HOME/.config/polybar/launch.sh" &
|
||
|
"$HOME/.config/bspwm/focus-voip.py" &
|
||
|
|
||
|
numlockx on
|
||
|
xsetroot -cursor_name left_ptr
|
||
|
xrdb "$HOME/.Xresources"
|
||
|
|
||
|
_autostart_run_graphical
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--version | -v)
|
||
|
version_command
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.environment_variables_filter
|
||
|
|
||
|
env_var_names+=("HOSTNAME")
|
||
|
|
||
|
# :command.dependencies_filter
|
||
|
if command -v tomlq >/dev/null 2>&1; then
|
||
|
deps['tomlq']="$(command -v tomlq | head -n1)"
|
||
|
else
|
||
|
printf "missing dependency: tomlq\n" >&2
|
||
|
printf "%s\n" "please install yq (https://github.com/kislyuk/yq)" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# :command.command_filter
|
||
|
action=${1:-}
|
||
|
|
||
|
case $action in
|
||
|
-*) ;;
|
||
|
|
||
|
completions)
|
||
|
action="completions"
|
||
|
shift
|
||
|
autostart_manage_completions_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
list)
|
||
|
action="list"
|
||
|
shift
|
||
|
autostart_manage_list_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
info)
|
||
|
action="info"
|
||
|
shift
|
||
|
autostart_manage_info_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
sync)
|
||
|
action="sync"
|
||
|
shift
|
||
|
autostart_manage_sync_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
enable)
|
||
|
action="enable"
|
||
|
shift
|
||
|
autostart_manage_enable_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
disable)
|
||
|
action="disable"
|
||
|
shift
|
||
|
autostart_manage_disable_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
restart)
|
||
|
action="restart"
|
||
|
shift
|
||
|
autostart_manage_restart_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
start)
|
||
|
action="start"
|
||
|
shift
|
||
|
autostart_manage_start_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
status)
|
||
|
action="status"
|
||
|
shift
|
||
|
autostart_manage_status_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
stop)
|
||
|
action="stop"
|
||
|
shift
|
||
|
autostart_manage_stop_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
kill)
|
||
|
action="kill"
|
||
|
shift
|
||
|
autostart_manage_kill_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
log | logs)
|
||
|
action="log"
|
||
|
shift
|
||
|
autostart_manage_log_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
exec)
|
||
|
action="exec"
|
||
|
shift
|
||
|
autostart_manage_exec_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
run)
|
||
|
action="run"
|
||
|
shift
|
||
|
autostart_manage_run_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
run-wayland)
|
||
|
action="run-wayland"
|
||
|
shift
|
||
|
autostart_manage_run_wayland_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
run-xorg)
|
||
|
action="run-xorg"
|
||
|
shift
|
||
|
autostart_manage_run_xorg_parse_requirements "$@"
|
||
|
shift $#
|
||
|
;;
|
||
|
|
||
|
# :command.command_fallback
|
||
|
"")
|
||
|
autostart_manage_usage >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
printf "invalid command: %s\n" "$action" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_completions_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_completions_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="completions"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_list_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_list_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="list"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_info_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_info_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="info"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_sync_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_sync_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="sync"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['groups']+x} ]]; then
|
||
|
args['groups']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_enable_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_enable_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="enable"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.required_args_filter
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
printf "missing required argument: PROGRAM\nusage: autostart-manage enable PROGRAM\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_disable_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_disable_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="disable"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.required_args_filter
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
printf "missing required argument: PROGRAM\nusage: autostart-manage disable PROGRAM\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_restart_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_restart_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="restart"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.default_assignments
|
||
|
[[ -n ${args['program']:-} ]] || args['program']="*"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_start_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_start_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="start"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.default_assignments
|
||
|
[[ -n ${args['program']:-} ]] || args['program']="*"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_status_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_status_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="status"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.default_assignments
|
||
|
[[ -n ${args['program']:-} ]] || args['program']="*"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_stop_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_stop_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="stop"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.default_assignments
|
||
|
[[ -n ${args['program']:-} ]] || args['program']="*"
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_kill_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_kill_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="kill"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.required_args_filter
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
printf "missing required argument: PROGRAM\nusage: autostart-manage kill PROGRAM\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_log_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_log_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="log"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.required_args_filter
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
printf "missing required argument: PROGRAM\nusage: autostart-manage log PROGRAM\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_exec_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_exec_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="exec"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
# :argument.case
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
args['program']=$1
|
||
|
shift
|
||
|
else
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.required_args_filter
|
||
|
if [[ -z ${args['program']+x} ]]; then
|
||
|
printf "missing required argument: PROGRAM\nusage: autostart-manage exec PROGRAM\n" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_run_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_run_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="run"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_run_wayland_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_run_wayland_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="run-wayland"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.parse_requirements
|
||
|
autostart_manage_run_xorg_parse_requirements() {
|
||
|
# :command.fixed_flags_filter
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case "${1:-}" in
|
||
|
--help | -h)
|
||
|
long_usage=yes
|
||
|
autostart_manage_run_xorg_usage
|
||
|
exit
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
break
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# :command.command_filter
|
||
|
action="run-xorg"
|
||
|
|
||
|
# :command.parse_requirements_while
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
key="$1"
|
||
|
case "$key" in
|
||
|
|
||
|
-?*)
|
||
|
printf "invalid option: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
# :command.parse_requirements_case
|
||
|
# :command.parse_requirements_case_simple
|
||
|
printf "invalid argument: %s\n" "$key" >&2
|
||
|
exit 1
|
||
|
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.user_hooks
|
||
|
before_hook() {
|
||
|
# autostart-manage/before.sh
|
||
|
#!/usr/bin/env bash
|
||
|
|
||
|
service_file="$HOME/.config/systemd/user/autostart@.service"
|
||
|
if [ ! -f "$service_file" ]; then
|
||
|
_deploy_service_file "$service_file"
|
||
|
fi
|
||
|
|
||
|
target_file="$HOME/.config/systemd/user/autostart.target"
|
||
|
if [ ! -f "$target_file" ]; then
|
||
|
_deploy_target_file "$target_file"
|
||
|
fi
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.initialize
|
||
|
initialize() {
|
||
|
version="0.1.3"
|
||
|
long_usage=''
|
||
|
set -euo pipefail
|
||
|
|
||
|
}
|
||
|
|
||
|
# :command.run
|
||
|
run() {
|
||
|
declare -A args=()
|
||
|
declare -A deps=()
|
||
|
declare -a other_args=()
|
||
|
declare -a env_var_names=()
|
||
|
declare -a input=()
|
||
|
normalize_input "$@"
|
||
|
parse_requirements "${input[@]}"
|
||
|
before_hook
|
||
|
|
||
|
case "$action" in
|
||
|
"completions") autostart_manage_completions_command ;;
|
||
|
"list") autostart_manage_list_command ;;
|
||
|
"info") autostart_manage_info_command ;;
|
||
|
"sync") autostart_manage_sync_command ;;
|
||
|
"enable") autostart_manage_enable_command ;;
|
||
|
"disable") autostart_manage_disable_command ;;
|
||
|
"restart") autostart_manage_restart_command ;;
|
||
|
"start") autostart_manage_start_command ;;
|
||
|
"status") autostart_manage_status_command ;;
|
||
|
"stop") autostart_manage_stop_command ;;
|
||
|
"kill") autostart_manage_kill_command ;;
|
||
|
"log") autostart_manage_log_command ;;
|
||
|
"exec") autostart_manage_exec_command ;;
|
||
|
"run") autostart_manage_run_command ;;
|
||
|
"run-wayland") autostart_manage_run_wayland_command ;;
|
||
|
"run-xorg") autostart_manage_run_xorg_command ;;
|
||
|
esac
|
||
|
}
|
||
|
|
||
|
initialize
|
||
|
run "$@"
|