Recent

Author Topic: Hiding my app from the dock and the CMD-TAB list of running programs  (Read 2705 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: 8746
  • 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: 3944
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.



(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • 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 »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • 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


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 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.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • 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!

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!

 

TinyPortal © 2005-2018