Mavericks - CocoaDialog at logout

dwandro92
Contributor III

Our organization has been using CocoaDialog progress bars at logout to display the installation progress of non-Apple and Apple software updates. Recently I've been working on our Mavericks image (which has been quite a pain, to say the least) and we have noticed that CocoaDialog progress bars aren't being displayed during logout. I am positive that the policy scope is correct and that the update actions are running, but the dialogs are just not being displayed. In addition, I have verified that the progress bar windows are being displayed correctly when executed while I am logged in. Has anyone seen this problem and found a solution, or is there any other application we could use to accomplish this task on 10.9? Please let me know.

Thank you,

Dakota Wandro
Imaging Specialist

71 REPLIES 71

loceee
Contributor

Doesn't work on a logout hook though. Not sure what jamfHelper is doing there.

jesseshipley
Contributor

@loceee This works using a LaunchDaemon with the regular v3.0b of cocoadialog.

loceee
Contributor

Ahaha. I was actually about to test the original release now. What a numpty. Move along, nothing to see here.

bentoms
Release Candidate Programs Tester

@nigelg Imm not sure if the JAMFHelper is a signed app.. That might help.

Also it maybe the method used to call JAMFHelper.

@jesseshipley works at logout via a launchdaemon?

loceee
Contributor

Try that binary again... looks like I might have cracked it... cocoaDialog.zip

sudo defaults read com.apple.loginwindow LogoutHook
{
    LogoutHook = "/Library/Scripts/logouthook.sh";
}

/Library/Scripts/logouthook.sh

#!/bin/bash
/Applications/cocoaDialog.app/Contents/MacOS/cocoaDialog ok-msgbox --text "I am displaying on a logout hook"
sleep 1
exit

Ya'll owe me a beer at JNUC if I fixed it. 0f3d1f27e6824ec897a8f8e59d41d3b0

russeller
Contributor III

I tested @loceee build of CocoaDialog with @dwandro92 script with a JSS logout trigger and it worked! Well done! Did you have to just remove the legacy code from CocoaDialog? Any other tweaks?

mm2270
Legendary Contributor III

@loceee

Ya'll owe me a beer at JNUC if I fixed it.

Indeed! Will you actually be making it out there this year?

jhbush
Valued Contributor II

@loceee thank you for fixing this. Will you be pushing your changes to your fork of CocoaDialog on your GitHub repo?

loceee
Contributor

@mm2270 actually pretty unlikely. 2 kids in childcare and a mortgage... and I kinda doubt I can get $ out of work to ship me over. Pour one out for me though.

@ssrussell other tweaks I found in similar projects - all in github fork now.

@jhbush1973 done. https://github.com/loceee/cocoadialog

INSERT shameless plug - all details on my blog - http://www.rehrehreh.com

mscottblake
Valued Contributor

Very cool, @loceee. Thanks for your effort on this. You should try to do a PR back to the main repo too.

loceee
Contributor

@mscottblake is anyone even maintaining the repo anymore?

mscottblake
Valued Contributor

@loceee I know he pays attention, and he might bring in the changes since he doesn't have to do the work. Otherwise, no.

jesseshipley
Contributor

@loceee It just so happens @bentoms volunteered me to modernize it with swift. I made it a part of my annual goals at work so you'll see a whole new version at some point this year if all goes according to plan.

nessts
Valued Contributor II

well @jesseshipley if you are taking requests, the bubble notifications should turn into notification center items. Although I still think that is the worst new feature they have provided, a notice pops up and disappears somewhere I never remember to look for notices, much like JAMF notices winding up there. But maybe some people actually use that thing regularly and it would be handy for those notices to go there.

jesseshipley
Contributor

Depending on how it goes @nessts that could be a part of it. Currently Yo does that very well and they are persistent alerts not just banners. Check it out here https://github.com/sheagcraig/yo.

mm2270
Legendary Contributor III

@jesseshipley Kind of psyched to hear that you'll actually be looking to keep cocoaDialog alive! As you can imagine and see by the myriad threads here, its one of those tools that, should it just stop working one day, there will be many sad Mac admins out there. :'-( We'd all survive of course, but our world will be a little duller and more "cookie cutter" like if you ask me. So any effort you put into this will be much appreciated!
I'm looking forward to see what you can do. Just fixing a few of the current bugs would be a major thing by itself. For example, I had to stop using the dropdown window style a few OS versions back as the window size doesn't respect the amount of text you add to the dialog, meaning the drop down menus get smooshed up against the text, looking rather ugly. No amount of fiddling has been able to work around the issue in all my testing.

FWIW, I kind of stopped using the bubble or notify window a while ago. Although I generally would agree with @nessts on what he's stating, at least NC messages get logged into the full Notification Center view, and the user can see them later if they happened to miss them. The bubble/notify style in CD just disappears after the time out and does not log anything anywhere, so they can be completely missed. I don't see much point in using them anymore, and the original developer was thinking the same thing before he dropped any development on it.

bentoms
Release Candidate Programs Tester

Haha. Go @jesseshipley! go!

jesseshipley
Contributor

@bentoms only way I'll make it happen is by making myself fully accountable for it. Now everyone in the IRC, here, and my boss expects it to happen. Completely painted into a corner now haha.

emily
Valued Contributor III
Valued Contributor III

@jesseshipley let us know if we need to send you some caffeine at any point. :)

NightFlight
New Contributor III

I'd just like to point out I still use the CocoaDialog progress dialog to output rsync progress at login hook, as that is what I use for roaming mobile profiles (flawlessly). Logout is just a black screen. I've not been able to get anything on top of that hook's screen since 10.8 I don't think.

One has to wonder if swift has any value here.

bentoms
Release Candidate Programs Tester

@chris.hotte a number of the functions within CocoaDialog have been deprecated now & so large parts need to be re-written/replaced.

So my idea was to attack it in Swift as then they would be current functions & it would have been a cool swift project.

But as @jesseshipley has more swift knowledge & seemingly more drive.. I just talked them into it.

Meanwhile, I can bugger about with $other_projects

mm2270
Legendary Contributor III

@bentoms More wife knowledge? How can I get some of that please? I never quite seem to have enough of that... and some days it gets me into trouble.

russeller
Contributor III

This doesn't work with my wife

#!/bin/sh
sudo make_me_a_sandwich

https://xkcd.com/149/

jesseshipley
Contributor

My wife knowledge is greatly exaggerated seeing as I'm without one.

bentoms
Release Candidate Programs Tester

Haha. Gotta love a typo.

nessts
Valued Contributor II

if you want a sandwhich its more like

#!/bin/sh
nice -10 make_me_a_sandwhich
if [ -e /tmp/hell_no ]; then
    sudo please
fi

russeller
Contributor III

@nessts haha good point, please goes a long way. I never used the nice binary before, very interesting.

nigelg
Contributor

@loceee Awesome, I will be giving that a try! Could maybe use it instead of messing around in Cocoa anyway - I used my own progress bars in 10.8 but couldn't in 10.9. Also can't wait to see the new swift version @jesseshipley

jreitzersmith
New Contributor

@jesseshipley - Were you able to make any progress on updating CocoaDialog over the last year?

jesseshipley
Contributor

@jreitzersmith I postponed it to this year waiting en El Cap and some other stuff. I have a couple of tools I'm hoping to build for the community and will post them once I have more info to share.

NightFlight
New Contributor III

Redacted.

nigelg
Contributor

So I got a cocoa app written in swift to appear at logout. Its just a very basic app that opens a window for now - just a test case but happy I got it working. The code I need to add was a single line.

self.window.level=2147483631

Heres is my appdelegate code. It makes a window appear then it pauses for 10 seconds before it terminates the application.

I used 2 sources - the new version of Cocoa Dialog that @loceee made and the FileVault code from here that he referenced on his github. Initially I had a lot of extra lines in there but turns out that all I needed was to set the window level to be higher than the fullscreen window at logout. So simple now I've got it working.

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!


    func applicationWillFinishLaunching(notification: NSNotification) {


    }

    func applicationDidFinishLaunching(aNotification: NSNotification) {
        // Insert code here to initialize your application

        self.window.level=2147483631

        let time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), 10 * Int64(NSEC_PER_SEC))
        dispatch_after(time, dispatch_get_main_queue()) {
            //put your code which should be executed with a delay here

            NSApplication.sharedApplication().terminate(self)
        }
    }

    func applicationWillTerminate(aNotification: NSNotification) {
        // Insert code here to tear down your application
    }


}