[haiku] Terminal "Visor" functionality

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: Haiku ML <haiku@xxxxxxxxxxxxx>
  • Date: Sun, 2 Jan 2011 21:14:10 -0500

There is a Mac OS X utility called Visor (http://visor.binaryage.com/)
which provides a "system-wide terminal on a hot key."

I actually haven't used it but it sounds cool, so I wanted to see if I
could make the Haiku Terminal application do something like that. I
ended up just writing a bash script which uses hey and a few other
things to get this functionality. I think it is pretty slick and shows
the power of scripting in Haiku.

Anyhow the full script is at the bottom of the email. Just copy and
paste it into a file under ~/config/bin (I named mine visor), chmod +x
that file and then set up a shortcut in the Shortcuts preferences (I
used Win-` (backtick)) to run that file.

I'd recommend letting the script start Terminal because it sets the
window to show on all workspaces. This scripts the first terminal
window so any other terminals opened won't be affected. The same
script could be used for other applications by just changing the
signature and window number. FYI the first browsing window of
WebPositive is window 2 (window 0 is Downloads and window 1 is
Settings.)

Have fun!

SCRIPT_START
#!/bin/sh

signature=application/x-vnd.Haiku-Terminal
window=0

is_running=`roster | grep $signature | wc -l`
if [ $is_running -eq 0 ]; then
        open $signature
        # Let the application start before scripting it
        sleep 1
    # Show on all workspaces
        hey $signature SET Workspaces of Window $window TO -1
        exit
fi

active=`hey $signature GET Active of Window $window | awk '/result/ {print $4}'`
if [ $active = FALSE ]; then
        # Show the window and make it active
        hey $signature SET Hidden of Window $window TO FALSE
        hey $signature SET Active of Window $window TO TRUE
else
        # Hide the window if it is the active one
        hey $signature SET Hidden of Window $window TO TRUE
fi
SCRIPT_END

-- 
Regards,
Ryan

Other related posts:

  • » [haiku] Terminal "Visor" functionality - Ryan Leavengood