Skip to content

Instantly share code, notes, and snippets.

@seansu4you87
Last active February 17, 2024 04:29
Show Gist options
  • Save seansu4you87/9595069 to your computer and use it in GitHub Desktop.
Save seansu4you87/9595069 to your computer and use it in GitHub Desktop.
GeekTools Multi Monitor Reposition

Geektools with Varying Monitor Setups

While I love my Geeklets, I had a pretty hard time to set them up consistently across varying monitor setups (home, work, on the go,...). The bad news first: There is no built in mechanism (as of 01/2013) to take care of this problem. Still there are good news: With some minor tinkering, you can automagically position your Geeklets across multiple setups.

The initial step is to add your Geeklets - you can totally ignore the positioning for the moment.

Which Geeklets Am I Running?

Once this is done, let's start with some simple scripts. With the help of AppleScript (I created .app files for this), you can position your Geeklets wherever you want. This means you'll need to create one script for each setup. However, I found the manipulation via a script more convenient than dragging Geeklets around by mouse, but GUI centric users might disagree. So let's get started: First, fire up the AppleScript Editor and run the following code to fetch the IDs of all the Geeklets you've added so far:

tell application "GeekTool Helper"
  geeklets
end tell

This should return a result similar to this one:

{shell geeklet id "77946042-43FA-42CF-891B-624912269D25" of application "GeekTool Helper", shell geeklet id "E94270E2-35BB-42B1-B0F1-E464DE988940" of application "GeekTool Helper", shell geeklet id "C834BEE8-670D-4C77-BA15-D1388B32FF80" of application "GeekTool Helper", shell geeklet id "0B44BD7D-E6BA-45C1-A794-C54D35DEE605" of application "GeekTool Helper", image geeklet id "CC56DB0D-92FB-4D9A-848A-F131FB3DFB5D" of application "GeekTool Helper", shell geeklet id "3AA07D2C-F41A-42C2-8D99-5CF17E5EFD2A" of application "GeekTool Helper", shell geeklet id "CD1A2CEE-AEDF-4932-BB6A-957D03FF8752" of application "GeekTool Helper", image geeklet id "5FCF08C3-C73F-4BA9-A963-E5DAA25D1653" of application "GeekTool Helper", shell geeklet id "416A2E4A-5E10-416F-AE93-2AF041CB5B02" of application "GeekTool Helper"}

You might want to save our first script, as it comes in handy whenever you add or remove Geeklets.

Position Your Geeklets

Now it's time to get started with the positioning. What we are doing now is to use the IDs from the previous step to position them. Positioning means setting an x and y pixel value - which will look something like this:

tell application "GeekTool Helper"
	# Date
	set x position of geeklet id "77946042-43FA-42CF-891B-624912269D25" to 7.0
	set y position of geeklet id "77946042-43FA-42CF-891B-624912269D25" to 500.0
	# Itunes visualisation
	set x position of geeklet id "E94270E2-35BB-42B1-B0F1-E464DE988940" to 660.0
	set y position of geeklet id "E94270E2-35BB-42B1-B0F1-E464DE988940" to 730.0
	# Calendar
	set x position of geeklet id "C834BEE8-670D-4C77-BA15-D1388B32FF80" to 7.0
	set y position of geeklet id "C834BEE8-670D-4C77-BA15-D1388B32FF80" to 30.0
	# Itunes title
	set x position of geeklet id "0B44BD7D-E6BA-45C1-A794-C54D35DEE605" to 513.0
	set y position of geeklet id "0B44BD7D-E6BA-45C1-A794-C54D35DEE605" to 710.0
	# Weather icon today
	set x position of geeklet id "CC56DB0D-92FB-4D9A-848A-F131FB3DFB5D" to 850.0
	set y position of geeklet id "CC56DB0D-92FB-4D9A-848A-F131FB3DFB5D" to 50.0
	# Weather temperature today
	set x position of geeklet id "3AA07D2C-F41A-42C2-8D99-5CF17E5EFD2A" to 850.0
	set y position of geeklet id "3AA07D2C-F41A-42C2-8D99-5CF17E5EFD2A" to 35.0
	# Weather lowest temperature tomorrow
	set x position of geeklet id "CD1A2CEE-AEDF-4932-BB6A-957D03FF8752" to 1027.0
	set y position of geeklet id "CD1A2CEE-AEDF-4932-BB6A-957D03FF8752" to 55.0
	# Weather icon tomorrow
	set x position of geeklet id "5FCF08C3-C73F-4BA9-A963-E5DAA25D1653" to 990.0
	set y position of geeklet id "5FCF08C3-C73F-4BA9-A963-E5DAA25D1653" to 50.0
	# Weather highest temperature tomorrow
	set x position of geeklet id "416A2E4A-5E10-416F-AE93-2AF041CB5B02" to 1027.0
	set y position of geeklet id "416A2E4A-5E10-416F-AE93-2AF041CB5B02" to 40.0
	#
	#set x position of geeklet id "" to 0.0
	#set y position of geeklet id "" to 0.0
end tell

Tip: How do you even know there is an option "x position" and what other possibilities do you have? Open AppleScript editor's library (command+shift+L). In Finder open the GeekTool.app ("Show package contents" in the context menu). Open Contents/PlugIns and open GeekTool.prefPane (again with "Show package contents"). In Contens/Resources you should find the "GeekTool Helper.app". Drag it onto the script editor's library window and you can then look up all available features.

This is my "on the go" setup, which I've saved under an appropriate name. So every time I run this little app, it will position my Geeklets on my laptop's screen. You'll need to create similar scripts for all your different setups.

Note: A different approach would be to use multiple groups and enable / disable them as needed. However, with multiple groups you'd need to duplicate the Geeklets for each setup, making it awkward to change them. I find the positioning approach much nicer, but you could also try the group one.

Automatical Execution

While this is already pretty nice, it's not automagical. To get this done you'll need a third party app, which is aware of your current location. My tool of choice is ControlPlane (http://controlplane.dustinrue.com), which is based on MarcoPolo (http://www.symonds.id.au/marcopolo/ - no longer maintained). Now I've created a location based on different monitor setups - which is really the difference we're interested in. As there is no negation at the moment, I've created a rule for "on the go" without any additional monitors with a pretty low priority. As soon as a specific screen is plugged into the laptop, a rule for this is fired with a higher priority. This should detect the correct monitor setup currently in use. The final step is to automatically execute the correct script based on the current location.

That's it - now you can have an automagical Geeklet configuration, which isn't too hard to create.

@nitrocode
Copy link

I'd like to try duplication. How do I duplicate a geeklet using the command line?

@luckydonald
Copy link

ControlPane changed website to http://www.controlplaneapp.com but also is on github: https://github.com/dustinrue/ControlPlane

@gargolito
Copy link

This works but Applescript will only re-position the geeklet in the current primary monitor (the one with the menu bar). In my case, I have two monitors attached to my MacBook Pro and use one of them as the primary monitor but I want the geeklet on my laptop display. I'm trying to find a way to move it there.
Applescript uses the context of the display to calculate the coordinates so, for example: if all my monitors are 1920x1080, applescript will see the x,y coordinates for each monitor individually, i.e. 600,900 is per monitor. In linux the desktop is cumulative. i.e. the context of the desktop is all monitors put together so the desktop context of three 1080p monitors is, 5760x1080 and 600,900 exists only once in your desktop.

@mpjuers
Copy link

mpjuers commented Jul 19, 2019

@gargolito

This works but Applescript will only re-position the geeklet in the current primary monitor (the one with the menu bar). In my case, I have two monitors attached to my MacBook Pro and use one of them as the primary monitor but I want the geeklet on my laptop display. I'm trying to find a way to move it there.

Have you solved this yet? I'm still trying to figure it out.

@gargolito
Copy link

gargolito commented Jul 23, 2019

@mpjuers
I have a sort of hack that works for now though i'd like something more automated/dependable.
I work on the command line most of the day so I have a bash script:
mvclock.sh

#!/usr/bin/env osascript on run argv tell application "GeekTool Helper" set x of geeklet id "60457FA0-A44D-4469-8BCE-7405F90CB6FB" to (item 1 of argv) set y of geeklet id "60457FA0-A44D-4469-8BCE-7405F90CB6FB" to (item 2 of argv) end tell end run

then I had to fine tune the coords for the gadget, in my case all I use is a transparent clock on the desktop.
this should be one single script but it's not that important, this is how I set the coords that I noted

case $1 in 1l) mvclock.sh -1805 15 ;; 1r) mvclock.sh 1165 15 ;; 2r) if [[ $IPADDRESS == 192.168.1.26 ]]; then mvclock.sh 1175 15; else mvclock.sh 2055 15; fi ;; 3l) if [[ $IPADDRESS == 192.168.1.26 ]]; then mvclock.sh 1550 15; else mvclock.sh 2435 15; fi ;; 3r) if [[ $IPADDRESS == 192.168.1.26 ]]; then mvclock.sh 2855 15; else mvclock.sh 4045 15; fi ;; 00 | 2l) mvclock.sh -130 15 ;; *) echo ' 1[l|r] laptop with two 4k monitors @work 2[l|r] first 4k monitor @work 3[l|r] second 4k monitor @work ' ;; esac

In case you're interested, this is the desktop clock I use with geektools https://gist.github.com/gargolito/5b61fef43671f4fa7278bc070bf34271

@chromasia
Copy link

@mpjuers, if you're still trying to solve this you can use Applescript to move a geeklet to a second monitor. In my setup the 2nd screen is to the left of my primary screen. The following will move a widget to that screen:

set x of geeklet id "4ED1045F-091D-4432-B240-4A4338E3263E" to -1862
set y of geeklet id "4ED1045F-091D-4432-B240-4A4338E3263E" to 58

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment