diff --git a/scripts/fillThemes.js b/scripts/fillThemes.js index f95876b..cabb21e 100644 --- a/scripts/fillThemes.js +++ b/scripts/fillThemes.js @@ -179,6 +179,7 @@ const collectBorderColors = (baseJSON) => { const determineBestMatchValue = (baseValue, valueToKeysMap, targetJSON, specialKeyMappings, currentKey, baseTheme) => { if (specialKeyMappings.hasOwnProperty(currentKey)) { const sourceKey = specialKeyMappings[currentKey]; + if (targetJSON.hasOwnProperty(sourceKey)) { console.log(formatMessage(COLORS.FG_CYAN, `šŸ” Found source key '${sourceKey}' in target JSON.`)); return targetJSON[sourceKey]; @@ -309,24 +310,24 @@ const processTheme = async (themePath, baseTheme, dryRun, specialKeyMappings = { } } - const extraKeys = findExtraKeys(baseTheme, themeJSON); - - if (extraKeys.length === 0) { - console.log(formatMessage(COLORS.FG_GREEN, `āœ… No extra keys to remove in '${path.basename(themePath)}'.`)); - } else { - console.log( - formatMessage( - COLORS.FG_YELLOW, - `\nšŸ—‘ļø Processing '${path.basename(themePath)}': Found ${extraKeys.length} extra key(s) to remove.`, - ), - ); - - for (const key of extraKeys) { - delete themeJSON[key]; - console.log(formatMessage(COLORS.FG_RED, `āž– Removed key: "${key}"`)); - hasChanges = true; - } - } + // const extraKeys = findExtraKeys(baseTheme, themeJSON); + // + // if (extraKeys.length === 0) { + // console.log(formatMessage(COLORS.FG_GREEN, `āœ… No extra keys to remove in '${path.basename(themePath)}'.`)); + // } else { + // console.log( + // formatMessage( + // COLORS.FG_YELLOW, + // `\nšŸ—‘ļø Processing '${path.basename(themePath)}': Found ${extraKeys.length} extra key(s) to remove.`, + // ), + // ); + // + // for (const key of extraKeys) { + // delete themeJSON[key]; + // console.log(formatMessage(COLORS.FG_RED, `āž– Removed key: "${key}"`)); + // hasChanges = true; + // } + // } if (hasChanges) { if (dryRun) { @@ -402,11 +403,11 @@ const main = async () => { const themeFiles = (await fs.readdir(themesDir)).filter((file) => file.endsWith('.json')); const specialKeyMappings = { - 'theme.bar.buttons.modules.cava.text': 'theme.bar.buttons.modules.submap.text', - 'theme.bar.buttons.modules.cava.background': 'theme.bar.buttons.modules.submap.background', - 'theme.bar.buttons.modules.cava.icon_background': 'theme.bar.buttons.modules.submap.icon_background', - 'theme.bar.buttons.modules.cava.icon': 'theme.bar.buttons.modules.submap.icon', - 'theme.bar.buttons.modules.cava.border': 'theme.bar.buttons.modules.submap.border', + 'theme.bar.buttons.modules.worldclock.text': 'theme.bar.buttons.clock.text', + 'theme.bar.buttons.modules.worldclock.background': 'theme.bar.buttons.clock.background', + 'theme.bar.buttons.modules.worldclock.icon_background': 'theme.bar.buttons.clock.icon_background', + 'theme.bar.buttons.modules.worldclock.icon': 'theme.bar.buttons.clock.icon', + 'theme.bar.buttons.modules.worldclock.border': 'theme.bar.buttons.clock.border', }; const queue = [...themeFiles].filter( diff --git a/scripts/fillThemes.sh b/scripts/fillThemes.sh deleted file mode 100755 index 8684653..0000000 --- a/scripts/fillThemes.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -# Generated by our good friend Chat Jippity -# Might be inefficient but it works - -# Define directories and theme files -THEMES_DIR="$(dirname "$(realpath "$0")")/../themes" -COMPLETE_THEME_FILE="catppuccin_mocha.json" -COMPLETE_SPLIT_THEME_FILE="catppuccin_mocha_split.json" - -# Check if jq is installed -if ! command -v jq &>/dev/null; then - echo "jq is required but not installed. Please install jq and try again." - exit 1 -fi - -# Function to fill missing values -fill_missing_values() { - local complete_theme_file="$1" - local target_theme_file="$2" - - # Load complete theme and target theme into variables - complete_theme=$(jq '.' "$complete_theme_file") - target_theme=$(jq '.' "$target_theme_file") - - # Create associative arrays to map colors to properties for fast lookup - declare -A color_to_props - declare -A prop_to_color - - # Populate color_to_props and prop_to_color arrays from complete theme - while IFS= read -r line; do - key=$(echo "$line" | awk '{print $1}') - value=$(echo "$line" | awk '{print $2}') - color_to_props["$value"]+="$key " - prop_to_color["$key"]="$value" - done < <(echo "$complete_theme" | jq -r 'to_entries[] | "\(.key) \(.value)"') - - # Generate filled theme by iterating over complete theme keys - filled_theme="$target_theme" - for key in "${!prop_to_color[@]}"; do - if ! echo "$target_theme" | jq -e ".\"$key\"" &>/dev/null; then - # Find corresponding color if missing in target theme - value="${prop_to_color[$key]}" - corresponding_color="" - - # Check if other properties with the same color exist in the target theme - for prop in ${color_to_props["$value"]}; do - if echo "$target_theme" | jq -e ".\"$prop\"" &>/dev/null; then - corresponding_color=$(echo "$target_theme" | jq -r ".\"$prop\"") - break - fi - done - - # Add missing property with the corresponding color - if [ -n "$corresponding_color" ]; then - filled_theme=$(echo "$filled_theme" | jq --arg key "$key" --arg value "$corresponding_color" '.[$key] = $value') - echo "Added missing property: $key with value: $corresponding_color to $target_theme_file" - else - # Default action if no corresponding color is found - echo "No corresponding color found for $key; using value from complete theme." - filled_theme=$(echo "$filled_theme" | jq --arg key "$key" --arg value "$value" '.[$key] = $value') - fi - fi - done - - # Write the filled theme back to the target file - echo "$filled_theme" >"$target_theme_file" - echo "Filled missing values in $target_theme_file" -} - -# Process all theme files in the directory -for file in "$THEMES_DIR"/*.json; do - filename=$(basename "$file") - - # Skip the complete theme files - if [[ "$filename" == "$COMPLETE_THEME_FILE" ]] || [[ "$filename" == "$COMPLETE_SPLIT_THEME_FILE" ]]; then - continue - fi - - # Determine whether to use split or non-split complete theme - if [[ "$filename" == *"_split"* ]]; then - fill_missing_values "$THEMES_DIR/$COMPLETE_SPLIT_THEME_FILE" "$file" - else - fill_missing_values "$THEMES_DIR/$COMPLETE_THEME_FILE" "$file" - fi -done diff --git a/src/components/bar/modules/worldclock/index.tsx b/src/components/bar/modules/worldclock/index.tsx index 892ff9d..953449d 100644 --- a/src/components/bar/modules/worldclock/index.tsx +++ b/src/components/bar/modules/worldclock/index.tsx @@ -1,120 +1,82 @@ -import { openMenu } from '../../utils/menu'; import options from 'src/options'; import { BarBoxChild } from 'src/lib/types/bar.js'; -import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js'; +import { inputHandler } from 'src/components/bar/utils/helpers.js'; import { bind, Variable } from 'astal'; -import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers'; import { Astal } from 'astal/gtk3'; import { systemTime } from 'src/globals/time'; import { GLib } from 'astal'; +import { Module } from '../../shared/Module'; -const { format, formatDiffDate, tz, icon, showIcon, showTime, rightClick, middleClick, scrollUp, scrollDown } = - options.bar.customModules.worldclock; -const { style } = options.theme.bar.buttons; +const { + format, + formatDiffDate, + divider, + tz, + icon, + showIcon, + leftClick, + rightClick, + middleClick, + scrollUp, + scrollDown, +} = options.bar.customModules.worldclock; -const time = Variable.derive( - [systemTime, format, formatDiffDate, tz], - (c, f, fdd, tzn) => - tzn - .map((t) => - c - .to_timezone(GLib.TimeZone.new(t)) - .format(c.to_timezone(GLib.TimeZone.new(t)).get_day_of_year() == c.get_day_of_year() ? f : fdd), - ) - .join(' | ') || '', -); - -const WorldClock = (): BarBoxChild => { - const ClockTime = (): JSX.Element =>