Recent

Author Topic: Hiding my app from the dock and the CMD-TAB list of running programs  (Read 666 times)

yazzdi

  • New Member
  • *
  • Posts: 16
We wrote a FPC/Lazarus program that is a helper program to another FPC/Lazarus program that we also wrote.
When the helper program runs, I want it to be as invisible as possible.
That includes not showing up in the dock, and not showing up on the CMD-TAB list of programs.
In addition, is it possible for the program to not have a main menu, currently the helper program has a tiny menu, but it has no use for a menu at all. But since the Apple symbol is part of the menu, I expect that Apple insists on a menu bar for every program.


Leledumbo

  • Hero Member
  • *****
  • Posts: 8114
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #1 on: August 30, 2019, 12:07:24 pm »
Why not make it a console app instead?

yazzdi

  • New Member
  • *
  • Posts: 16
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #2 on: August 30, 2019, 06:51:45 pm »
>Why not make it a console app instead?

It’s got dialogs that it needs to shows at various times.

440bx

  • Hero Member
  • *****
  • Posts: 1258
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #3 on: August 30, 2019, 10:45:55 pm »
When the helper program runs, I want it to be as invisible as possible.
That includes not showing up in the dock, and not showing up on the CMD-TAB list of programs.
In addition, is it possible for the program to not have a main menu, currently the helper program has a tiny menu, but it has no use for a menu at all. But since the Apple symbol is part of the menu, I expect that Apple insists on a menu bar for every program.
I don't know if what I'm going to suggest can be done on a mac but, on Windows, you could have the helper program be a dynamically loaded and unloaded service. 

That would meet all the requirements you've mentioned so far.  In a unix environment, that would be making your helper program a daemon.  If you think that is a solution, you could ask for how a daemon is created in FPC, which is not something I can help you with, since I am not well versed on that platform.



using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #4 on: September 01, 2019, 04:22:55 pm »
you're looking into creating an "agent app".
In order to do that, you need to add special option into your app bundle Info.plist file:

LSUIElement
Code: [Select]
  <key>LSUIElement</key>
  <true/>

There's a documentation regarding that on FPC wiki.
https://wiki.freepascal.org/Carbon_Interface#Hiding_application_from_the_Dock
It resides in Carbon section, but it applies to Cocoa. (this should be moved to "OS X Programming Tips", rather than being widgetset specific)
« Last Edit: September 01, 2019, 06:32:54 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Bart

  • Hero Member
  • *****
  • Posts: 3546
    • Bart en Mariska's Webstek
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #5 on: September 01, 2019, 04:59:28 pm »
I have a sneaky suspicion I have seen this discussion (with this example) several times before, either on this forum or on the ML.

Bart

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 243
  • Former Delphi 7 and Delphi 10.2 User
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #7 on: September 02, 2019, 01:02:15 pm »
Moved Hiding an app from the Dock content from Carbon Interface page to its own page:

https://wiki.freepascal.org/Hiding_a_macOS_app_from_the_Dock

and referenced in the Carbon Interface and the OS X Programming Tips pages.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #8 on: September 03, 2019, 02:39:46 am »
Thank you!
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

yazzdi

  • New Member
  • *
  • Posts: 16
Re: Hiding my app from the dock and the CMD-TAB list of running programs
« Reply #9 on: September 03, 2019, 04:45:46 pm »
Many thanks for the helpful replies!