diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/lib_apps.sh | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/scripts/lib_apps.sh b/scripts/lib_apps.sh new file mode 100644 index 00000000..a1ee2fe5 --- /dev/null +++ b/scripts/lib_apps.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# App enablement and editor selection helpers. + +enable_asusctl() { + local log="$1" + if command -v asusctl >/dev/null 2>&1; then + local OVERLAY_SA="config/hypr/configs/Startup_Apps.conf" + mkdir -p "$(dirname "$OVERLAY_SA")" + touch "$OVERLAY_SA" + grep -qx 'exec-once = rog-control-center' "$OVERLAY_SA" || echo 'exec-once = rog-control-center' >>"$OVERLAY_SA" + fi +} + +enable_blueman() { + local log="$1" + if command -v blueman-applet >/dev/null 2>&1; then + local OVERLAY_SA="config/hypr/configs/Startup_Apps.conf" + mkdir -p "$(dirname "$OVERLAY_SA")" + touch "$OVERLAY_SA" + grep -qx 'exec-once = blueman-applet' "$OVERLAY_SA" || echo 'exec-once = blueman-applet' >>"$OVERLAY_SA" + fi +} + +enable_ags() { + local log="$1" + if command -v ags >/dev/null 2>&1; then + echo "${INFO:-[INFO]} AGS detected - enabling in startup and refresh scripts" 2>&1 | tee -a "$log" + local OVERLAY_SA="config/hypr/configs/Startup_Apps.conf" + mkdir -p "$(dirname "$OVERLAY_SA")" + touch "$OVERLAY_SA" + grep -qx 'exec-once = ags' "$OVERLAY_SA" || echo 'exec-once = ags' >>"$OVERLAY_SA" + sed -i '/#ags -q && ags &/s/^#//' config/hypr/scripts/RefreshNoWaybar.sh + sed -i '/#ags -q && ags &/s/^#//' config/hypr/scripts/Refresh.sh + fi +} + +enable_quickshell() { + local log="$1" + if command -v qs >/dev/null 2>&1; then + echo "${INFO:-[INFO]} Quickshell detected - enabling in startup and refresh scripts" 2>&1 | tee -a "$log" + local OVERLAY_SA="config/hypr/configs/Startup_Apps.conf" + mkdir -p "$(dirname "$OVERLAY_SA")" + touch "$OVERLAY_SA" + grep -qx 'exec-once = qs' "$OVERLAY_SA" || echo 'exec-once = qs' >>"$OVERLAY_SA" + sed -i '/#pkill qs && qs &/s/^#//' config/hypr/scripts/RefreshNoWaybar.sh + sed -i '/#pkill qs && qs &/s/^#//' config/hypr/scripts/Refresh.sh + fi +} + +ensure_keybinds_init() { + local log="$1" + local OVERLAY_SA="config/hypr/configs/Startup_Apps.conf" + mkdir -p "$(dirname "$OVERLAY_SA")" + if ! grep -qx 'exec-once = \$scriptsDir/KeybindsLayoutInit.sh' "$OVERLAY_SA"; then + echo 'exec-once = $scriptsDir/KeybindsLayoutInit.sh' >>"$OVERLAY_SA" + echo "${INFO:-[INFO]} Added KeybindsLayoutInit.sh to user Startup_Apps overlay" 2>&1 | tee -a "$log" + fi +} + +choose_default_editor() { + local log="$1" + local editor_set=0 + update_editor() { + local editor=$1 + sed -i "s/#env = EDITOR,.*/env = EDITOR,$editor #default editor/" config/hypr/UserConfigs/01-UserDefaults.conf + echo "${OK:-[OK]} Default editor set to ${MAGENTA:-}$editor${RESET:-}." 2>&1 | tee -a "$log" + } + if command -v nvim &>/dev/null; then + printf "${INFO:-[INFO]} ${MAGENTA:-}neovim${RESET:-} is detected as installed\n" + if ! read -r -p "${CAT:-[ACTION]} Do you want to make ${MAGENTA:-}neovim${RESET:-} the default editor? (y/N): " EDITOR_CHOICE </dev/tty; then + : + elif [[ "$EDITOR_CHOICE" == "y" || "$EDITOR_CHOICE" == "Y" ]]; then + update_editor "nvim" + editor_set=1 + fi + fi + printf "\n" + if [[ "$editor_set" -eq 0 ]] && command -v vim &>/dev/null; then + printf "${INFO:-[INFO]} ${MAGENTA:-}vim${RESET:-} is detected as installed\n" + if read -r -p "${CAT:-[ACTION]} Do you want to make ${MAGENTA:-}vim${RESET:-} the default editor? (y/N): " EDITOR_CHOICE </dev/tty; then + if [[ "$EDITOR_CHOICE" == "y" || "$EDITOR_CHOICE" == "Y" ]]; then + update_editor "vim" + editor_set=1 + fi + fi + fi +} |
