10 Commits

22 changed files with 370 additions and 358 deletions

30
TODO.md
View File

@@ -1,5 +1,7 @@
# TODO # TODO
A list of in-progress and completed todo's.
## Arch Todos ## Arch Todos
- [ ] Update README, it's way out of date. - [ ] Update README, it's way out of date.
@@ -10,28 +12,40 @@
config in the dotfiles, but works if I use the default config. Need to explore config in the dotfiles, but works if I use the default config. Need to explore
why (current thoughts are it has to do with creating the why (current thoughts are it has to do with creating the
clipboard_history.json file and not letting clipse do it automatically). clipboard_history.json file and not letting clipse do it automatically).
- [ ] Need to confirm bootstrap does things properly with git submodules. - [x] Need to add the following system packages for neovim/render-markdown.nvim
- [x] `libtexprintf`
### Bootstrapping a new machine
- [ ] Need to confirm bootstrap does things properly with git submodules. Currently the
system run handles installing packages needed for my yubikey, probably need to automate
installing the public key into the keyring.
- [x] Add gpg public key import into `runs/after/system`
- [ ] Need to ensure ssh keys are setup before private submodules are loaded / installed, - [ ] Need to ensure ssh keys are setup before private submodules are loaded / installed,
so I need to make sure that Yubikey setup runs early and works for ssh authentication. so I need to make sure that Yubikey setup runs early and works for ssh authentication.
- [ ] Need to add the following system packages for neovim/render-markdown.nvim - [ ] Setup a new machine / virtual machine to test, as it's hard to test the scripts once a machine is setup.
- [ ] `libtexprintf`
### Keyboard / kanata ### Keyboard / kanata
- [ ] Move keyboard (kanata) systemd service to be started as a '--user' service, as - [x] Move keyboard (kanata) systemd service to be started as a '--user' service, as
it seems to not work when used on a desktop (mac mini) vs. laptop. it seems to not work when used on a desktop (mac mini) vs. laptop.
- [ ] Need to update kanatactl to generate udev rules, etc. (see - [x] Need to update kanatactl to generate udev rules, etc. (see
here)[https://github.com/jtroo/kanata/blob/main/docs/setup-linux.md] here)[https://github.com/jtroo/kanata/blob/main/docs/setup-linux.md]
- [ ] Need to rethink symbol / number keyboard layers. - [ ] Need to rethink symbol / number keyboard layers.
- [ ] Move symbols to their own layer. - [ ] Move symbols to their own layer.
- [ ] I would like to have a symbols layer that I can hold modifier keys with a symbol - [ ] I would like to have a symbols layer that I can hold modifier keys with a symbol
and would also like to possibly pass through underlying key / experiment so that and would also like to possibly pass through underlying key / experiment so that
I can use default keybinds in certain applications (i.e. neovim `[b`, etc.). I can use default keybinds in certain applications (i.e. neovim `[b`, etc.).
- [x] Remove pkg sub-commands from kanatactl, it is available via package manager now.
### Runs (package installs) ### Runs (package installs)
- [ ] Should runs just export / echo a list of packages, then the `run` script can handle the package - [x] Should runs just export / echo a list of packages, then the `run` script can handle the package
manager options / command. manager options / command.
- [ ] Think about adding an `after` directory for runs, so that they can perform setup tasks after - [x] Think about adding a `before` and an `after` directory for runs, so that they can perform setup tasks after
the packages are installed. the packages are installed.
- [ ] The `after` file should have the same name as the `run` file. - [x] The `before` and `after` file should have the same name as the `run` file.
- [ ] This could allow to remove / move the `system` script into the `after` directory. - [ ] This could allow to remove / move the `system` script into the `after` directory.
- [ ] Look into install packages with `nvim --headless`, not sure if this possible when using the new package
manager builtin to neovim as it prompts for user input to install packages.
- With lazy this was done with `nvim --headless "+Lazy! sync" +qa`

View File

@@ -23,7 +23,8 @@ done
echo "Args to bootstrap scripts: $args" echo "Args to bootstrap scripts: $args"
echo "Installing packages may require your password multiple times." echo "Installing packages may require your password multiple times."
echo "Running packages" && $DEV_ENV/run "$args"
echo "Installing configuration" && $DEV_ENV/dev-env "$args" echo "Installing configuration" && $DEV_ENV/dev-env "$args"
# TODO: Need to run system run early, then once ssh keys are setup pull
# git submodules, then run config install again.
echo "Running packages" && $DEV_ENV/run "$args"
echo "Installing webapps" && $DEV_ENV/webapp "$args" echo "Installing webapps" && $DEV_ENV/webapp "$args"
echo "Starting system services" && $DEV_ENV/system "$args"

View File

@@ -153,7 +153,7 @@ copy_files $DEV_ENV/env/wallpapers $HOME/wallpapers
mkdir $HOME/Pictures >/dev/null 2>&1 mkdir $HOME/Pictures >/dev/null 2>&1
mkdir -p $XDG_DATA_HOME/clipse/tmp_files mkdir -p $XDG_DATA_HOME/clipse/tmp_files
copy $DEV_ENV/dev-env $HOME/.local/scripts/dev-env copy $DEV_ENV/dev-env $HOME/.local/scripts/dev-env
copy $DEV_ENV/env/.markdownlint.jsonc $HOME/.makrdownlint.jsonc copy $DEV_ENV/env/.markdownlint.jsonc $HOME/.markdownlint.jsonc
copy $DEV_ENV/env/.prettierrc.yaml $HOME/.prettierrc.yaml copy $DEV_ENV/env/.prettierrc.yaml $HOME/.prettierrc.yaml
mkdir -p $XDG_DATA_HOME/applications/icons mkdir -p $XDG_DATA_HOME/applications/icons

View File

@@ -11,7 +11,7 @@ input {
kb_rules = kb_rules =
repeat_rate = 50 repeat_rate = 50
repeat_delay = 175 repeat_delay = 200
follow_mouse = 2 follow_mouse = 2

View File

@@ -16,7 +16,7 @@ $fileManager = $terminal -e yazi
$fileBrowser = uwsm app -- nautilus $fileBrowser = uwsm app -- nautilus
$menu = hyprlauncher $menu = hyprlauncher
$scripts = ~/.local/scripts/hypr $scripts = ~/.local/scripts/hypr
$pwa = $scripts/launch-webapp $pwa = $scripts/webapp launch
$tmuxSessionator = ~/.local/scripts/tmux-sessionator $tmuxSessionator = ~/.local/scripts/tmux-sessionator
$clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse $clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse
$uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app $uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app

View File

@@ -2,13 +2,5 @@
# https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html # https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html
enable-ssh-support enable-ssh-support
ttyname $GPG_TTY ttyname $GPG_TTY
default-cache-ttl 60 default-cache-ttl 120
max-cache-ttl 120 max-cache-ttl 120
#pinentry-program /usr/bin/pinentry-curses
#pinentry-program /usr/bin/pinentry-gnome3
#pinentry-program /bin/pinentry-tty
#pinentry-program /usr/bin/pinentry-x11
#pinentry-program /usr/local/bin/pinentry-curses
#pinentry-program /bin/pinentry-dmenu
#pinentry-program /opt/homebrew/bin/pinentry-mac

View File

@@ -3,7 +3,9 @@
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file # Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
THIS_FILE=${BASH_SOURCE[0]} THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE") THIS=${THIS:-$(basename "$THIS_FILE")}
LOG_FILE=${LOG_FILE:-"$THIS.log"}
LOG_LABEL=$(basename "$THIS_FILE")
function usage() { function usage() {
cat <<EOF cat <<EOF
@@ -237,7 +239,7 @@ EOF
# Setup logging file and label # Setup logging file and label
source "$SCRIPTS/hypr/logging" source "$SCRIPTS/hypr/logging"
setup-logging "$THIS.log" "$THIS" setup-logging "$LOG_FILE" "$LOG_LABEL"
export LOG_ENABLE_DRY_RUN="$dry_run" export LOG_ENABLE_DRY_RUN="$dry_run"
if [[ -z "$XDG_DATA_HOME" ]]; then if [[ -z "$XDG_DATA_HOME" ]]; then
@@ -287,7 +289,7 @@ set_icon_ref
# Check that an exec command is set, or default to the 'launch-webapp' script. # Check that an exec command is set, or default to the 'launch-webapp' script.
if [[ -z $exec_cmd ]]; then if [[ -z $exec_cmd ]]; then
exec_cmd="$SCRIPTS/hypr/launch-webapp $app_url" exec_cmd="$SCRIPTS/hypr/webapp launch $app_url"
fi fi
log "\e[032mCreating web app:\e[0m $desktop_file" log "\e[032mCreating web app:\e[0m $desktop_file"

View File

@@ -4,7 +4,7 @@
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}" SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
THIS_FILE=${BASH_SOURCE[0]} THIS_FILE=${BASH_SOURCE[0]}
LOG_LABEL=$(basename "$THIS_FILE") LOG_LABEL=$(basename "$THIS_FILE")
THIS=$(basename "$THIS_FILE") THIS=${THIS:-$(basename "$THIS_FILE")}
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"} LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
usage() { usage() {
@@ -29,7 +29,7 @@ NOTES:
Any extra arguments after '--' get passed directly to the browser invocation. Any extra arguments after '--' get passed directly to the browser invocation.
$ launch-webapp https://example.com -- --some-random-flag-for-browser=1 $ $THIS https://example.com -- --some-random-flag-for-browser=1
Any options passed in prior to the '--' get sent to the 'launch' script, so you can pass Any options passed in prior to the '--' get sent to the 'launch' script, so you can pass
options that are not specifically shown here, but the ones shown would be the most commonly options that are not specifically shown here, but the ones shown would be the most commonly
@@ -94,7 +94,7 @@ fi
# Any left over args after "--" # Any left over args after "--"
app_args="$@" app_args="$@"
log "URL: $url" log "Launching URL: $url"
log " Launch args: ${launch_args[@]}" log " Launch args: ${launch_args[@]}"
log " App args: ${app_args}" log " App args: ${app_args}"

57
env/.local/scripts/hypr/webapp vendored Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
LOG_LABEL=$(basename "$THIS_FILE")
THIS=${THIS:-$LOG_LABEL}
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
usage() {
cat <<EOF
Utility for launching or installing a progressive web app.
USAGE:
$ $THIS <flags> <command>
FLAGS:
-h | --help: Show this help page.
COMMANDS:
install: Generate a '.desktop' file for a web app.
launch: Launch a url as a web app.
RUN '$THIS <command> --help' for more information about a command.
EOF
}
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$LOG_FILE" "$LOG_LABEL"
while [[ $# -gt 0 ]]; do
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage
elif [[ $1 == "install" ]]; then
shift
THIS="$THIS install" "$SCRIPTS/hypr/utils/webapp/install" "$@"
elif [[ $1 == "launch" ]]; then
shift
THIS="$THIS launch" "$SCRIPTS/hypr/utils/webapp/launch" "$@"
fi
shift
done

View File

@@ -17,8 +17,7 @@ KBD=${KBD:-""} # Keyboard config to use, either "voyager" or "macbook"
usage() { usage() {
cat <<EOF cat <<EOF
Manages kanata qmk keyboard program, which needs to be built locally. Currently the linux builds Manages kanata qmk keyboard program, which needs to be built locally. Also manages the kanata systemd service.
are only for x86. Also manages the kanata systemd service.
USAGE: USAGE:
@@ -30,8 +29,6 @@ FLAGS:
COMMANDS: COMMANDS:
config: Commands for the kanata keyboard configuration file(s). config: Commands for the kanata keyboard configuration file(s).
service: Commands for the kanata systemd service. service: Commands for the kanata systemd service.
pkg: Commands for the kanata package.
bootstrap: Bootstrap a new machine, performs installation, enables, and starts kanata systemd service.
logs: View the log file. logs: View the log file.
Run "$THIS <command> --help" for more information about a command. Run "$THIS <command> --help" for more information about a command.
@@ -44,16 +41,6 @@ log() {
logging log --source "$THIS_FILE" "$@" logging log --source "$THIS_FILE" "$@"
} }
# Bootstrap a new machine, by building and installing the kanata executable,
# installing the systemd service files, and enable / start the service.
bootstrap() {
log "Bootstrapping new system..."
$THIS_FILE pkg install
$THIS_FILE service install
$THIS_FILE service enable
$THIS_FILE service start
}
################################################################################ ################################################################################
# MAIN # MAIN
################################################################################ ################################################################################
@@ -65,8 +52,6 @@ setup-logging "$LOG_FILE" "$LOG_LABEL"
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0 usage && exit 0
elif [[ $1 == "bootstrap" ]]; then
bootstrap && exit 0
elif [[ $1 == "config" ]]; then elif [[ $1 == "config" ]]; then
shift shift
THIS="$THIS config" $SCRIPTS/utils/kanatactl/config "$@" THIS="$THIS config" $SCRIPTS/utils/kanatactl/config "$@"
@@ -75,10 +60,6 @@ while [[ $# -gt 0 ]]; do
shift shift
THIS="$THIS service" $SCRIPTS/utils/kanatactl/service "$@" THIS="$THIS service" $SCRIPTS/utils/kanatactl/service "$@"
exit $? exit $?
elif [[ $1 == "pkg" ]]; then
shift
THIS="$THIS pkg" $SCRIPTS/utils/kanatactl/pkg "$@"
exit $?
elif [[ $1 == "logs" ]]; then elif [[ $1 == "logs" ]]; then
bat ${LOG_DIR:-/tmp/logs}/$LOG_FILE && exit 0 bat ${LOG_DIR:-/tmp/logs}/$LOG_FILE && exit 0
elif [[ $1 == "update" ]]; then elif [[ $1 == "update" ]]; then

View File

@@ -1,193 +0,0 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
LOG_LABEL=$(basename "$THIS_FILE")
THIS=${THIS:-$LOG_LABEL}
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
usage() {
cat <<EOF
Manage the kanata package / crate.
USAGE:
$ $THIS <command> <flags> <args...>
FLAGS:
-h | --help: Show this help page.
COMMANDS:
install: Install the kanata package.
update: Updates the kanata package.
EOF
}
kanata_dir="$XDG_CACHE_HOME/kanata"
kanata_url="https://github.com/jtroo/kanata.git"
kanata_current_version=""
install_mode="0"
update_mode="0"
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
get_current_version() {
if [[ $(command -v /usr/bin/kanata) ]]; then
kanata_current_version=$(/usr/bin/kanata --version)
# Remove 'kanata ' from output of the version command.
kanata_current_version="${kanata_current_version#kanata *}"
fi
}
# Get's kanat versions by git tag and filter's out versions that are less than our
# current version number.
get_versions() {
get_current_version
local rows=()
local tag=""
local has_seen_current="0"
for tag in $(git tag --list 'v*' | sort --version-sort); do
if [[ $has_seen_current == "1" ]] || [[ -z $kanata_current_version ]]; then
rows+=("$tag\n")
elif [[ $tag =~ $kanata_current_version ]]; then
has_seen_current="1"
fi
done
echo "$(echo -e "${rows[@]}" | sort --version-sort --reverse | tr -d ' ')"
}
# Present an fzf menu to choose a version to install / update to.
prompt_for_version_to_install() {
local rows=$(get_versions)
if [[ -z $rows ]]; then
log --error "No versions to select." && exit 1
else
echo $(printf '%s\n' "${rows[@]}" | fzf --header='Which version would you like to install?')
fi
}
# Compares the selected version to the installed version.
compare_versions() {
# An example selection at this point: 'v1.9.0'
local selection=""
read -r selection
if [[ $(command -v /usr/bin/kanata) ]] && [[ -n $selection ]]; then
[[ -z $kanata_current_version ]] && get_current_version
local selected_version=${selection#v*} # remove the 'v' from selected version.
log "Comparing selected: '$selected_version' to installed '$kanata_current_version'"
if [[ $selected_version == $kanata_current_version ]]; then
log --warn "Selected version matches the currently installed version." && exit 1
fi
fi
echo "$selection"
}
# Check's out the selected version tag and builds the kanata executable.
build_selection() {
# An example selection at this point: 'v1.9.0'
local selection=""
read -r selection
if [[ -z $selection ]]; then
log --error "Selection is empty." && exit 1
# Handle logged messages instead of an actual selection.
elif [[ $selection =~ "[WARN]" ]] || [[ $selection =~ "[ERROR]" ]]; then
echo $selection && exit 1
fi
if [[ $selection =~ ^v ]]; then
log "Building kanata..."
# checkout the selected version tag and build.
git checkout $selection
cargo build --release --features cmd
echo "done"
fi
}
# Copies the most recently built kanata executable to the '/usr/bin' directory.
#
copy_to_usr_bin() {
# This is the end of the install / update pipe, so it loops over output of
# the other commands in the pipe printing it to the console, while waiting on the
# build to be done.
while read line; do
if [[ $line == "done" ]]; then
log "Copying to '/usr/bin/kanata'" && echo "Copying to '/usr/bin/kanata'"
sudo cp target/release/kanata /usr/bin
echo "Done!"
else
echo "$line"
fi
done
}
title() {
if [[ $update_mode == "1" ]]; then
echo "Updating"
else
echo "Installing"
fi
}
# Handles both install or update commands, as they do the same thing.
install_or_update() {
local mode=$(title)
log "$mode kanata..."
local should_pull="1"
if [[ ! -d $kanata_dir ]]; then
log "Cloning repo."
should_pull="0"
git clone $kanata_url $kanata_dir
fi
pushd $kanata_dir &>/dev/null
(
[[ $should_pull == "1" ]] && git pull origin main >/dev/null 2>&1
prompt_for_version_to_install | compare_versions | build_selection | copy_to_usr_bin
)
popd &>/dev/null
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$LOG_FILE" "$LOG_LABEL"
while [[ $# -gt 0 ]]; do
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0
elif [[ $1 == "install" ]]; then
shift
install_mode="1"
install_or_update "$@"
exit $?
elif [[ $1 == "update" ]]; then
shift
update_mode="1"
install_or_update "$@"
exit $?
fi
done
# If we made it here, then none of the commands handled the arguments, so show the
# usage and exit
usage && exit 1

View File

@@ -11,6 +11,13 @@ THIS=${THIS:-$LOG_LABEL}
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"} LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
DEV_ENV=${DEV_ENV:-""} DEV_ENV=${DEV_ENV:-""}
declare user_flag system_flag prompt_flag mode
declare -a args
user_flag="1"
system_flag="0"
prompt_flag="0"
mode=""
usage() { usage() {
cat <<EOF cat <<EOF
Manages the kanata systemd service. Manages the kanata systemd service.
@@ -21,6 +28,9 @@ USAGE:
FLAGS: FLAGS:
-h | --help: Show this help page. -h | --help: Show this help page.
--user: Setup systemd service as a user service (default).
--system: Setup systemd service as a system service.
--prompt: Prompt the user to install service as system or user service.
COMMANDS: COMMANDS:
enable: Enable the kanata service. enable: Enable the kanata service.
@@ -45,7 +55,11 @@ log() {
enable_service() { enable_service() {
log "Enabling kanata service..." log "Enabling kanata service..."
sudo systemctl enable kanata.service if [[ $user_flag == "1" ]]; then
systemctl --user enable --now kanata.service
else
sudo systemctl enable --now kanata.service
fi
} }
get_status() { get_status() {
@@ -53,18 +67,52 @@ get_status() {
systemctl status kanata.service systemctl status kanata.service
} }
prompt_user() {
log "Prompting user for how they would like to setup kanata systemd service..."
local choice
choice=$(echo -e "user\nsystem" | fzf --header "How would you like to setup the kanata systemd service?")
if [[ $choice == "system" ]]; then
user_flag="0"
system_flag="1"
elif [[ $choice == "user" ]]; then
user_flag="1"
system_flag="0"
else
exit 1
fi
}
install_service() { install_service() {
local service_dir="user"
if [[ -z $DEV_ENV ]]; then if [[ -z $DEV_ENV ]]; then
log --error "DEV_ENV is not set properly." && exit 1 log --error "DEV_ENV is not set properly." && exit 1
fi fi
log "Starting install service..."
# Ensure the configuration is copied / setup otherwise the keyboard may not work. # Ensure the configuration is copied / setup otherwise the keyboard may not work.
"$SCRIPTS/kanatactl" config install "$@" "$SCRIPTS/kanatactl" config install "$@"
log "Installing kanata service..." # Prompt the user for how they would like to install the systemd service, if the
# prompt flag is set.
[[ $prompt_flag == "1" ]] && prompt_user || exit 1
[[ $system_flag == "1" ]] && service_dir="system"
log "Installing kanata service as: '$service_dir' service..."
if [[ $service_dir == "system" ]]; then
[[ -f /etc/systemd/system/kanata.service ]] && sudo rm -rf /etc/systemd/system/kanata.service [[ -f /etc/systemd/system/kanata.service ]] && sudo rm -rf /etc/systemd/system/kanata.service
sudo cp "$DEV_ENV/env/etc/systemd/system/kanata.service" /etc/systemd/system sudo cp "$DEV_ENV/env/etc/systemd/system/kanata.service" /etc/systemd/system
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable --now kanata.service
else
[[ -f ~/.config/systemd/user/kanata.service ]] && rm -rf ~/.config/systemd/user/kanata.service
mkdir -p ~/.config/systemd/user &>/dev/null
cp "$DEV_ENV/env/etc/systemd/user/kanata.service" ~/.config/systemd/user
systemctl --user daemon-reload
systemctl --user enable --now kanata.service
fi
} }
start_service() { start_service() {
@@ -96,26 +144,42 @@ restart_service() {
source "$SCRIPTS/hypr/logging" source "$SCRIPTS/hypr/logging"
setup-logging "$LOG_FILE" "$LOG_LABEL" setup-logging "$LOG_FILE" "$LOG_LABEL"
# Parse flags / arguments.
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0 usage && exit 0
elif [[ $1 == "disable" ]]; then elif [[ $1 == "--user" ]]; then
disable_service && exit $? user_flag="1"
elif [[ $1 == "enable" ]]; then elif [[ $1 == "--system" ]]; then
enable_service && exit $? system_flag="1"
elif [[ $1 == "install" ]]; then elif [[ $1 == "--prompt" ]]; then
shift prompt_flag="1"
install_service "$@" && exit $? # Set first non-flag to the mode / subcommand.
elif [[ $1 == "start" ]]; then elif [[ -z $mode ]]; then
start_service && exit $? mode="$1"
elif [[ $1 == "status" ]]; then # Add any other arguments to the 'args' array.
get_status && exit $? else
elif [[ $1 == "stop" ]]; then args+=("$1")
stop_service && exit $?
elif [[ $1 == "restart" ]]; then
restart_service && exit $?
fi fi
shift
done done
# Handle mode.
if [[ $mode == "disable" ]]; then
disable_service && exit $?
elif [[ $mode == "enable" ]]; then
enable_service && exit $?
elif [[ $mode == "install" ]]; then
install_service "${args[@]}" && exit $?
elif [[ $mode == "start" ]]; then
start_service && exit $?
elif [[ $mode == "status" ]]; then
get_status && exit $?
elif [[ $mode == "stop" ]]; then
stop_service && exit $?
elif [[ $mode == "restart" ]]; then
restart_service && exit $?
else
# If we made it here, then none of the subcommands handled the args. # If we made it here, then none of the subcommands handled the args.
usage && exit 1 usage && exit 1
fi

12
env/etc/systemd/user/kanata.service vendored Normal file
View File

@@ -0,0 +1,12 @@
[Unit]
Description=Kanata Service
Documentation=https://github.com/jtroo/kanata
[Service]
Environment=PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin
Type=simple
ExecStart=/bin/sh -c 'exec /usr/bin/kanata --cfg /home/michael/.config/kanata/config.kbd'
Restart=no
[Install]
WantedBy=default.target

16
runs/after/espanso Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
install() {
log " Setting up espanso."
sudo setcap "cap_dac_override+p" "$(which espanso)"
espanso service register
systemctl --user daemon-reload
espanso service start
}
arg=${1:-""}
[[ $arg == "install" ]] && install && exit 0

16
runs/after/gopass Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME"/.local/share}
install() {
[[ ! -d "$XDG_DATA_HOME/gopass/stores/root" ]] &&
gopass clone ssh://git@git.housh.dev:2222/michael/passwordstore.git
}
uninstall() {
[[ -d "$XDG_DATA_HOME/gopass" ]] && rm -rf "$XDG_DATA_HOME/gopass"
}
arg=${1:-""}
[[ $arg == "install" ]] && install
[[ $arg == "uninstall" ]] && uninstall

79
runs/after/system Executable file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
# Set scripts to be in the DEV_ENV folder encase they have not been
# installed yet.
SCRIPTS="${DEV_ENV}/env/.local/scripts"
_setup-mounts() {
local line="nas.housh.dev:/var/nfs/shared/michael_share /mnt/michael nfs defaults 0 0"
if sudo cat /etc/fstab | grep -vq "$line"; then
log " Setting up nas mount."
sudo mkdir -p /mnt/michael &>/dev/null
echo "$line" | sudo tee --append /etc/fstab
sudo systemctl daemon-reload
sudo mount -a ||
log --warning "You will need to make sure this computer's ip is in the allow list, then run 'sudo mount -a'"
fi
}
_setup-kanata() {
log " Setting up kanata udev rules."
sudo groupadd --system uinput
sudo usermod -aG input "$USER"
sudo usermod -aG uinput "$USER"
[[ ! -f /etc/udev/rules.d/99-input.rules ]] &&
(
echo 'KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"' |
sudo tee /etc/udev/rules.d/99-input.rules
) &&
sudo udevadm control --reload-rules &&
sudo udevadm trigger &&
sudo modprobe uinput
log " Setting up kanata, using kanatactl."
SCRIPTS="$SCRIPTS" "$SCRIPTS/kanatactl" service install --prompt
}
_setup-gpg() {
log " Setting up gpg."
mkdir -p ~/{.gnupg,.ssh} &>/dev/null
chmod 700 ~/.gnupg
chmod 700 ~/.ssh
local dir=/tmp/gpg-public-key
git clone https://git.housh.dev/michael/gpg-public-key.git "$dir"
pushd "$dir" &>/dev/null || exit 1
(
source ./import
)
popd &>/dev/null || exit 1
rm -rf "$dir"
}
_setup-home-dir() {
log " Setting up home directory."
rm -rf "$HOME/Desktop" &>/dev/null
mkdir "$HOME/{containers,dev}" &>/dev/null
mkdir -p "$HOME/work/consults" &>/dev/null
}
install() {
log " Setting user shell to 'zsh'."
sudo chsh --shell "$(which zsh)"
log " Enabling systemd services."
sudo systemctl daemon-reload
sudo systemctl enable --now pcscd.service
sudo systemctl enable --now firewalld.service
systemctl --user enable --now logout-task.service
systemctl --user enable --now battery-monitor.timer
systemctl --user enable --now tmux-kill-sessions.timer
_setup-kanata
_setup-mounts
_setup-gpg
_setup-home-dir
}
arg=${1:-""}
[[ $arg == "install" ]] && install

13
runs/before/espanso Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
uninstall() {
log " Tearing down espanso."
espanso service stop
espanso service unregister
}
arg=${1:-""}
[[ $arg == "uninstall" ]] && uninstall && exit 0

View File

@@ -7,6 +7,7 @@ fzf
git-lfs git-lfs
gum gum
jq jq
libtexprintf
neovim neovim
nodejs nodejs
npm npm

View File

@@ -18,7 +18,7 @@ GREP_STR=${RUN_GREP_STR:-""}
log() { log() {
logging log --source "$THIS_FILE" --echo "$@" logging log --source "$THIS_FILE" --echo "$@"
} && export -f log }
run_before_or_after() { run_before_or_after() {
local dir file run local dir file run

43
system
View File

@@ -1,43 +0,0 @@
#!/usr/bin/env bash
# Enable system services.
dry_run="0"
while [[ $# -gt 0 ]]; do
echo "ARG: \"$1\""
# Handle a --dry or --dry-run argument
if [[ "$1" =~ ^--dry ]]; then
dry_run="1"
fi
shift
done
log() {
if [[ $dry_run == "1" ]]; then
echo "[DRY_RUN]: $1"
else
echo "$1"
fi
}
log_and_run() {
log "Running: \"$*\""
if [[ $dry_run == "0" ]]; then
eval "$1"
fi
}
log_and_run "sudo chsh --shell $(which zsh)"
log_and_run "systemctl --user daemon-reload"
log_and_run "systemctl --user enable --now hyprpaper.service"
log_and_run "systemctl --user enable --now hypridle.service"
log_and_run "espanso service register"
log_and_run "sudo setcap "cap_dac_override+p" $(which espanso)"
log_and_run "systemctl --user enable --now logout-task.service"
log_and_run "systemctl --user enable --now battery-monitor.timer"
log_and_run "systemctl --user enable --now tmux-kill-sessions.timer"
log_and_run "sudo systemctl enable --now pcscd.service"
log_and_run "sudo systemctl enable --now firewalld.service"

4
webapp
View File

@@ -51,7 +51,7 @@ log() {
install() { install() {
local file=$DEV_ENV/env/webapps/$(basename $1) local file=$DEV_ENV/env/webapps/$(basename $1)
local script="$DEV_ENV/env/.local/scripts/hypr/install-webapp" local script="$DEV_ENV/env/.local/scripts/hypr/webapp"
if [[ ! -x $script ]]; then if [[ ! -x $script ]]; then
log "Failed to find install web app script." log "Failed to find install web app script."
@@ -69,7 +69,7 @@ install() {
log "Installing webapp from spec: $file" log "Installing webapp from spec: $file"
if [[ $dry_run == "0" ]]; then if [[ $dry_run == "0" ]]; then
$script --file $file --no-interactive $script install --file $file --no-interactive
fi fi
} }