Deploy a shortcut to user desktops to launch a specific UDP address/stream

kbreed27
Contributor

I am having trouble figuring out the ideal way to accomplish this goal:

 

Our campuses use UDP addresses to launch video announcements streams through VLC player. Up until now we had been putting bookmarks in Jamf Self-service with the udp address to pretty good results, but management wants to for us to deploy desktop shortcuts to achieve the same thing. 

 

A shell script like below would accomplish the goal, but we have terminal.app locked out to all end-users.

 

#!/bin/bash

open "udp://@192.168.0.1:1234"

 

I could make an .app to run that command through Automator, drop it in the /Applications folder or another directory, and have a script use the "ln" command to make an alias on the user's desktop, but is there not something similar to .webloc that could be used for a UDP address that's an all-in-one type solution? 

 

I feel like there is a very simple solution to this staring me in the face but I am being unintentionally obtuse.... help?

3 REPLIES 3

AJPinto
Honored Contributor II

There really is not a good way of doing this. Place stuff on people's desktop is a Windows function, macOS's desktop functions vastly different and macOS has no concept of a shared desktop. 

 

  • You could cache the file somewhere on the device. Then have a policy that runs at login to move it to the user's desktop with the mv command.
  • Opening the file with Jamf would be very tricky, Jamf runs everything as root. So, if you run open whatever in CLI, it will run that command as root and not the user, so the user won't see anything happen. It is possible to perform user substitution in commands, but it needs quite a bit of scripting.
  • Having the Terminal app blocked does not matter if Jamf or some other service is calling the script. Jamf or launch agents/daemons would call the sh, or zsh binaries directly to execute scripts and is not actually call the terminal application.

 

If you absolutely must do this. I would suggest placing the file somewhere shared, not the user's desktop. Then have a launch daemon or agent you call to run the file as the user. Or write a small "application" to do the function of running the command.

mm2270
Legendary Contributor III

Like @AJPinto mentions, one way to do this is to place the file in a shared location and then do something to make that accessible to each user on their Desktop.

However, instead of copying that file to each persons Desktop folder, you could make a symlink to it, which should have the same effect. It's like an alias, but a unix construct. Making an actual macOS native alias in a shell script is a little complicated, and not really worth the effort in my experience.

So maybe something like, deploy the file to /Users/Shared/ using a custom package (or script it into place if it's something text based), then run a command like:

ln -s /Users/Shared/somefile /Users/<username>/Desktop

You would have to loop over any accounts on the machine and do the same type of command above to get it onto all Desktops, assuming there is more than one primary account per machine. If not, then it should be pretty simple.

Short of that, writing a small application that can launch the address is also a good option. Take a look at Platypus for putting together simple apps that can run scripts.

joshuasee
Contributor III

Finder bookmarks come in flavors other than HTTP. They just use the extension inetloc instead of webloc.

What about a policy with a Files & Processes one liner to build the bookmark?

defaults write /tmp/VKRS URL 'udp://example@192.168.0.1:1234'; mv /tmp/VKRS.plist /Users/$(stat -f%Su /dev/console)/Desktop/VKRS.inetloc

Triggers would be login and check in, frequency would be once per user per computer.

Since no package is involved updates are easy.

The bookmark would be owned by root, preventing removal. If that is undesirable, use cp or ditto with appropriate arguments.

Alternately, adding a LaunchAgent to create the bookmark as users login would also work, but be more complex to set up and update.

Ways that don't work:

  • I've created desktop bookmarks before with a DMG installer and FUT/FEU, but that graceful method is no longer available.
  • Hard linking a bookmark back to a managed pref in the correct format would seem great for easy and fast updates, but it turns out cfprefsd recreates the plist at every update, breaking the link.