diff --git a/modules/user/lucid/default.nix b/modules/user/lucid/default.nix index 99073be..031fb5f 100644 --- a/modules/user/lucid/default.nix +++ b/modules/user/lucid/default.nix @@ -9,31 +9,6 @@ let binds = builtins.filter (entry: builtins.elem entry.id specialBindIds) (builtins.fromJSON (builtins.readFile ./lucid-keybinds-rias.json)).binds; }); - vaultwardenBindSeed = pkgs.writeText "lucid-vaultwarden-binding.json" (builtins.toJSON { - binds = [ { - id = "vaultwarden-password"; - keys = "SUPER + X"; - desc = "Type a password from Vaultwarden"; - category = "Apps"; - type = "exec"; - cmd = "qs ipc call -- launcher search '>pass '"; - } ]; - }); - mergeVaultwardenBind = pkgs.writeText "lucid-merge-vaultwarden-bind.jq" '' - def normkeys: (. // "") | ascii_upcase | gsub("\\s+"; "") | split("+") - | map(if . == "WIN" or . == "LOGO" or . == "MOD4" then "SUPER" - elif . == "CONTROL" then "CTRL" else . end) | sort | join("+"); - if (.binds | type) != "array" then error("keybinds.json has no binds array") else . end - | . as $old - | ($seed[0].binds[0]) as $seed_bind - | ($old.binds | map(select(.id == $seed_bind.id)) | first) as $existing - | ($old.binds | map(select(.id != $seed_bind.id))) as $others - | ($others | any(.enabled != false and ((.keys | normkeys) == ($seed_bind.keys | normkeys)))) as $conflict - | .binds = $others + [ - $seed_bind + (if $existing.enabled == false or ($existing == null and $conflict) - then {enabled: false} else {} end) - ] - ''; chestBindingsScript = pkgs.writeText "lucid-chest-bindings.py" '' import hashlib import json @@ -83,43 +58,6 @@ json.dump({"version": 1, "binds": result + specials}, open(output, "w"), indent= python3 ${chestBindingsScript} ${lib.escapeShellArg (builtins.toJSON config.lucidHyprlandBinds)} \ ${./lucid-keybinds-rias.json} ${specialSeed} "$out" ''; - mergeChestBinds = pkgs.writeText "lucid-merge-chest-bindings.jq" '' -def normlua: (. // "") | gsub("\\s+"; "") | gsub("\u0027"; "\""); -def normkeys: (. // "") | ascii_upcase | gsub("\\s+"; "") | split("+") - | map(if . == "WIN" or . == "LOGO" or . == "MOD4" then "SUPER" - elif . == "CONTROL" then "CTRL" else . end) | sort | join("+"); -def combos: - if .each == "workspace" then .keys as $k | [range(1;11) as $i | ($k | gsub("\\{key\\}"; (($i % 10) | tostring)) | normkeys)] - else [(.keys | normkeys)] end; -def trigger: {click: (.opts.click // false), long_press: (.opts.long_press // false), release: (.opts.release // false), mouse: (.opts.mouse // false)}; -if (.binds | type) != "array" then error("keybinds.json has no binds array") else . end -| . as $old -| .binds += [$seed[0].binds[] as $b - | select([$old.binds[] | select( - .id == $b.id - or ((["scratchpad", "scratchpad-stash", "special-music", "special-comms", "special-todo", "special-sysmon", "daemons-workspace"] | index($b.id)) != null and .type == "lua" and $b.type == "lua" and ((.lua | normlua) == ($b.lua | normlua))) - or ((trigger == ($b | trigger)) and ((combos - ($b | combos) | length) < (combos | length))) - )] | length == 0) | $b] - ''; - mergeSpecialBinds = pkgs.writeText "lucid-merge-special-binds.jq" '' - def normlua: (. // "") | gsub("\\s+"; "") | gsub("\u0027"; "\""); - def normkeys: (. // "") | ascii_upcase | gsub("\\s+"; "") | split("+") - | map(if . == "WIN" or . == "LOGO" or . == "MOD4" then "SUPER" - elif . == "CONTROL" then "CTRL" else . end) | sort | join("+"); - if (.binds | type) != "array" then error("keybinds.json has no binds array") else . end - | . as $old - | .binds += [ $seed[0].binds[] as $b - | select([$old.binds[] | select(.id == $b.id or (.type == "lua" and ((.lua | normlua) == ($b.lua | normlua))))] | length == 0) - | if ([$old.binds[] | select(.enabled != false and ((.keys | normkeys) == ($b.keys | normkeys)))] | length) > 0 - then $b + { enabled: false } else $b end ] - ''; - mergeSpecialPrefs = pkgs.writeText "lucid-merge-special-prefs.jq" '' - .specialCustom = ((.specialCustom // "[]" | fromjson) - | if type != "array" then error("specialCustom is not an array") else . end - | if any(.[]; .key == "daemons") then . - else . + [{key: "daemons", label: "Daemons", glyph: "build", on: true, apps: ""}] end - | tojson) - ''; staticBindKeys = map (entry: builtins.elemAt entry._args 0) config.wayland.windowManager.hyprland.settings.bind; nonRiasBinds = pkgs.runCommand "lucid-nix-binds.lua" { nativeBuildInputs = [ pkgs.python3 ]; } '' python3 - ${source}/support/hypr/modules/binds.lua "$out" ${lib.escapeShellArg (builtins.toJSON staticBindKeys)} <<'PY' @@ -420,7 +358,29 @@ dock_path.write_text(dock) wallpaperScript = "${config.home.homeDirectory}/.config/hypr/scripts/wallpaper/set-wallpaper.sh"; widgetLayout = if osConfig.networking.hostName == "Rias" then ./lucid-widgets-rias.json - else ./lucid-widgets.json; + else if isChest && host == "Impreza" then ./lucid-widgets-impreza.json + else null; + bindSeed = if config.home.username == "sweetbread" then ./lucid-keybinds-rias.json + else chestSeed; + specialCustomValue = builtins.toJSON [ { + key = "daemons"; + label = "Daemons"; + glyph = "build"; + on = true; + apps = ""; + } ]; + genericPrefsSeed = pkgs.writeText "lucid-default-prefs.json" (builtins.toJSON ( + (builtins.fromJSON (builtins.readFile ./lucid-prefs.json)) // { + specialCustom = if isRias then "[]" else specialCustomValue; + } + )); + chestPrefsSeed = pkgs.runCommand "lucid-chest-prefs.json" { nativeBuildInputs = [ pkgs.jq ]; } '' + ${pkgs.jq}/bin/jq --arg specialCustom ${lib.escapeShellArg specialCustomValue} \ + '.specialCustom = $specialCustom' ${source}/defaults/prefs.json > "$out" + ''; + prefsSeed = if config.home.username == "sweetbread" then genericPrefsSeed + else if isChest && host == "Impreza" then ./lucid-prefs-impreza.json + else chestPrefsSeed; defaultWallpaper = "${wallpaperDir}/bluehour.jpg"; hyprLua = import ../hyprland/lua.nix { inherit lib; }; colors = config.lib.stylix.colors.withHashtag; @@ -760,71 +720,8 @@ in { lucid_dir="${config.home.homeDirectory}/.config/lucid" $DRY_RUN_CMD mkdir -p "$lucid_dir/themes" - if [ "${host}" = Rias ] && [ -z "''${DRY_RUN_CMD:-}" ]; then - if [ ! -s "$lucid_dir/keybinds.json" ]; then - install -m644 ${./lucid-keybinds-rias.json} "$lucid_dir/keybinds.json" - fi - binds_tmp=$(${pkgs.coreutils}/bin/mktemp "$lucid_dir/keybinds.json.XXXXXX") - if ${pkgs.jq}/bin/jq --slurpfile seed ${vaultwardenBindSeed} -f ${mergeVaultwardenBind} \ - "$lucid_dir/keybinds.json" > "$binds_tmp"; then - chmod 644 "$binds_tmp" - mv "$binds_tmp" "$lucid_dir/keybinds.json" - else - rm -f "$binds_tmp" - echo "Could not merge the Vaultwarden Lucid binding" >&2 - exit 1 - fi - fi - ${lib.optionalString (!isRias) '' - special_migration="$lucid_dir/special-workspaces-v1" - if [ -z "''${DRY_RUN_CMD:-}" ] && [ ! -e "$special_migration" ]; then - if [ -f "${config.home.homeDirectory}/.config/hypr/lucid-specials.lua" ] && \ - [ ! -e "${config.home.homeDirectory}/.config/hypr/lucid-specials.before-special-workspaces-v1.lua" ]; then - cp -p "${config.home.homeDirectory}/.config/hypr/lucid-specials.lua" \ - "${config.home.homeDirectory}/.config/hypr/lucid-specials.before-special-workspaces-v1.lua" - fi - if [ ! -s "$lucid_dir/keybinds.json" ]; then - install -m644 ${specialSeed} "$lucid_dir/keybinds.json" - else - binds_tmp=$(${pkgs.coreutils}/bin/mktemp "$lucid_dir/keybinds.json.XXXXXX") - if ${pkgs.jq}/bin/jq --slurpfile seed ${specialSeed} -f ${mergeSpecialBinds} \ - "$lucid_dir/keybinds.json" > "$binds_tmp"; then - chmod 644 "$binds_tmp" - mv "$binds_tmp" "$lucid_dir/keybinds.json" - else - rm -f "$binds_tmp" - echo "Could not merge Lucid special workspace bindings" >&2 - exit 1 - fi - fi - fi - ''} - ${lib.optionalString isChest '' - chest_migration="$lucid_dir/chest-keybinds-v1" - if [ -z "''${DRY_RUN_CMD:-}" ] && [ ! -e "$chest_migration" ]; then - if [ ! -s "$lucid_dir/keybinds.json" ]; then - install -m644 ${chestSeed} "$lucid_dir/keybinds.json" - else - if [ ! -e "$lucid_dir/keybinds.before-chest-migration.json" ]; then - cp -p "$lucid_dir/keybinds.json" "$lucid_dir/keybinds.before-chest-migration.json" - fi - binds_tmp=$(${pkgs.coreutils}/bin/mktemp "$lucid_dir/keybinds.json.XXXXXX") - if ${pkgs.jq}/bin/jq --slurpfile seed ${chestSeed} -f ${mergeChestBinds} "$lucid_dir/keybinds.json" > "$binds_tmp"; then - chmod 644 "$binds_tmp" - mv "$binds_tmp" "$lucid_dir/keybinds.json" - else - rm -f "$binds_tmp" - echo "Could not migrate chest keybindings to Lucid" >&2 - exit 1 - fi - fi - touch "$chest_migration" - fi - ''} - monitor_file="${config.home.homeDirectory}/.config/hypr/lucid-monitors.lua" - if [ "${host}" = Rias ] && { [ ! -s "$monitor_file" ] || ! grep -qE 'output[[:space:]]*=' "$monitor_file"; } && \ - ! grep -qE 'workspace[[:space:]]*=' "$monitor_file" 2>/dev/null; then - $DRY_RUN_CMD install -m644 ${./lucid-monitors-rias.lua} "$monitor_file" + if [ ! -s "$lucid_dir/keybinds.json" ]; then + $DRY_RUN_CMD install -m644 ${bindSeed} "$lucid_dir/keybinds.json" fi $DRY_RUN_CMD ${pkgs.rsync}/bin/rsync -rltp --chmod=Du+rwx,Fu+rw --ignore-existing \ "${source}/support/lucid/themes/" "$lucid_dir/themes/" @@ -840,7 +737,7 @@ in { "$lucid_dir/apply-theme.sh" if [ ! -e "$target/lucidprefs/prefs.json" ]; then - $DRY_RUN_CMD install -m644 ${if isChest then "${source}/defaults/prefs.json" else ./lucid-prefs.json} "$target/lucidprefs/prefs.json" + $DRY_RUN_CMD install -m644 ${prefsSeed} "$target/lucidprefs/prefs.json" fi if [ -z "''${DRY_RUN_CMD:-}" ] && [ -f "$target/lucidprefs/prefs.json" ]; then prefs_tmp=$(${pkgs.coreutils}/bin/mktemp "$target/lucidprefs/prefs.json.XXXXXX") @@ -856,26 +753,21 @@ in { exit 1 fi fi - ${lib.optionalString (!isRias) '' - if [ -z "''${DRY_RUN_CMD:-}" ] && [ ! -e "$special_migration" ]; then - prefs_tmp=$(${pkgs.coreutils}/bin/mktemp "$target/lucidprefs/prefs.json.XXXXXX") - if ${pkgs.jq}/bin/jq -f ${mergeSpecialPrefs} "$target/lucidprefs/prefs.json" > "$prefs_tmp"; then - chmod 644 "$prefs_tmp" - mv "$prefs_tmp" "$target/lucidprefs/prefs.json" - touch "$special_migration" - else - rm -f "$prefs_tmp" - echo "Could not merge Lucid special workspace settings" >&2 - exit 1 - fi - fi - ''} - if [ ! -e "$target/luciddocks/pinned.json" ]; then - $DRY_RUN_CMD install -m644 ${./lucid-pinned.json} "$target/luciddocks/pinned.json" - fi + ${lib.optionalString (widgetLayout != null) '' if [ ! -e "$target/lucidwidgets/widgets.json" ]; then $DRY_RUN_CMD install -m644 ${widgetLayout} "$target/lucidwidgets/widgets.json" fi + ''} + ${lib.optionalString (isChest && host == "Impreza") '' + if [ ! -e "${config.home.homeDirectory}/.config/hypr/lucid-settings.lua" ]; then + $DRY_RUN_CMD install -m644 ${./lucid-settings-impreza.lua} \ + "${config.home.homeDirectory}/.config/hypr/lucid-settings.lua" + fi + if [ ! -e "${config.home.homeDirectory}/.config/hypr/lucid-glass.lua" ]; then + $DRY_RUN_CMD install -m644 ${./lucid-glass-impreza.lua} \ + "${config.home.homeDirectory}/.config/hypr/lucid-glass.lua" + fi + ''} for pair in \ 'blur.json lucidbar/blur.json' \ @@ -892,47 +784,6 @@ in { fi done - ${lib.optionalString (isChest && host == "Impreza") '' - # Import Eclipse's appearance once. Keep later Lucid edits and back up - # existing laptop settings before changing them; monitor state is untouched. - appearance_marker="$lucid_dir/impreza-appearance-v1" - if [ -z "''${DRY_RUN_CMD:-}" ] && [ ! -e "$appearance_marker" ]; then - mkdir -p "${config.home.homeDirectory}/.cache" "${config.home.homeDirectory}/.config/hypr" - prefs="$target/lucidprefs/prefs.json" - prefs_tmp=$(${pkgs.coreutils}/bin/mktemp "$prefs.XXXXXX") - if ${pkgs.jq}/bin/jq --slurpfile appearance ${./lucid-prefs-impreza.json} \ - '. + $appearance[0]' "$prefs" > "$prefs_tmp"; then - cp --backup=numbered "$prefs" "$prefs.before-impreza-appearance" - chmod 644 "$prefs_tmp" - mv "$prefs_tmp" "$prefs" - else - rm -f "$prefs_tmp" - exit 1 - fi - for pair in \ - '${./lucid-widgets-impreza.json} lucidwidgets/widgets.json' \ - '${./lucid-pinned-impreza.json} luciddocks/pinned.json'; do - set -- $pair - [ ! -e "$target/$2" ] || cp --backup=numbered "$target/$2" "$target/$2.before-impreza-appearance" - install -m644 "$1" "$target/$2" - done - for pair in \ - '${./lucid-settings-impreza.lua} lucid-settings.lua' \ - '${./lucid-glass-impreza.lua} lucid-glass.lua'; do - set -- $pair - file="${config.home.homeDirectory}/.config/hypr/$2" - [ ! -e "$file" ] || cp --backup=numbered "$file" "$file.before-impreza-appearance" - install -m644 "$1" "$file" - done - if [ -e "${config.home.homeDirectory}/.cache/current_theme" ]; then - cp --backup=numbered "${config.home.homeDirectory}/.cache/current_theme" \ - "${config.home.homeDirectory}/.cache/current_theme.before-impreza-appearance" - fi - install -m644 ${themeName} "${config.home.homeDirectory}/.cache/current_theme" - touch "$appearance_marker" - fi - ''} - $DRY_RUN_CMD mkdir -p "${config.home.homeDirectory}/.config/lucid/themes/stylix" \ "${config.home.homeDirectory}/.cache/quickshell" $DRY_RUN_CMD install -m644 ${paletteFile} \ @@ -1034,21 +885,8 @@ in { package.path = config_home .. "/hypr/?.lua;" .. config_home .. "/hypr/?/init.lua;" .. package.path require("modules.specials") LucidSpecials.apply() - '' + lib.optionalString (isRias || isChest) '' + '' + lib.optionalString isChest '' require("modules.monitors") - '' + lib.optionalString isRias '' - local lucid_monitor_apply = LucidMonitors.apply - LucidMonitors.apply = function(...) - lucid_monitor_apply(...) - hl.monitor({ output = "desc:Huawei Technologies Co. Inc. ZQE-CAA 0xC080F622", cm = "srgb", supports_hdr = -1 }) - end - LucidMonitors.apply() - -- Lucid previously left numbered workspaces persistent on this host. - -- Retire those stale rules after applying the monitor layout so they do - -- not return on the next Hyprland reload. - for workspace = 1, 10 do - hl.workspace_rule({ workspace = tostring(workspace), persistent = false }) - end '' + lib.optionalString (isRias || isChest) '' require("modules.settings") require("modules.glass") diff --git a/modules/user/lucid/lucid-keybinds-rias.json b/modules/user/lucid/lucid-keybinds-rias.json index 12fa358..01c108a 100644 --- a/modules/user/lucid/lucid-keybinds-rias.json +++ b/modules/user/lucid/lucid-keybinds-rias.json @@ -15,6 +15,7 @@ { "id": "zoom-out-kp-subtract", "keys": "SUPER + KP_SUBTRACT", "desc": "Zoom out", "category": "Accessibility", "type": "lua", "lua": "function() local current = hl.get_config('cursor.zoom_factor'); hl.config({ cursor = { zoom_factor = math.max(1, current * 0.9) } }) end", "opts": { "repeating": true } }, { "id": "widgets-panel", "keys": "SUPER + SHIFT + G", "desc": "Toggle widgets panel", "category": "Lucid", "type": "exec", "cmd": "qs ipc call widgets panel" }, { "id": "launcher", "keys": "SUPER + D", "desc": "App launcher", "category": "Lucid", "type": "exec", "cmd": "hyprctl eval 'hl.config({ input = { follow_mouse = 2 } })' && qs ipc call launcher toggle" }, + { "id": "vaultwarden-password", "keys": "SUPER + X", "desc": "Type a password from Vaultwarden", "category": "Apps", "type": "exec", "cmd": "qs ipc call -- launcher search '>pass '" }, { "id": "clipse", "keys": "SUPER + V", "desc": "Clipboard manager", "category": "Apps", "type": "exec", "cmd": "ghostty --title=clipse -e clipse" }, { "id": "clipboard", "keys": "SUPER + SHIFT + V", "desc": "Clipboard history", "category": "Lucid", "type": "exec", "cmd": "hyprctl eval 'hl.config({ input = { follow_mouse = 2 } })' && qs ipc call launcher clipboard" }, { "id": "screenshot", "keys": "Print", "desc": "Full screenshot", "category": "Screenshots", "type": "exec", "cmd": "qs ipc call screenshot full" }, diff --git a/modules/user/lucid/lucid-monitors-rias.lua b/modules/user/lucid/lucid-monitors-rias.lua deleted file mode 100644 index a090c4d..0000000 --- a/modules/user/lucid/lucid-monitors-rias.lua +++ /dev/null @@ -1,9 +0,0 @@ --- Initial Rias display layout; Home Manager seeds this only while the --- user-owned Lucid monitor list is empty. -return { - monitors = { - { output = "desc:Huawei Technologies Co. Inc. ZQE-CAA 0xC080F622", mode = "3440x1440@120.00", position = "1920x0", scale = "1" }, - { output = "desc:Samsung Electric Company SAMSUNG 0x01000E00", mode = "1920x1080@60.00", position = "0x0", scale = "1" }, - }, - workspaces = {}, -} diff --git a/modules/user/lucid/lucid-pinned-impreza.json b/modules/user/lucid/lucid-pinned-impreza.json deleted file mode 100644 index 163100b..0000000 --- a/modules/user/lucid/lucid-pinned-impreza.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pinnedApps": [] -} diff --git a/modules/user/lucid/lucid-pinned.json b/modules/user/lucid/lucid-pinned.json deleted file mode 100644 index 163100b..0000000 --- a/modules/user/lucid/lucid-pinned.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pinnedApps": [] -} diff --git a/modules/user/lucid/lucid-widgets.json b/modules/user/lucid/lucid-widgets.json deleted file mode 100644 index 70d2290..0000000 --- a/modules/user/lucid/lucid-widgets.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "nextId": 3, - "boardFull": true, - "instances": [ - { - "uid": "w1", - "type": "clock", - "variant": "digital", - "wx": 40, - "wy": 70 - }, - { - "uid": "w2", - "type": "system", - "variant": "rings", - "wx": 40, - "wy": 250 - } - ] -}