From beceab7fb97654483b5d505ee6d251b206143aed Mon Sep 17 00:00:00 2001 From: Don Williams Date: Fri, 24 Jul 2026 17:04:04 -0400 Subject: copy.sh was enablling lua workflow Added additional checks Signed-off-by: Don Williams On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: config/hypr/UserConfigs/01-UserDefaults.conf modified: config/hypr/configs/Startup_Apps.conf modified: config/hypr/lua/startup.lua modified: config/hypr/scripts/WallpaperDaemon.sh modified: config/hypr/scripts/WaybarStartup.sh modified: config/rofi/.current_wallpaper modified: copy.sh modified: scripts/lib_copy.sh --- config/hypr/configs/Startup_Apps.conf | 4 +-- config/hypr/lua/startup.lua | 4 +-- config/hypr/scripts/WallpaperDaemon.sh | 50 ++++++++++++++++++++++++++++++++-- config/hypr/scripts/WaybarStartup.sh | 44 ++++++++++++++++++++++-------- config/rofi/.current_wallpaper | 2 +- copy.sh | 25 ++++++++++++++++- scripts/lib_copy.sh | 33 ++++++++++++---------- 7 files changed, 127 insertions(+), 35 deletions(-) diff --git a/config/hypr/configs/Startup_Apps.conf b/config/hypr/configs/Startup_Apps.conf index f29b26f5..e83c414c 100644 --- a/config/hypr/configs/Startup_Apps.conf +++ b/config/hypr/configs/Startup_Apps.conf @@ -13,7 +13,7 @@ $livewallpaper="" $wallDIR = $HOME/Pictures/wallpapers # change path manually here if needed ### wallpaper stuff ### -exec-once = sh -c 'sleep 2; $HOME/.config/hypr/scripts/WallpaperDaemon.sh' +exec-once = sh -c 'sleep 2; $HOME/.config/hypr/scripts/WallpaperDaemon.sh; $HOME/.config/hypr/scripts/ApplyThemeMode.sh; $HOME/.config/hypr/scripts/WaybarStartup.sh' #exec-once = mpvpaper '*' -o "load-scripts=no no-audio --loop" $livewallpaper # wallpaper random #exec-once = $SwwwRandom $wallDIR # random wallpaper switcher every 30 minutes @@ -29,8 +29,6 @@ exec-once = swaync #exec-once = blueman-applet #exec-once = rog-control-center exec-once = $scriptsDir/PortalHyprland.sh -exec-once = sh $HOME/.config/hypr/scripts/ApplyThemeMode.sh -exec-once = sh $scriptsDir/WaybarStartup.sh # Cursor refresh (enabled by installer on hybrid NVIDIA/GDM setups) exec-once = sh -c 'sleep 0.3; hyprctl setcursor "${HYPRCURSOR_THEME:-Bibata-Modern-Ice}" "${HYPRCURSOR_SIZE:-24}"' exec-once = qs --log-rules "qt.qpa.wayland.textinput.warning=false" -c overview # Quickshell Overview diff --git a/config/hypr/lua/startup.lua b/config/hypr/lua/startup.lua index 10369d6f..6ff9f8ad 100644 --- a/config/hypr/lua/startup.lua +++ b/config/hypr/lua/startup.lua @@ -42,7 +42,7 @@ end -- Prefer lifecycle-hook orchestration for clarity while keeping exec_once -- reliability semantics for real-world startup behavior. local startup_commands = { - scriptsDir .. "/WallpaperDaemon.sh", + "sleep 2; $HOME/.config/hypr/scripts/WallpaperDaemon.sh; $HOME/.config/hypr/scripts/ApplyThemeMode.sh; $HOME/.config/hypr/scripts/WaybarStartup.sh", "$HOME/.config/hypr/initial-boot.sh", "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP", "systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP", @@ -52,8 +52,6 @@ local startup_commands = { -- "nm-tray", "swaync", scriptsDir .. "/PortalHyprland.sh", - "sh $HOME/.config/hypr/scripts/ApplyThemeMode.sh", - "sh " .. scriptsDir .. "/WaybarStartup.sh", 'qs --log-rules "qt.qpa.wayland.textinput.warning=false" -c overview', 'qs --log-rules "qt.qpa.wayland.textinput.warning=false" -p $HOME/.config/quickshell/qs-hyprview', "hypridle", diff --git a/config/hypr/scripts/WallpaperDaemon.sh b/config/hypr/scripts/WallpaperDaemon.sh index aeb6c397..4725bc6b 100755 --- a/config/hypr/scripts/WallpaperDaemon.sh +++ b/config/hypr/scripts/WallpaperDaemon.sh @@ -38,6 +38,32 @@ get_monitors() { fi } +wait_for_monitors() { + local monitors="" + for _ in {1..120}; do + monitors="$(get_monitors 2>/dev/null | awk 'NF')" + if [ -n "$monitors" ]; then + printf '%s\n' "$monitors" + return 0 + fi + sleep 0.1 + done + return 1 +} + +default_wallpaper_path() { + local pictures_dir wall_dir + pictures_dir="$(xdg-user-dir PICTURES 2>/dev/null || echo "$HOME/Pictures")" + wall_dir="$pictures_dir/wallpapers" + + [ -d "$wall_dir" ] || return 1 + + find -L "$wall_dir" -type f \( \ + -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.bmp" -o \ + -iname "*.gif" -o -iname "*.webp" -o -iname "*.tiff" \ + \) -print | LC_ALL=C sort | awk 'NR == 1 {print; exit}' +} + apply_wallpaper_for_monitor() { local monitor="$1" local per_monitor_link="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/.current_wallpaper_${monitor}" @@ -91,6 +117,11 @@ apply_wallpaper_for_monitor() { fi fi + # Final fallback: use the first available wallpaper from the wallpapers directory. + if [ -z "$wallpaper_path" ]; then + wallpaper_path="$(default_wallpaper_path 2>/dev/null || true)" + fi + if [ -n "$wallpaper_path" ] && [ -f "$wallpaper_path" ]; then local resize_mode resize_mode="$(wallpaper_resize_mode "$wallpaper_path" "$monitor")" @@ -98,10 +129,25 @@ apply_wallpaper_for_monitor() { sleep 0.3 "$WWW_CMD" img -o "$monitor" --resize "$resize_mode" "$wallpaper_path" >/dev/null 2>&1 & fi + printf '%s\n' "$wallpaper_path" + return 0 fi + + return 1 } +applied_wallpaper="" while read -r monitor; do [ -n "$monitor" ] || continue - apply_wallpaper_for_monitor "$monitor" -done < <(get_monitors) + applied_path="$(apply_wallpaper_for_monitor "$monitor" || true)" + if [ -z "$applied_wallpaper" ] && [ -n "$applied_path" ] && [ -f "$applied_path" ]; then + applied_wallpaper="$applied_path" + fi +done < <(wait_for_monitors || true) + +"$SCRIPTSDIR/RofiFocusedWallpaperLink.sh" >/dev/null 2>&1 || true + +waybar_colors="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/wallust/colors-waybar.css" +if [ ! -s "$waybar_colors" ] && [ -n "$applied_wallpaper" ] && [ -x "$SCRIPTSDIR/WallustSwww.sh" ]; then + "$SCRIPTSDIR/WallustSwww.sh" "$applied_wallpaper" >/dev/null 2>&1 || true +fi diff --git a/config/hypr/scripts/WaybarStartup.sh b/config/hypr/scripts/WaybarStartup.sh index 5691c86b..575a7a2b 100755 --- a/config/hypr/scripts/WaybarStartup.sh +++ b/config/hypr/scripts/WaybarStartup.sh @@ -10,10 +10,32 @@ runtime_dir="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" export XDG_RUNTIME_DIR="$runtime_dir" +SCRIPTSDIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts" is_waybar_running() { pgrep -x "waybar" >/dev/null 2>&1 || pgrep -x '\.waybar-wrapped' >/dev/null 2>&1 } +wait_for_waybar() { + for _ in $(seq 1 30); do + is_waybar_running && return 0 + sleep 0.1 + done + return 1 +} +ensure_wallust_waybar_colors() { + local colors_file="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/wallust/colors-waybar.css" + [ -s "$colors_file" ] && return 0 + + if [ -x "$SCRIPTSDIR/WallustSwww.sh" ]; then + "$SCRIPTSDIR/WallustSwww.sh" >/dev/null 2>&1 || true + fi + + for _ in $(seq 1 40); do + [ -s "$colors_file" ] && return 0 + sleep 0.1 + done + return 1 +} sync_portal_env() { if command -v dbus-update-activation-environment >/dev/null 2>&1; then dbus-update-activation-environment --systemd \ @@ -68,12 +90,14 @@ wait_for_wayland() { start_waybar_direct() { if command -v waybar >/dev/null 2>&1; then waybar >/dev/null 2>&1 & - return 0 + wait_for_waybar + return $? fi if command -v .waybar-wrapped >/dev/null 2>&1; then .waybar-wrapped >/dev/null 2>&1 & - return 0 + wait_for_waybar + return $? fi return 1 @@ -87,8 +111,7 @@ start_waybar_via_systemd() { [ -n "$load_state" ] && [ "$load_state" != "not-found" ] || return 1 systemctl --user start waybar.service >/dev/null 2>&1 || return 1 - sleep 0.4 - is_waybar_running + wait_for_waybar } main() { @@ -97,18 +120,17 @@ main() { wait_for_wayland || true sync_portal_env start_portal_services || true + ensure_wallust_waybar_colors || true is_waybar_running && exit 0 - if start_waybar_via_systemd; then + if start_waybar_via_systemd || start_waybar_direct; then exit 0 fi - - if is_waybar_running; then - exit 0 - fi - - start_waybar_direct || exit 1 + # One retry after attempting to refresh wallust templates. + ensure_wallust_waybar_colors || true + sleep 0.3 + start_waybar_via_systemd || start_waybar_direct || exit 1 } main diff --git a/config/rofi/.current_wallpaper b/config/rofi/.current_wallpaper index 4f0d70ab..e09dc461 120000 --- a/config/rofi/.current_wallpaper +++ b/config/rofi/.current_wallpaper @@ -1 +1 @@ -/home/ja/Pictures/wallpapers/Northern Lights3.png \ No newline at end of file +../hypr/wallpaper_effects/.wallpaper_current \ No newline at end of file diff --git a/copy.sh b/copy.sh index 0ed8e8ac..a77d2f23 100755 --- a/copy.sh +++ b/copy.sh @@ -225,6 +225,20 @@ if ! declare -f restore_runtime_personal_state >/dev/null 2>&1; then echo "${OK} Restored runtime wallpaper state after copy." 2>&1 | tee -a "$log" rm -f "$state_file" 2>/dev/null || true fi + + if [ -L "$rofi_link" ]; then + local resolved_link="" + resolved_link="$(readlink -f "$rofi_link" 2>/dev/null || true)" + if [ -z "$resolved_link" ] || [ ! -f "$resolved_link" ]; then + if [ -f "$wallpaper_current" ]; then + ln -snf "$wallpaper_current" "$rofi_link" 2>/dev/null || true + echo "${NOTE} Repaired broken rofi wallpaper link to wallpaper_current fallback." 2>&1 | tee -a "$log" + fi + fi + elif [ ! -e "$rofi_link" ] && [ -f "$wallpaper_current" ]; then + ln -snf "$wallpaper_current" "$rofi_link" 2>/dev/null || true + echo "${NOTE} Initialized rofi wallpaper link from wallpaper_current fallback." 2>&1 | tee -a "$log" + fi } fi @@ -270,8 +284,17 @@ is_kooldots_config() { is_oem_lua_config() { local cfg_home + local hypr_dir cfg_home="$(config_home)" - [ -f "$cfg_home/hyprland.lua" ] || [ -f "$cfg_home/hypr/hyprland.lua" ] + hypr_dir="$cfg_home/hypr" + + # Explicit Hyprlang workflow marker: + # if hyprland.lua.disable exists and hyprland.lua does not, treat host as conf mode. + if [ -f "$hypr_dir/hyprland.lua.disable" ] && [ ! -f "$hypr_dir/hyprland.lua" ]; then + return 1 + fi + + [ -f "$cfg_home/hyprland.lua" ] || [ -f "$hypr_dir/hyprland.lua" ] } require_kooldots_for_upgrade() { diff --git a/scripts/lib_copy.sh b/scripts/lib_copy.sh index d496f2d7..0c065ca9 100644 --- a/scripts/lib_copy.sh +++ b/scripts/lib_copy.sh @@ -184,30 +184,35 @@ restore_hypr_assets() { local base="${DOTFILES_DIR:-.}" local HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" - local CONFIG_HOME="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}" local BACKUP_DIR BACKUP_DIR=$(get_backup_dirname) local BACKUP_HYPR_PATH="$HYPR_DIR-backup-$BACKUP_DIR" if [ -d "$BACKUP_HYPR_PATH" ]; then local backup_mode="conf" - if [ -f "$BACKUP_HYPR_PATH/hyprland.lua" ] || [ -f "$CONFIG_HOME/hyprland.lua" ]; then + local backup_lua_entry="$BACKUP_HYPR_PATH/hyprland.lua" + local backup_lua_disabled="$BACKUP_HYPR_PATH/hyprland.lua.disable" + if [ -f "$backup_lua_entry" ]; then backup_mode="lua" + elif [ -f "$backup_lua_disabled" ]; then + # Explicit conf marker used by migrate-hypr-to-lua.sh while Lua is disabled. + backup_mode="conf" fi - # Preserve Lua entrypoint after upgrade, preferring the current template - # shipped in the repo to avoid restoring stale/broken entrypoints. + # Preserve Lua entrypoint only when the backup was already using Lua mode. + # Do not auto-enable Lua on conf-based hosts. local LUA_ENTRY_TEMPLATE="$base/config/hypr/hyprland.lua" - local LUA_ENTRY_TEMPLATE_DISABLED="$base/config/hypr/hyprland.lua.disable" - if [ -f "$LUA_ENTRY_TEMPLATE" ]; then - cp -f "$LUA_ENTRY_TEMPLATE" "$HYPR_DIR/hyprland.lua" 2>&1 | tee -a "$log" - echo "${OK:-[OK]} - Restored file: ${MAGENTA:-}hyprland.lua${RESET:-} (from repo template)" 2>&1 | tee -a "$log" - elif [ -f "$LUA_ENTRY_TEMPLATE_DISABLED" ]; then - cp -f "$LUA_ENTRY_TEMPLATE_DISABLED" "$HYPR_DIR/hyprland.lua" 2>&1 | tee -a "$log" - echo "${OK:-[OK]} - Restored file: ${MAGENTA:-}hyprland.lua${RESET:-} (from repo .disable template)" 2>&1 | tee -a "$log" - elif [ -f "$BACKUP_HYPR_PATH/hyprland.lua" ]; then - cp -f "$BACKUP_HYPR_PATH/hyprland.lua" "$HYPR_DIR/hyprland.lua" 2>&1 | tee -a "$log" - echo "${OK:-[OK]} - Restored file: ${MAGENTA:-}hyprland.lua${RESET:-} (from backup)" 2>&1 | tee -a "$log" + if [ "$backup_mode" = "lua" ]; then + if [ -f "$LUA_ENTRY_TEMPLATE" ]; then + cp -f "$LUA_ENTRY_TEMPLATE" "$HYPR_DIR/hyprland.lua" 2>&1 | tee -a "$log" + echo "${OK:-[OK]} - Restored file: ${MAGENTA:-}hyprland.lua${RESET:-} (lua mode preserved from repo template)" 2>&1 | tee -a "$log" + elif [ -f "$BACKUP_HYPR_PATH/hyprland.lua" ]; then + cp -f "$BACKUP_HYPR_PATH/hyprland.lua" "$HYPR_DIR/hyprland.lua" 2>&1 | tee -a "$log" + echo "${OK:-[OK]} - Restored file: ${MAGENTA:-}hyprland.lua${RESET:-} (lua mode preserved from backup)" 2>&1 | tee -a "$log" + fi + else + rm -f "$HYPR_DIR/hyprland.lua" 2>/dev/null || true + echo "${NOTE:-[NOTE]} - Conf mode detected; skipping Lua entrypoint restore." 2>&1 | tee -a "$log" fi if [ "$express_mode" -eq 1 ]; then -- cgit v1.2.3