#StackBounty: #swift #macos #cocoa Getting notified when the screen brightness changes in macOS

Bounty: 250

I’m writing a macOS app for myself in which I’d like to do something with the value of the screen brightness as soon as it changes.

I can determine what the screen brightness is by iterating over IOServices with IOServiceGetMatchingServices() then using IODisplayGetFloatParameter() to obtain the kIODisplayBrightnessKey parameter of the IODisplayConnect services I found, as explained in this answer, but I don’t know how to find out when the brightness has changed.

Is there a way for my app to get notified as soon as the screen brightness has changed?

I could poll, and I know how to do that, but that’s not what I’m looking for. I’m looking for something like UIScreen.brightnessDidChangeNotification, but for macOS.


Get this bounty!!!

#StackBounty: #macos #microsoft-defender Microsoft Defender web filtering on MacOS

Bounty: 150

I would like to find out what policies were deployed to my private Mac that I enrolled under Intune in order to read work email. The Microsoft Content Filter is running under network properties – I would like to know:

  1. Where are the policies store locally
  2. What policies were deployed – are they only blocking some websites (get a list) or are they sending every webpage I visit back
  3. What server(s) are configured to use these reports?

I am sure there is a config file somewhere, but I could not find it.

Thx!


Get this bounty!!!

#StackBounty: #swift #macos #cocoa #sandbox #nsxpcconnection Inter-App Communication for sandboxed swift app on macOS

Bounty: 200

I’m building a sandboxed macOS app with Swift, which contains a child app inside.

What I want to implement is:

  • Parent can launch multiple child apps
  • Parent send different content to each child app to show
  • Both parent and child app have their own UIs.

Implementation way I’ve been thinking about:

Distributed Notification

Distributed notification with user info objects are denied by sandbox.

CFMessagePort

It requires both parent and child app are in the same app group, and signed with proper provision profiles. But on Xcode it is always None required on the provision profile settings so nowhere to change the settings.
Besides, there is no documents or posts explaining how to use CFMessagePort in Swift. I tried the code below but it crashes everytime as it’s denied by sandbox.

let portName = "{team_identifier}.{app_group_identifier}.{port_name}"
let remote = CFMessagePortCreateRemote(nil, portName as CFString)
var returnData: Unmanaged<CFData>? = nil
if kCFMessagePortSuccess == CFMessagePortSendRequest(remote, 0, data as CFData, 1, 1, CFRunLoopMode.defaultMode.rawValue, &returnData) && nil != returnData {
    
}

NSXPCConnection

I don`t think XPC works for this situation, as XPC is designed to communicate between a service running invisible and a client app, while the service is bundled into the app. I doubt it would work for the parent-child model.


So, is there any better way to achieve my target? I feel I should go with CFMessagePort but I also need some more help on how to use it with Swift. Thanks!


Get this bounty!!!

#StackBounty: #macos #elasticsearch #macos-catalina elasticsearch not started on macOS

Bounty: 50

When I try to start elasticsearch on my macOS laptop, it does not appear to have started. So much of the answers I find on the internet do not relate to using brew on macOS.

See this command line history of trying to start it.

:>brew services stop elasticsearch 
Stopping `elasticsearch`... (might take a while)
==> Successfully stopped `elasticsearch` (label: homebrew.mxcl.elasticsearch)
:>brew services start elasticsearch
==> Successfully started `elasticsearch` (label: homebrew.mxcl.elasticsearch)
:>curl http://localhost:9200      
curl: (7) Failed to connect to localhost port 9200: Connection refused
:>curl https://localhost:9200      
curl: (7) Failed to connect to localhost port 9200: Connection refused
:>lsof -i :9200     
:>sudo ps -ef | grep elastic
  501 85360 68989   0  9:51AM ttys000    0:00.00 grep elastic

Also using the Network Utility I see nothing is listening at the port 9200.

enter image description here

I am using Catalina Version 10.15.7 (19H1030).

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

My elasticsearch version is

Version: 6.0.1, Build: 601be4a/2017-12-04T09:29:09.525Z, JVM: 1.8.0_121

The location of the binary on my PATH is /usr/local/bin/elasticsearch

EDIT:

There was a comment to include any error messages or the output. If this was not clear, what I wrote is the only output. The only output to stdout or stderr from brew services start elasticsearch is "Successfully started elasticsearch".

However, when trying elasticsearch -d from the command line I get this:

:>elasticsearch -d
:>2021-05-24 09:33:08,875 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
    at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389)
    at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)
    at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:206)
    at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:220)
    at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:197)
    at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:172)
    at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:141)
    at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:120)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:290)
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:130)
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:121)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:69)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
    at org.elasticsearch.cli.Command.main(Command.java:90)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85)

ERROR: no log4j2.properties found; tried [/usr/local/etc/elasticsearch] and its subdirectories

The /usr/local/etc/elasticsearch directory exists but is empty.

:>ls -l /usr/local/etc
...
drwxr-xr-x   2 marlpier  admin     64 May 19 16:30 elasticsearch
...
:>find /usr/local/etc/elasticsearch 
/usr/local/etc/elasticsearch

Maybe my jvm.options file is not found. Where should it be?


Get this bounty!!!

#StackBounty: #ubuntu #virtualbox #macos #vagrant #shebang shebang on vagrant mount doesn't work: bad interpreter: Invalid argument

Bounty: 50

I run in a strange problem if I try to execute a file inside vagrant mount, but not outside:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

Some details:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

Tried also:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

Guest:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

Host: MacOS BigSur 11.3 (20E232)

Vagrant snippet:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

Any suggestions how to deal with that?


Get this bounty!!!

#StackBounty: #macos #tmux Tmux – Cannot use "Shift + arrows" to switch window on Mac OS

Bounty: 100

Got recently a Mac computer for work and beeing a Tmux fan I did installed it with my favorite plugins and .tmux.conf file that I use on my personnal Linux machine.

After some tweaking to make it usable on Mac OS, the only thing that’s still not working is my shortcut to switch window using "Shift + arrow" doesn’t work on this Mac computer.

I put this into my .tmux.conf :

# Set this on Mac OS

set-option -g -w xterm-keys on

# Shift arrow to switch windows 

bind -n S-Left previous-window
bind -n S-Right next-window

My guess is that the Shift key is being used by something. when I do

tmux list-keys | grep "S-"

Here is the output:

bind-key -r -T prefix       S-Up                 refresh-client -U 10
bind-key -r -T prefix       S-Down               refresh-client -D 10
bind-key -r -T prefix       S-Left               refresh-client -L 10
bind-key -r -T prefix       S-Right              refresh-client -R 10
bind-key    -T root         S-Left               previous-window
bind-key    -T root         S-Right              next-window

I tried to unbind as this:

unbind-key S-Left
unbind-key S-Right

but still, "shift+arrow" doesn’t do anything.

Do you guys have any idea how to solve this ?

Thanks!

Xzi.


Get this bounty!!!

#StackBounty: #ubuntu #virtualbox #macos #vagrant #shebang shebang on vagrant mount doesn't work: bad interpreter: Invalid argument

Bounty: 50

I run in a strange problem if I try to execute a file inside vagrant mount, but not outside:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

Some details:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

Tried also:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

Guest:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

Host: MacOS BigSur 11.3 (20E232)

Vagrant snippet:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

Any suggestions how to deal with that?


Get this bounty!!!

#StackBounty: #ubuntu #virtualbox #macos #vagrant #shebang shebang on vagrant mount doesn't work: bad interpreter: Invalid argument

Bounty: 50

I run in a strange problem if I try to execute a file inside vagrant mount, but not outside:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

Some details:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

Tried also:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

Guest:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

Host: MacOS BigSur 11.3 (20E232)

Vagrant snippet:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

Any suggestions how to deal with that?


Get this bounty!!!

#StackBounty: #ubuntu #virtualbox #macos #vagrant #shebang shebang on vagrant mount doesn't work: bad interpreter: Invalid argument

Bounty: 50

I run in a strange problem if I try to execute a file inside vagrant mount, but not outside:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

Some details:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

Tried also:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

Guest:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

Host: MacOS BigSur 11.3 (20E232)

Vagrant snippet:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

Any suggestions how to deal with that?


Get this bounty!!!

#StackBounty: #ubuntu #virtualbox #macos #vagrant #shebang shebang on vagrant mount doesn't work: bad interpreter: Invalid argument

Bounty: 50

I run in a strange problem if I try to execute a file inside vagrant mount, but not outside:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

Some details:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

Tried also:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

Guest:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

Host: MacOS BigSur 11.3 (20E232)

Vagrant snippet:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

Any suggestions how to deal with that?


Get this bounty!!!