7

At home I've got a nice big display that unfortunately does not have the same resolution as my retina macbook does.

I'd like to use a pixel-font on the low-res screen and a nice smooth one on the retina screen. To do this I've set up a script that listens to an event when the display is connected.

I've set up two profiles in Terminal.app, one for the low-res screen and one for the retina screen.

Is there a way to make a profile the "default" profile (eg using applescript) without restarting Terminal.app (otherwise defaults com.apple.terminal ... would have done it)

The following script works by changing the current default profile (so it's not entirely what I need, but might work if I find the names of all the settings I want to change):

#!/usr/bin/env osascript -l JavaScript
function run (argv) {
  var terminal = Application('Terminal');

  terminal.defaultSettings.fontName = 'creep';
  terminal.defaultSettings.fontSize = 16;

  // these don't seem to work
  // because I do not know their names, and it's hard to debug guessing them
  // terminal.defaultSettings.fontAntialiasing = false;
  // terminal.defaultSettings.fontHeigthSpacing = 0.8;
}

I'd have to write a script to revert the changes

  • Out of curiosity, what method are using to listen to display connected events? This could probably be done via launchd if you can find out the name of the correct AppleEvent. – phobox Feb 28 '16 at 2:34
  • @phobox I'm using an iokit listener that triggers the script whenever a certain usb device is attached like in this answer. I never found out how to do it for HDMI devices, so I count on the fact that I have a FLIRC usb device plugged into the same hub that also connects the display (the display has a USB hub). You should be able to listen to devices of another class than IOUSBDevice however. Alternatively, you can just run a script that checks if the display is connected every 2 seconds or so (eg. using ioreg -p IODisplayConnect). – romeovs Feb 28 '16 at 10:31
5

Okay, after some fooling around in AppleScript editor (it has this nice thing called dictionary that shows you all available commands for a given App) I settled for this script:

#!/usr/bin/env osascript
on run {name}
  tell application "Terminal"
    set default settings to settings set name
    set current settings of tabs of windows to settings set name
  end tell
end run

Make it executable (chmod u+x change.applescript) and run it, passing in the name of the profile to activate:

./change.applescript creep

This will:

  • change the default profile, so all new windows will use it
  • change the profile of all tabs of all windows to the new profile, so open terminals get to use it too!

You must log in to answer this question.

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