1

How can I show fewer or more hours at a time in Week view in Calendar.app without opening preferences every time?

Pinching does nothing for me, heightening or shortening the window just proportionally grows/shrinks the vertical size of each hour too so the same number of hours are shown no matter the window size.

1
  • Did my Alternate Solution work for you? Oct 24, 2021 at 17:51

1 Answer 1

4

My guess would be that by default with having the, e.g. Show: [12] hours at a time preference in Calendar > Preferences… > General, that will be the only way to change the number of hours shown from within Calendar, regardless of the size of the window. I tested with various combinations of modifier keys and it didn't help to change the number of hours displayed.

That said, I did test doing it programmatically thru scripting and assigning a keyboard shortcut to an Automator Quick Action/Service and it does work.



Alternate Solution

Create two Automator Quick Action/Service, with settings:

  • Workflow receives [no input] in [Calendar]

Add a Run Shell Script action to each, with settings:

  • Shell: [/bin/zsh]
  • Pass input: [to stdin]

Add the following example shell script code to the first one and save it as, e.g.:

  • Zoom out Hours in Calendar

Example shell script code:

deltaHours=2
currentHours=$(defaults read com.apple.iCal 'number of hours displayed')
[ $((currentHours + deltaHours)) -gt 24 ] && exit 0
defaults write com.apple.iCal 'number of hours displayed' -int $((currentHours + deltaHours))

Add the following example shell script code to the second one and save it as, e.g.:

  • Zoom in Hours in Calendar

Example shell script code:

deltaHours=2
currentHours=$(defaults read com.apple.iCal 'number of hours displayed')
[ $((currentHours - deltaHours)) -lt 6 ] && exit 0
defaults write com.apple.iCal 'number of hours displayed' -int $((currentHours - deltaHours))

Notes:

In System Preferences > Keyboard > Shortcuts > Services I assigned each a keyboard shortcut of ⌘K and ⌥⌘K respectively.

In testing, I could press the assigned keyboard shortcut multiple time in a row quickly and have the number of hours displayed increase/decrease.

The example shell script code as currently coded will increase/decrease by two hours with each pressing of the assigned keyboard shortcut.

The example shell script code, shown above, was tested in a Run Shell Script action as an Automator Quick Action/Service with keyboard shortcuts assigned under macOS Catalina and macOS Big Sur with Language & Region settings in System Preferences set to English (US) — Primary and worked for me without issue1.

  • 1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.



Note: The example shell script code is just that, an example, and sans any included error handling does not contain any additional error handling as may be appropriate, needed, or wanted. The onus in upon the user to ensure the script is fit for use for ones purpose.

1
  • This didn’t work anymore in macOS Sonoma 14.0. Took me about an hour to find that simply by replacing com.apple.iCal by /Users/[username]/Library/Preferences/com.apple.iCal.plist did the trick. Thanks!
    – tb87
    Oct 16, 2023 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .