summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-30 06:54:29 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-30 06:54:29 +0900
commite129395dada177f359d41cf80967f59a1b1f0f3c (patch)
treebf9a0068f3473af4c3194d476aaf37828a1bdf93
parentaab3930921c90f21e9e50b9b59cd0c9be011a552 (diff)
modified items/battery.sh, modified items/calendar.sh, modified plugins/calendar.sh
-rwxr-xr-xmac/.config/sketchybar/items/battery.sh2
-rwxr-xr-xmac/.config/sketchybar/items/calendar.sh6
-rwxr-xr-xmac/.config/sketchybar/plugins/calendar.sh85
3 files changed, 47 insertions, 46 deletions
diff --git a/mac/.config/sketchybar/items/battery.sh b/mac/.config/sketchybar/items/battery.sh
index 7955060..d3adcf8 100755
--- a/mac/.config/sketchybar/items/battery.sh
+++ b/mac/.config/sketchybar/items/battery.sh
@@ -9,8 +9,8 @@ battery=(
update_freq=120
updates=on
)
+
sketchybar --add item battery right \
--set battery "${battery[@]}"\
icon.font.size=15 update_freq=120 script="$PLUGIN_DIR/battery.sh" \
--subscribe battery power_source_change system_woke
-
diff --git a/mac/.config/sketchybar/items/calendar.sh b/mac/.config/sketchybar/items/calendar.sh
index 62aadc8..5fa2825 100755
--- a/mac/.config/sketchybar/items/calendar.sh
+++ b/mac/.config/sketchybar/items/calendar.sh
@@ -11,6 +11,6 @@ calendar=(
click_script="$PLUGIN_DIR/zen.sh"
)
-sketchybar --add item calendar right \
- --set calendar "${calendar[@]}" \
- --subscribe calendar system_woke
+sketchybar --add item calendar right \
+ --set calendar "${calendar[@]}" \
+ --subscribe calendar system_woke
diff --git a/mac/.config/sketchybar/plugins/calendar.sh b/mac/.config/sketchybar/plugins/calendar.sh
index 013e3db..5999f84 100755
--- a/mac/.config/sketchybar/plugins/calendar.sh
+++ b/mac/.config/sketchybar/plugins/calendar.sh
@@ -5,23 +5,24 @@ source "$CONFIG_DIR/colors.sh"
# Get next calendar event
get_next_event() {
- # Use EventKit to get calendar events
- local event_info=$(osascript << 'EOF'
+ # Use EventKit to get calendar events
+ local event_info=$(
+ osascript <<'EOF'
tell application "Calendar"
set currentDate to current date
set endOfDay to currentDate + (1 * days)
-
+
set allEvents to {}
repeat with cal in calendars
set calEvents to (events of cal whose start date ≥ currentDate and start date ≤ endOfDay)
set allEvents to allEvents & calEvents
end repeat
-
+
if (count of allEvents) > 0 then
set nextEvent to item 1 of allEvents
set eventStart to start date of nextEvent
set eventTitle to summary of nextEvent
-
+
# Find the earliest upcoming event
repeat with evt in allEvents
if start date of evt < eventStart and start date of evt ≥ currentDate then
@@ -30,11 +31,11 @@ tell application "Calendar"
set eventTitle to summary of evt
end if
end repeat
-
+
# Format the time properly
set eventHour to hours of eventStart
set eventMinute to minutes of eventStart
-
+
# Convert to 12-hour format
if eventHour = 0 then
set displayHour to 12
@@ -49,19 +50,19 @@ tell application "Calendar"
set displayHour to eventHour - 12
set ampm to "PM"
end if
-
+
# Format minutes with leading zero if needed
if eventMinute < 10 then
set minuteStr to "0" & eventMinute
else
set minuteStr to eventMinute as string
end if
-
+
set formattedTime to displayHour & ":" & minuteStr & " " & ampm
-
+
set eventDate to date string of eventStart
set todayDate to date string of currentDate
-
+
if eventDate = todayDate then
return eventTitle & "|" & formattedTime
else
@@ -72,46 +73,46 @@ tell application "Calendar"
end if
end tell
EOF
-)
-
- echo "$event_info"
+ )
+
+ echo "$event_info"
}
# Get calendar information
EVENT_INFO=$(get_next_event 2>/dev/null)
if [[ "$EVENT_INFO" == "No events" ]] || [[ -z "$EVENT_INFO" ]]; then
- # No upcoming events
- ICON="󰸗"
- COLOR=$GREY
- LABEL="No Events"
+ # No upcoming events
+ ICON="󰸗"
+ COLOR=$GREY
+ LABEL="No Events"
else
- # Parse event information
- IFS='|' read -r event_title event_time <<< "$EVENT_INFO"
-
- # Set icon and color based on time
- if [[ "$event_time" == "Tomorrow"* ]]; then
- ICON="󰸗"
- COLOR=$ACCENT_QUATERNARY
- else
- ICON="󰃭"
- COLOR=$ACCENT_PRIMARY
- fi
-
- # Truncate long event titles
- if [[ ${#event_title} -gt 15 ]]; then
- event_title="${event_title:0:15}..."
- fi
-
- # Create multi-line label using actual newline
- LABEL="$event_title
+ # Parse event information
+ IFS='|' read -r event_title event_time <<<"$EVENT_INFO"
+
+ # Set icon and color based on time
+ if [[ "$event_time" == "Tomorrow"* ]]; then
+ ICON="󰸗"
+ COLOR=$ACCENT_QUATERNARY
+ else
+ ICON="󰃭"
+ COLOR=$ACCENT_PRIMARY
+ fi
+
+ # Truncate long event titles
+ if [[ ${#event_title} -gt 15 ]]; then
+ event_title="${event_title:0:15}..."
+ fi
+
+ # Create multi-line label using actual newline
+ LABEL="$event_title
$event_time"
fi
# Update the Calendar item
sketchybar --set "$NAME" icon="$ICON" \
- icon.color="$COLOR" \
- label="$LABEL" \
- label.color=$WHITE \
- label.font="SF Pro:Medium:12.0" \
- label.max_chars=20
+ icon.color="$COLOR" \
+ label="$LABEL" \
+ label.color=$WHITE \
+ label.font="SF Pro:Medium:12.0" \
+ label.max_chars=20