Recently, I'm searching how to change the Android Wear's settings
and some of them are found in settings.db.
Brightness
adb shell settings put system screen_brightness_mode 0
adb shell settings put system screen_brightness 0
Airplane mode
adb shell settings put global airplane_mode_on 0
Theater mode
adb shell settings put global theater_mode_on 0
Wi-Fi
adb shell settings put global wifi_on 0 & adb reboot
However, I cannot find the following settings in settings.db
Always-on screen
Wrist gesture
Please tell me if you know them!
Thanks,
For always-on screen I use: adb shell svc power stayon true
Don't know about the Wrist gesture, all I could find was wake_gesture_enabled.
Related
On macOs Catalina have problems with making screenshots over cron.
When manually run do_screenshot.sh script then all fine.
But when it run auto over cron - probs, only menu correct, instead window content shown macOs background(see pic)
do_screenshot.sh:
#!/bin/bash
DATEFULL=`date '+%Y%m%d%H%M%S'`
FILENAME="/Users/yak/Documents/screenshots/"$DATEFULL.png
/usr/sbin/screencapture -x $FILENAME
Ran into this problem after the update too. Spent hours learning the details, here is the why and how. Credit goes to big-circle. The original question and answer here.
The problem is the cron doesn't have screen access.
Here's the solution
close SIP (System Integrity Protection).
Make sure your SIP is disabled. To check if SIP is disabled. To to terminal and type csrutil status. It should say SIP status: enabled/disabled.
To disable it:
Powerdown Mac, start up again and hold down cmd+r until OS X Utilities window shows up. Open terminal type csrutil disable. Restart again, boot into normal mac os.
grant write permission to TCC
sudo chmod 664 /Library/Application\ Support/com.apple.TCC
grant screencapure privilege to cron and screencapture
a) CRON:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/cron", 1, 1, 1, "", "", "", "UNUSED", "", 0,"")'`
b) screencapture:
Pre Big Sur:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/screencapture", 1, 1, 1, "", "", "", "UNUSED", "", 0,"")'`
--------------------------------------------------------------------------
Big Sur and later:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/screencapture", 1,2,4,1, "", "", "", "UNUSED", "", 0,"")'`
It's probably a good idea to turn SIP back on at this stage. To enable it, follow step 1, and instead of csrutil disable just type csrutil enable.
Edit # 2021-12-09T11:58:00+1000: Added in commands for Big Sur and later per comment from Silvan Mühlemann
You should allow your script to use the "Screen Recording" in the "Security & Privacy" system preferences.
You may start your app in a background from a terminal with a long loop (you need start it manually, that is not good):
#!/bin/bash
for value in {1..980}
do
/Users/<username>/record_activity_with_screen_capture.bash
sleep 60
done
echo All done
OR
use launchd (instead of cron) for running this script.
There are two examples:
how to start bash script in launchd
How to add timing
calendar example
Instead of playing with SIP (System Integrity Protection), which is dangerous, but suggested anyways but the top answer, simply give Screen Recording permissions to /usr/sbin/cron (or /sbin/cron in some MacOS versions I think).
In order to do that:
Open System Settings
Open Security & Privacy
Go to the Privacy tab
Go to Screen Recording
Click the lock in the bottom left corner and authenticate in order to enable editing the list
Now, if cron is listed there and unchecked, check it and the job is done. Likely is not listed there at all and you need to add it manually
Click on + below the list of programs
In the file picker hit a magic command Cmd+Shift+G, which will show a Go To Folder popup
Type: /usr/sbin and hit Enter (if you can't find cron in the next steps, try /sbin here instead)
You should see a list of files, all with an icon of a black terminal
Find cron on the list and hit Open
Check the checkbox next to cron
Wait for your cron to run the command again.
Voila, it should be capturing screenshots now.
You can try to change shebang to #!/bin/sh, or change screencapture to exec screencapture
First some background: I'm using the LaunchD feature in Mac OSX to periodically launch an application I'll call "AppX". Optimally I like to run this application nearly 24/7. But due to issues with memory leakage (that is my best guess), AppX closes periodically. To solve this, I've created and loaded a simple plist file to launch the application every 6 hours. This itself works perfectly and minimizes application downtime. However, AppX itself can be a drain on my battery, and I'd prefer it only launch when I'm at home, connected to my wifi network.
Please be aware that while I have some experience with C++ and Java, I know very little in the way of Unix.
My question: I'd like to use an if statement to check whether the network I'm connected to is my home wifi network. Being the case that it is, the system will execute the command:
open -a AppX
So... How would I implement an if statement to accomplish this? Any help is appreciated.
There's an older SO question that gives part of the answer:
Get wireless SSID through shell script on Mac OS X
As for the if statement, the following should work:
homenet = "MyHomeNetwork"
netname = /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
if [ "$netname" -eq "$homenet" ]
then
# Do fancy service startup here
else
# This is not my home network
fi
I am trying to launch Settings app from am start -a ACTIVITY from uiautomator code, in this way: am start -n com.android.settings/.Settings
But the problem is, the settings activity in one samsung device is /.Settings & in another device is /.SettingsTabActivity.
So, how can write the code that should launch Settings app in both the phones? (means how to handle both activities /.Settings & /.SettingsTabActivity)
Get the device name from getprop ro.build.product and store to a string devname, Accordingly use the activity name.
if (devname.contains("samsung"))
Runtime.getRuntime()
.exec("am start -n com.android.settings/.Settings");
else
Runtime.getRuntime()
.exec("am start -n com.android.settings/.Settings$WifiSettingsActivity");
If you just want to start the main settings app then just use - am start com.android.settings this starts the package's main activity so should solve your problem.
How do I turn off bluetooth via terminal/shell/automator/applescript on a Mac? It should be pretty easy.
BTW, I know you can get applescript to press the bluetooth menu and then press turn bluetooth off. I don't want this if possible.
I'm going to use blueutil.
-- gadgetmo
There are two ways to go about it. You can tell launchd to unload the Bluetooth daemon and no longer start it on demand, or you can programmatically toggle the preference for it and stop the server.
For the former method, use launchctl to tell launchd to unload the daemon and set its disabled flag:
# launchctl unload -w /System/Library/LaunchDaemons/com.apple.blued.plist
If you want to restore it later, this should suffice:
# launchctl load -wF /System/Library/LaunchDaemons/com.apple.blued.plist
That should do it. Now for the latter method, first update the preference file (same thing that would happen when toggling from the UI):
# defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState -BOOL 0
Then, you can just rudely kill off the server:
# killall blued
Later, you can restore the preference by resetting the bit:
# defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState -BOOL 1
Then kick launchd to have it fire up blued again:
# launchctl start com.apple.blued
Is it possible to set the baud rate for Macs in a terminal? If yes, how to set the baud rate in terminal through the terminal?
I am trying to talk to the Mac using an Arduino (open source microcontroller), an XBee (wireless communicator) to type in the terminal through the serial monitor. The only problem I am having is the baud rate of the serial monitor and terminal are different. I can easily change the baud rate for the serial monitor in the Arduino, but I do not know what the baud rate is for the terminal in Mac.
On Mac OS, stty seemingly can only change terminal settings for an ongoing access.
It works to either:
Access the serial interface, e.g. cat /dev/cu.usbserial, the default settings will be used at first. On a different terminal use stty, e.g. stty -f /dev/cu.usbserial 230400 to set the baud rate, the settings of the terminal accessed before will change.
There is a small time window after executing stty, in which the access can be performed with the desired parameters, e.g. stty -f /dev/cu.usbserial 230400 & cat /dev/cu.usbserial executes stty, detaches it and then immediately performs the access to the serial device.
For one line command logging serial port /dev/tty.usbserial-X's output to cat.out and terminating the logging by pressing Ctrl+C, here is the solution: trap 'kill $(jobs -p)' SIGINT ; cat /dev/tty.usbserial-X | tee cat.out & stty -f /dev/tty.usbserial-X 115200. You can type Ctrl+C to terminate logging to cat.out. (edited)
This only seems to work for the /dev/cu.* device files. I don't know the difference from /dev/tty.* files.
Minicom is an excellent tool that does exactly what you're asking for. You can get it using apt on ubuntu but should check this Tutorial out for Mac.
Keep the serial reset issue in mind if you plan on sending data to the Arduino. see http://arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection
stty 19200 or so.
Check man stty, you can set stop bits, speed, etc.
Surprised that no one mentioned picocom which could set higher bard rate up to 4000000.