예제 #1
0
        public static void SetIsShownInDock(this NSApplication self, bool visible = true, bool relaunch = false)
        {
            if (visible == self.IsShownInDock())
            {
                return;
            }

            var path  = Path.Combine(NSBundle.MainBundle.BundlePath, "Contents/Info.plist");
            var plist = NSMutableDictionary.FromFile(path);

            plist[(NSString)"LSUIElement"] = NSNumber.FromBoolean(!visible);

            if (plist.WriteToFile(path, true))
            {
                Process.Start("/usr/bin/touch", string.Format("-fmac \"{0}\"", path));
                if (relaunch)
                {
                    self.Relaunch();
                }
            }
        }