From f72eb89868fcd25f35418ec45afd79c9814819a9 Mon Sep 17 00:00:00 2001 From: notcandy001 Date: Sun, 23 Aug 2026 18:52:23 +0530 Subject: [PATCH 1/3] =?UTF-8?q?well=20fixed=20the=20thing=20u=20asked=20fo?= =?UTF-8?q?r=20=F0=9F=98=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dots-extra/install-arch.sh | 185 ++++++++++-------- .../templates/templates/startup.conf.tpl | 11 ++ .../templates/templates/startup.lua.tpl | 11 ++ 3 files changed, 127 insertions(+), 80 deletions(-) create mode 100644 dots-extra/templates/templates/startup.conf.tpl create mode 100644 dots-extra/templates/templates/startup.lua.tpl diff --git a/dots-extra/install-arch.sh b/dots-extra/install-arch.sh index 92dcb14..ca42897 100644 --- a/dots-extra/install-arch.sh +++ b/dots-extra/install-arch.sh @@ -4,6 +4,7 @@ # Invoked by install.sh: $1=HYPRLAND_CONF $2=BACKUP_DIR $3=CONFIG_TYPE # ───────────────────────────────────────────────────────────────────────────── + set -eo pipefail # ── Arguments (validated up-front) ─────────────────────────────────────────── @@ -37,25 +38,6 @@ step() { declare -a FAILED_PKGS=() -# ══════════════════════════════════════════════════════════════════════════════ -# PACKAGE HELPERS -# ══════════════════════════════════════════════════════════════════════════════ - -# pacman_install [ ...] -# -# Strategy (three attempts, most to least aggressive): -# -# 1. Bulk install — fastest; skips already-installed packages via --needed. -# -# 2. Per-package retry — if the bulk transaction fails because ONE package -# has a conflict, the entire batch is rejected. Retrying individually -# isolates which package is actually broken so the rest can still install. -# -# 3. --overwrite='*' per package — resolves FILE-OWNERSHIP conflicts, where -# two packages both claim the same path. Safe in practice: the new package -# just wins the ownership. This does NOT help with hard PKGBUILD conflicts -# (ConflictsWith). Those need manual resolution (see summary output). -# pacman_install() { local -a pkgs=("$@") local total=${#pkgs[@]} @@ -158,9 +140,7 @@ aur_install() { } -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 1 — AUR Helper -# ══════════════════════════════════════════════════════════════════════════════ + step 1 "AUR Helper" AUR_HELPER="" @@ -205,9 +185,7 @@ else fi -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 2 — Pacman Packages -# ══════════════════════════════════════════════════════════════════════════════ + step 2 "Pacman Packages" PACMAN_DEPS=( @@ -255,9 +233,7 @@ sudo pacman -Syu --noconfirm 2>/dev/null || { pacman_install "${PACMAN_DEPS[@]}" -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 3 — AUR Packages -# ══════════════════════════════════════════════════════════════════════════════ + step 3 "AUR Packages" AUR_DEPS=( @@ -288,9 +264,7 @@ if ! "$AUR_HELPER" -Q quickshell &>/dev/null 2>&1; then fi -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 4 — Systemd Services -# ══════════════════════════════════════════════════════════════════════════════ + step 4 "Systemd Services" _svc_system() { @@ -312,67 +286,120 @@ _svc_user pipewire-pulse _svc_user wireplumber -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 5 — Hyprland Config -# ══════════════════════════════════════════════════════════════════════════════ step 5 "Hyprland Config" -# Marker used to detect whether the block was already appended -_MARKER="quickshell.*Brain_Shell" +STARTUP_CONF="$HOME/.config/hypr/brain-shell-startup.conf" +STARTUP_LUA="$HOME/.config/hypr/brain-shell-startup.lua" + +_BEGIN_MARK_CONF="# >>> Brain Shell Startup >>>" +_END_MARK_CONF="# <<< Brain Shell Startup <<<" +_BEGIN_MARK_LUA="-- >>> Brain Shell Startup >>>" +_END_MARK_LUA="-- <<< Brain Shell Startup <<<" -_append_conf() { - cat << 'EOF' >> "$1" +detect_keyboard_layout() { + local layout="" variant="" -# Brain Shell Autostarts -exec-once = awww-daemon -exec-once = hypridle -c $HOME/.local/src/Brain_Shell/src/config/hypridle.conf -exec-once = quickshell -c $HOME/.local/src/Brain_Shell/. -exec-once = systemctl --user start hyprpolkitagent -exec-once = wl-paste --type text --watch cliphist store -exec-once = wl-paste --type image --watch cliphist store -EOF + if command -v localectl &>/dev/null; then + local status; status="$(localectl status 2>/dev/null)" + layout="$(awk -F': ' '/X11 Layout/{print $2; exit}' <<< "$status" | tr -d '[:space:]')" + variant="$(awk -F': ' '/X11 Variant/{print $2; exit}' <<< "$status" | tr -d '[:space:]')" + fi + + if [[ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]] && command -v hyprctl &>/dev/null && command -v python3 &>/dev/null; then + local hypr_layout + hypr_layout="$(hyprctl -j devices 2>/dev/null | python3 -c ' +import json, sys +try: + data = json.load(sys.stdin) + kbs = data.get("keyboards", []) + kb = next((k for k in kbs if k.get("main")), kbs[0] if kbs else {}) + print(kb.get("layout", "").split(",")[0].strip()) +except Exception: + pass +' 2>/dev/null)" + [[ -n "$hypr_layout" ]] && layout="$hypr_layout" + fi + + layout="${layout%%,*}" + [[ -z "$layout" ]] && layout="us" + + printf '%s\t%s\n' "$layout" "$variant" } -_append_lua() { - cat << 'EOF' >> "$1" - --- Brain Shell Autostarts -hl.on("hyprland.start", function() - hl.exec_cmd("awww-daemon") - hl.exec_cmd("hypridle -c " .. os.getenv("HOME") .. "/.local/src/Brain_Shell/src/config/hypridle.conf") - hl.exec_cmd("quickshell -c " .. os.getenv("HOME") .. "/.local/src/Brain_Shell") - hl.exec_cmd("systemctl --user start hyprpolkitagent") - hl.exec_cmd("wl-paste --type text --watch cliphist store") - hl.exec_cmd("wl-paste --type image --watch cliphist store") -end) -EOF +KB_LAYOUT=""; KB_VARIANT="" +IFS=$'\t' read -r KB_LAYOUT KB_VARIANT <<< "$(detect_keyboard_layout)" +log_ok "Keyboard layout detected: ${KB_LAYOUT}${KB_VARIANT:+ (${KB_VARIANT})}" + +mkdir -p "$HOME/.config/hypr" + +_render_template() { + local tpl="$1" out="$2" + sed -e "s|__KB_LAYOUT__|${KB_LAYOUT}|g" -e "s|__KB_VARIANT__|${KB_VARIANT}|g" "$tpl" > "$out" } -if grep -q "$_MARKER" "$HYPRLAND_CONF" 2>/dev/null; then - log_warn "Autostart block already present — skipping." -else - case "$CONFIG_TYPE" in +_render_template "$REPO_DIR/dots-extra/templates/startup.conf.tpl" "$STARTUP_CONF" +_render_template "$REPO_DIR/dots-extra/templates/startup.lua.tpl" "$STARTUP_LUA" +log_ok "Generated $STARTUP_CONF" +log_ok "Generated $STARTUP_LUA" + +remove_legacy_inline_block() { + local file="$1" type="$2" + case "$type" in conf) - _append_conf "$HYPRLAND_CONF" - log_ok "Autostart block appended to hyprland.conf" + if grep -q "^# Brain Shell Autostarts$" "$file" 2>/dev/null; then + sed -i '/^# Brain Shell Autostarts$/,/^exec-once = wl-paste --type image --watch cliphist store$/d' "$file" + log_ok "Removed legacy inline autostart block from $(basename "$file")" + fi ;; lua) - # Extra safety backup before touching a Lua config - cp "$HYPRLAND_CONF" "${HYPRLAND_CONF}.pre-brain-shell" - log_info "Safety backup: ${HYPRLAND_CONF}.pre-brain-shell" - _append_lua "$HYPRLAND_CONF" - log_ok "Autostart block appended to hyprland.lua" - ;; - *) - log_warn "Unknown config type '$CONFIG_TYPE' — skipping Hyprland config update." + if grep -q "^-- Brain Shell Autostarts$" "$file" 2>/dev/null; then + sed -i '/^-- Brain Shell Autostarts$/,/^end)$/d' "$file" + log_ok "Removed legacy inline autostart block from $(basename "$file")" + fi ;; esac -fi +} + +remove_existing_marked_block() { + local file="$1" begin="$2" end="$3" + if grep -qF -- "$begin" "$file" 2>/dev/null; then + sed -i "\\|${begin}|,\\|${end}|d" "$file" + log_ok "Removed previous Brain Shell startup line from $(basename "$file") (reinstall)" + fi +} + +cp "$HYPRLAND_CONF" "${HYPRLAND_CONF}.pre-brain-shell" +log_info "Safety backup: ${HYPRLAND_CONF}.pre-brain-shell" + +case "$CONFIG_TYPE" in + conf) + remove_legacy_inline_block "$HYPRLAND_CONF" conf + remove_existing_marked_block "$HYPRLAND_CONF" "$_BEGIN_MARK_CONF" "$_END_MARK_CONF" + { + echo "" + echo "$_BEGIN_MARK_CONF" + echo 'source = $HOME/.config/hypr/brain-shell-startup.conf' + echo "$_END_MARK_CONF" + } >> "$HYPRLAND_CONF" + log_ok "Brain Shell startup sourced from hyprland.conf (1 line)" + ;; + lua) + remove_legacy_inline_block "$HYPRLAND_CONF" lua + remove_existing_marked_block "$HYPRLAND_CONF" "$_BEGIN_MARK_LUA" "$_END_MARK_LUA" + { + echo "" + echo "$_BEGIN_MARK_LUA" + echo 'dofile(os.getenv("HOME") .. "/.config/hypr/brain-shell-startup.lua")' + echo "$_END_MARK_LUA" + } >> "$HYPRLAND_CONF" + log_ok "Brain Shell startup loaded from hyprland.lua (1 line)" + ;; + *) + log_warn "Unknown config type '$CONFIG_TYPE' — skipping Hyprland config update." + ;; +esac -# ══════════════════════════════════════════════════════════════════════════════ -# STEP 6 — Brain Shell Config & Keybind Check -# ══════════════════════════════════════════════════════════════════════════════ step 6 "Brain Shell Config" USER_DATA="$HOME/.config/Brain_Shell/src/user_data" @@ -482,9 +509,7 @@ print(" Re-assign them: Dashboard → Config → Keybinds\n") PYEOF -# ══════════════════════════════════════════════════════════════════════════════ -# SUMMARY -# ══════════════════════════════════════════════════════════════════════════════ + echo "" echo -e " ${DIM}$(printf '%.0s─' {1..50})${NC}" diff --git a/dots-extra/templates/templates/startup.conf.tpl b/dots-extra/templates/templates/startup.conf.tpl new file mode 100644 index 0000000..eb74ad9 --- /dev/null +++ b/dots-extra/templates/templates/startup.conf.tpl @@ -0,0 +1,11 @@ +exec-once = awww-daemon +exec-once = hypridle -c $HOME/.local/src/Brain_Shell/src/config/hypridle.conf +exec-once = quickshell -c $HOME/.local/src/Brain_Shell/. +exec-once = systemctl --user start hyprpolkitagent +exec-once = wl-paste --type text --watch cliphist store +exec-once = wl-paste --type image --watch cliphist store + +input { + kb_layout = __KB_LAYOUT__ + kb_variant = __KB_VARIANT__ +} diff --git a/dots-extra/templates/templates/startup.lua.tpl b/dots-extra/templates/templates/startup.lua.tpl new file mode 100644 index 0000000..03e392f --- /dev/null +++ b/dots-extra/templates/templates/startup.lua.tpl @@ -0,0 +1,11 @@ +hl.on("hyprland.start", function() + hl.exec_cmd("awww-daemon") + hl.exec_cmd("hypridle -c " .. os.getenv("HOME") .. "/.local/src/Brain_Shell/src/config/hypridle.conf") + hl.exec_cmd("quickshell -c " .. os.getenv("HOME") .. "/.local/src/Brain_Shell") + hl.exec_cmd("systemctl --user start hyprpolkitagent") + hl.exec_cmd("wl-paste --type text --watch cliphist store") + hl.exec_cmd("wl-paste --type image --watch cliphist store") + + hl.exec_cmd("hyprctl keyword input:kb_layout __KB_LAYOUT__") + hl.exec_cmd("hyprctl keyword input:kb_variant __KB_VARIANT__") +end) From a0d0f8373d5bb42cc10b4a2ea53fc937ff083957 Mon Sep 17 00:00:00 2001 From: notcandy001 Date: Sun, 23 Aug 2026 18:53:28 +0530 Subject: [PATCH 2/3] =?UTF-8?q?well=20fixed=20the=20thing=20u=20asked=20fo?= =?UTF-8?q?r=20=F0=9F=98=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dots-extra/templates/{templates => }/startup.conf.tpl | 0 dots-extra/templates/{templates => }/startup.lua.tpl | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename dots-extra/templates/{templates => }/startup.conf.tpl (100%) rename dots-extra/templates/{templates => }/startup.lua.tpl (100%) diff --git a/dots-extra/templates/templates/startup.conf.tpl b/dots-extra/templates/startup.conf.tpl similarity index 100% rename from dots-extra/templates/templates/startup.conf.tpl rename to dots-extra/templates/startup.conf.tpl diff --git a/dots-extra/templates/templates/startup.lua.tpl b/dots-extra/templates/startup.lua.tpl similarity index 100% rename from dots-extra/templates/templates/startup.lua.tpl rename to dots-extra/templates/startup.lua.tpl From fae0b41b8f351186b4df03a59b350b2715ae1e0d Mon Sep 17 00:00:00 2001 From: Rahul <138906783+notcandy001@users.noreply.github.com> Date: Wed, 26 Aug 2026 21:56:21 +0530 Subject: [PATCH 3/3] Update install-arch.sh --- dots-extra/install-arch.sh | 48 ++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/dots-extra/install-arch.sh b/dots-extra/install-arch.sh index 27d46f6..df946e2 100644 --- a/dots-extra/install-arch.sh +++ b/dots-extra/install-arch.sh @@ -4,7 +4,6 @@ # Invoked by install.sh: $1=HYPRLAND_CONF $2=BACKUP_DIR $3=CONFIG_TYPE # ───────────────────────────────────────────────────────────────────────────── - set -eo pipefail # ── Arguments (validated up-front) ─────────────────────────────────────────── @@ -38,6 +37,25 @@ step() { declare -a FAILED_PKGS=() +# ══════════════════════════════════════════════════════════════════════════════ +# PACKAGE HELPERS +# ══════════════════════════════════════════════════════════════════════════════ + +# pacman_install [ ...] +# +# Strategy (three attempts, most to least aggressive): +# +# 1. Bulk install — fastest; skips already-installed packages via --needed. +# +# 2. Per-package retry — if the bulk transaction fails because ONE package +# has a conflict, the entire batch is rejected. Retrying individually +# isolates which package is actually broken so the rest can still install. +# +# 3. --overwrite='*' per package — resolves FILE-OWNERSHIP conflicts, where +# two packages both claim the same path. Safe in practice: the new package +# just wins the ownership. This does NOT help with hard PKGBUILD conflicts +# (ConflictsWith). Those need manual resolution (see summary output). +# pacman_install() { local -a pkgs=("$@") local total=${#pkgs[@]} @@ -140,7 +158,9 @@ aur_install() { } - +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 1 — AUR Helper +# ══════════════════════════════════════════════════════════════════════════════ step 1 "AUR Helper" AUR_HELPER="" @@ -185,7 +205,9 @@ else fi - +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 2 — Pacman Packages +# ══════════════════════════════════════════════════════════════════════════════ step 2 "Pacman Packages" PACMAN_DEPS=( @@ -233,7 +255,9 @@ sudo pacman -Syu --noconfirm 2>/dev/null || { pacman_install "${PACMAN_DEPS[@]}" - +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 3 — AUR Packages +# ══════════════════════════════════════════════════════════════════════════════ step 3 "AUR Packages" AUR_DEPS=( @@ -264,7 +288,9 @@ if ! "$AUR_HELPER" -Q quickshell &>/dev/null 2>&1; then fi - +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 4 — Systemd Services +# ══════════════════════════════════════════════════════════════════════════════ step 4 "Systemd Services" _svc_system() { @@ -286,6 +312,9 @@ _svc_user pipewire-pulse _svc_user wireplumber +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 5 — Hyprland Config +# ══════════════════════════════════════════════════════════════════════════════ step 5 "Hyprland Config" STARTUP_CONF="$HOME/.config/hypr/brain-shell-startup.conf" @@ -400,6 +429,9 @@ case "$CONFIG_TYPE" in esac +# ══════════════════════════════════════════════════════════════════════════════ +# STEP 6 — Brain Shell Config & Keybind Check +# ══════════════════════════════════════════════════════════════════════════════ step 6 "Brain Shell Config" USER_DATA="$HOME/.config/Brain_Shell/src/user_data" @@ -500,7 +532,7 @@ for action, info in conflicts.items(): print(f" {'':24} already used by: {info['used_by']}\n") unbound[action] = {"mods": "", "key": ""} -config_path = os.path.expanduser("~/.config/Brain_Shell/src/user_data/keybinds.json") +config_path = os.path.expanduser("$HOME/.config/Brain_Shell/src/user_data/keybinds.json") with open(config_path, "w") as f: json.dump(unbound, f, indent=2) @@ -509,7 +541,9 @@ print(" Re-assign them: Dashboard → Config → Keybinds\n") PYEOF - +# ══════════════════════════════════════════════════════════════════════════════ +# SUMMARY +# ══════════════════════════════════════════════════════════════════════════════ echo "" echo -e " ${DIM}$(printf '%.0s─' {1..50})${NC}"