How to Run Commands Actively in Background on macOS or OS X

Long ago I wanted to run certain commands and output them to my desktop but not just statically I wanted it to update. There was and tynially still is a tool called Geektool that allowed you to accomplish this. Initially I had it on this tool but it went silent for quite awhile as far as updates go until recently. Since then I looked for a substitute and found Übersicht.

I found it works really well and a bit cleaner for some things at least for me. There is also place for widgets, as they call them, that will give you dozens of ready made containers that you can add to your desktop. I also like the fact you can have different things for multiple monitors/desktops. In my case I have at least three monitors active at any given moment so this is a really great feature. You can also upload you own widgets for the community to use. I created a couple myself that have been downloaded many times.

I tried to make my desktop as clean as aI could but still provide me the widgets that works for me. Below you can see several widgets some like the “clock” are repeated on all my monitors.

My main desktop/monitor using Übersicht
Second desktop/monitor
Third desktop/monitor

When you get Übersicht loaded you will get a menu icon in which you can hide/unhide, edit, restart, open widget folder, etc. When you right click on the icon you will get something like this:

Right click on Übersicht icon

Here is a list and desktop location of what each one actually does. When you add a widget to the widget directory it will automatically pop up somewhere on your desktop. There are default location and other settings that will be changed after you get them installed. Although each widget has differences, there is some consistency.

Default location of widgets: /Users/<USER_NAME>/Library/Application Support/Übersicht/widgets

Widget NameDescriptionLocation
Playbox.widgetWhat’s playing from iTunes1st monitor, bottom right
bar.widgetHorizontal red bar1st monitor, bottom
cpu-bar.widgetCPU usage1st monitor, top
darksky.widgetWeather2nd monitor, upper left
ical2.widgetUses icalbuddy to display events. 1st monitor, bottom
mail.widgetUnread mail count1st monitor, bottom
memory-bar.widgetMemory usage1st monitor, top
network-throughput.widgetNetwork throughput1st monitor, top
outdated-brew-formulae.widgetWhat needs to be updated in Brew1st monitor, bottom
simple-clock.widgetClockAll dekstops/monitors
tmstatus.widgetTime machine Status2nd monitor, left
vertical-calendar.widgetCalendar, highlights current day1st monitor, left
vms.widgetShows what virtual machines are running and what they are.1st monitor top
Mail and VMs are the ones I wrote

There is plenty of information on the website to get this installed and configured the way you want. So I wont get into that so much, but here is what it may/could look like. Below is my VM script that I wrote for Übersicht. The code will call my shell script then display it accordingly.

This is the main script called index.coffee. It then will call my vms.sh script.

#index.coffee
command: "vms.widget/vms.sh"
refreshFrequency: 500000
style: """
  top: 45px
  left: 66%
color: #0000
  font-family: Helvetica Neue
  div
    display: block
    border: 0px solid #fff
    text-shadow: 0 0 1px rgba(#000, 0.5)
    background: rgba(#fff, 0.0)
    font-size: 14px
    font-weight: 500
    padding: 2px 0px 0px 0px
    font-family: Helvetica  Neue
    &:after
      content: 'VM Status'
      position: absolute
      left: 0
      top: -20px
      font-size: 16px
      font-weight: 500
      color: #09f
      font-weight: 500
"""
render: -> """
  <pre><div class='vms' style="font-family: Helvetica"></div></pre>
"""
update: (output, domEl) ->
  $(domEl).find('.vms').html(output)

Here is the vms.sh script, just shell scripting nothing crazy. This will go in the same directory or a sub whatever you like.

#!/bin/bash
# Makes calls for VMWare, Parallels and Virtual Box and 
# displays the count and type.

vm=`/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion list |awk -F/ '{print $NF}'|sed s/.vmx//g|grep -v Total|sed 'N;s/\n/ | /' `
pa=`/usr/local/bin/prlctl list -a --vmtype vm|grep -v NAME|grep  running|awk '{ $1=""; $2=""; $3=""; print}'| sed -e 's/^[ \t]*//'`
vb=`/usr/local/bin/VBoxManage list runningvms|awk '{print $1}'|sed 's/ //g'|sed 'N;s/\n/ | /' `
vmcount=`/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion list |head -1|awk '{print $4}'`
pacount=`ps -ef |grep Parallel|grep Window|head -1|wc -l`
vbcount=`/usr/local/bin/VBoxManage list runningvms|wc -l`
#
total=$(( $vmcount + $pacount + $vbcount ))
echo  -e "Running VM Count = $total  "
echo ""
if [ $total -ne 0 ];then

echo -e  " Fusion: \t $vm  "
echo -e  " Parallels: \t $pa  "
echo -e  " VBox: \t $vb  "
fi