OSX Script for Kiosk Mode

make your own screen saver

Published May 20, 2015 #howto #osx #toys #gaze

In the office, we run Jenkins on the same machine that we run Benevolent Gaze. During iOS builds, the iOS simulator will take over the screen for the build, and then leave the beautiful screen on the desktop, hiding our smiling faces. We want to return to Safari in this case, but we also want to make sure that if someone is actually in front of the machine it will let them do their thing.

Here’s a little script that check if the user hasn’t touched the keyboard or mouse in a while, and if so it will pull Safari to the front.

while true
  IDLE=$(ioreg -c IOHIDSystem |awk '/HIDIdle/ {print int($(NF)/1000000000 + 0.5)}'| sort -n |head -1)
  echo Idle $IDLE seconds

  if [ $IDLE -gt 30 ]
    cat <<- EOF | osascript
      tell application "Safari"
      end tell
  sleep 1

The first thing that this does is to call the ioreg command to pull data from the IOHIDSystem. This is what OSX uses to track inactivity, which is used to start powering things down to conserve battery life. The units of this measurement are small, so we divide by 1000000000 to get them into seconds. We round that number to the nearest integer by adding 0.5 and lopping off the right of the decimal place with int. Then we get the shortest number in the list using sort | head.

This script waits 30 seconds (if [ $IDLE -gt 30 ]) and then will run osascript to activate Safari. The here-doc between EOF is AppleScript which will activate Safari and bring it to the front. Replace that with Google Chrome if that’s your preferred browser.

Read next

See also

Embedding 3d models on your page

Github is awesome

Github has an embeddable 3d model viewer that you can use to display a model on your site. The model needs to be hosted in a github repo, and the format is <script src="https://embed.github.com/view/3d/<username>/<repo>/<ref>/<path_to_file>"></script> Here’s a model of me that we made using the Structure 3d scanner which is a fun device that plugs into your iPhone or iPad. Pretty fun right? The next thing you need to do is to get a 3d printer, so you can create action figures for your office.

Read more

Making Yosemite Faster

something is up with WindowServer

Since I’ve upgraded to Yosemite my computer has gotten slower and slower. When it first boots up, it is it’s old fast self, but after a few hours everything slows down. Remember the days when you needed to restart your computer to keep it working well? I had forgotten, and I wasn’t really into remembering it. I also upgraded to Airmail 2. I get a ton of email and it used it be a lot faster than using Mail.

Read more

How to track your coworkers

Simple passive network surveillance

How much information do you bleed? Ever wonder who is else is using your network? Or,who has actually showed up at the office? Networking primer The simplest thing we can do to make this work is to check to see which devices have registered themselves on the network. As devices come and go, they connect automatically, so we will have a pretty good idea if people are there or not. Phones seem to attach and detach quite frequency, probably to conserve battery, so if we are want to answer the question “is so-and-so in the office” we’ll need to add additional logic to determine how far spaced the “sighting” events are to mean that the person has left the office, rather than the phone has gone to sleep.

Read more