HomeTaskerBest run shell commands in Tasker

Best run shell commands in Tasker

Got more interesting "run shell " actions? Email me on mat (at) notenoughtech.com or let me know via social media and I will update the list!

Following my recent write up on Secure Settings not playing well with Android 6.0 devices, I decided to make another post about Tasker Run Shell actions. I think it is a good idea to keep all of them handy in one place instead of running around the web, looking for the information.  I have a small collection of these already in my notepad. I will be updating the list each time I come across something interesting.

Watch this space then, perhaps subscribe to receive updates to this post. Perhaps, later on, I will create one for the intents as well. You can read more on intents here.

Tasker Run Shell actions

Not all devices have been made equal and to find out what settings can be toggled on yours, you need to check what is available. There are two ways you can look up and change the Android settings on your mobile (for some you will need root). The easy way and the complicated one.

Android Secure|Global|System settings – AutoTools Root

I will strongly recommend this method, as AutoTools is one of the best plugins you can get for Tasker. Android comes with dozens of settings that can be modified by (mostly root enabled) user.

These settings can be toggled with AutoTools root. To do so, simply run AutoTools Enable Secure Settings to prompt the root access and use the AutoTools settings to change the core values of the Android.

Android Sample Settings
settings list systemsettings list globalsettings list secure
accelerometer_rotation=0
alarm_alert=content://media/internal/audio/media/11
alarm_alert_set=1
bd_setting_i=867981022506516
dim_screen=1
dtmf_tone=1
dtmf_tone_type=0
haptic_feedback_enabled=1
hearing_aid=0
hide_rotation_lock_toggle_for_accessibility=0
lockscreen_sounds_enabled=1
microphone_mute=0
mode_ringer_streams_affected=422
mute_streams_affected=46
next_alarm_formatted=
notification_light_pulse=0
notification_sound=content://media/internal/audio/media/24
notification_sound_set=1
pointer_speed=0
radio.data.stall.recovery.action=0
ringtone=content://media/internal/audio/media/36
ringtone_set=1
screen_brightness=216
screen_brightness_mode=0
screen_off_timeout=120000
sound_effects_enabled=1
status_bar_show_battery_percent=1
transition_animation_scale=1.0
tty_mode=0
user_rotation=0
vibrate_when_ringing=0
volume_alarm=6
volume_bluetooth_sco=7
volume_bluetooth_sco_earpiece=9
volume_music=11
volume_music_bt_a2dp=11
volume_music_headphone=4
volume_music_headset=4
volume_music_speaker=5
volume_notification=5
volume_ring=5
volume_ring_bt_a2dp=5
volume_ring_earpiece=5
volume_ring_speaker=1
volume_system=7
volume_voice=4
volume_voice_earpiece=4
window_animation_scale=1.0
adb_enabled=1
airplane_mode_on=0
airplane_mode_radios=cell,bluetooth,wifi,nfc,wimax
airplane_mode_toggleable_radios=bluetooth,wifi,nfc
app_idle_constants=idle_duration=94610000000
assisted_gps_enabled=1
audio_safe_volume_state=3
auto_time=1
auto_time_zone=1
ble_scan_always_enabled=1
bluetooth_a2dp_sink_priority_00:18:6B:F3:AF:17=1000
bluetooth_disabled_profiles=0
bluetooth_headset_priority_00:18:6B:F3:AF:17=1000
bluetooth_on=1
bugreport_in_power_menu=0
call_auto_retry=0
captive_portal_detection_enabled=1
car_dock_sound=/system/media/audio/ui/Dock.ogg
car_undock_sound=/system/media/audio/ui/Undock.ogg
cdma_cell_broadcast_sms=1
cert_pin_content_url=https://www.gstatic.com/android/config_update/08202014-pins.txt
cert_pin_metadata_url=https://www.gstatic.com/android/config_update/08202014-metadata.txt
data_roaming=0
default_install_location=0
desk_dock_sound=/system/media/audio/ui/Dock.ogg
desk_undock_sound=/system/media/audio/ui/Undock.ogg
development_settings_enabled=1
device_name=Nexus 6P
device_provisioned=1
dock_audio_media_enabled=1
dock_sounds_enabled=0
emergency_tone=0
guest_user_enabled=1
heads_up_notifications_enabled=1
location_providers_allowed=gps
lock_sound=/system/media/audio/ui/Lock.ogg
low_battery_sound=/system/media/audio/ui/LowBattery.ogg
low_battery_sound_timeout=0
low_power=0
mobile_data=1
mode_ringer=2
multi_sim_data_call=1
multi_sim_sms=1
multi_sim_voice_call=1
netstats_enabled=1
network_scoring_provisioned=1
package_verifier_enable=1
power_sounds_enabled=1
preferred_network_mode1=10
preferred_network_mode=10
send_action_app_error=1
set_install_location=0
sms_short_codes_content_url=https://www.gstatic.com/android/config_update/06012016-sms-blacklist.txt
sms_short_codes_metadata_url=https://www.gstatic.com/android/config_update/06012016-sms-blacklist-metadata.txt
stay_on_while_plugged_in=0
subscription_mode=0
theater_mode_on=0
trusted_sound=/system/media/audio/ui/Trusted.ogg
unlock_sound=/system/media/audio/ui/Unlock.ogg
upload_apk_enable=0
usb_mass_storage_enabled=1
volte_vt_enabled=1
wifi_country_code=GB
wifi_display_on=0
wifi_max_dhcp_retry_count=9
wifi_networks_available_notification_on=1
wifi_on=0
wifi_scan_always_enabled=1
wifi_sleep_policy=2
wifi_watchdog_on=1
wireless_charging_started_sound=/system/media/audio/ui/WirelessChargingStarted.ogg
zen_mode=0
zen_mode_config_etag=-45422432
zen_mode_ringer_level=null
accessibility_display_magnification_auto_update=1
accessibility_display_magnification_enabled=0
accessibility_display_magnification_scale=2.0
accessibility_enabled=1
accessibility_script_injection=0

allowed_geolocation_origins=https://www.google.com https://www.google.co.uk
android_id=a902eb2cd83851c8
backup_enabled=1
backup_transport=com.google.android.gms/.backup.BackupTransportService
bluetooth_addr_valid=1
bluetooth_address=
bluetooth_name=Nexus 6P
cdefault_input_method=com.touchtype.swiftkey.beta/com.touchtype.KeyboardService
double_tap_to_wake=1
doze_enabled=0
dropbox:data_app_anr=disabled
dropbox:data_app_crash=disabled
dropbox:data_app_wtf=disabled
enabled_accessibility_services=
enabled_input_methods=enabled_print_services=com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService
facelock_detection_threshold=0.0
facelock_liveliness_recognition_threshold=2.2
facelock_max_center_movement=10.0
immersive_mode_confirmations=confirmed
input_methods_subtype_history=install_non_market_apps=1
last_setup_shown=eclair_1
locationPackagePrefixBlacklist=
locationPackagePrefixWhitelist=
location_providers_allowed=gps,network
lock_screen_allow_private_notifications=0
lock_screen_lock_after_timeout=30000
lock_screen_owner_info_enabled=0
lock_screen_show_notifications=1
lockscreen.disabled=0
lockscreen.options=enable_facelock
long_press_timeout=500
masterLocationPackagePrefixBlacklist=com.google.,com.semaphoremobile.zagat.android
masterLocationPackagePrefixWhitelist=com.google.android.gms
media_button_receiver=com.google.android.music/com.google.android.music.playback.MediaButtonIntentReceiver
mock_location=0
mount_play_not_snd=1
mount_ums_autostart=0
mount_ums_notify_enabled=1
mount_ums_prompt=1
nfc_payment_default_component=com.google.android.gms/com.google.android.gms.tapandpay.hce.service.TpHceService
package_verifier_user_consent=1
print_service_search_uri=https://play.google.com/store/apps/collection/promotion_3000abc_print_services
screensaver_activate_on_dock=1
screensaver_activate_on_sleep=0
screensaver_components=com.google.android.deskclock/com.android.deskclock.Screensaver
screensaver_default_component=com.google.android.deskclock/com.android.deskclock.Screensaver
screensaver_enabled=1
seen_tuner_warning=1
selected_input_method_subtype=2131165516
selected_spell_checker=com.google.android.inputmethod.latin/com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService
selected_spell_checker_subtype=0
send_action_app_error=1
serial_blacklist=
show_note_about_notification_hiding=0
sleep_timeout=-1
sms_default_application=com.google.android.talk
speak_password=0
ssl_session_cache=file
touch_exploration_enabled=0
trust_agents_initialized=1
user_full_data_backup_aware=1
user_setup_complete=1
voice_interaction_service=com.google.android.googlequicksearchbox/com.google.android.voiceinteraction.GsaVoiceInteractionService
voice_recognition_service=com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService
volume_controller_service_component=null
wake_gesture_enabled=1
web_autofill_query_url=https://android.clients.google.com/proxy/webautofill
wifi_watchdog_watch_list=GoogleGuest

You will need:

  • Setting Name
  • Type
  • Input Type
  • Value

Get the information about the setting you want to change, and you can use the AutoTools action to update the values. Additionally, AutoTools has access to toggles, apps and notifications settings too.

The Hard Way

There are 3 groups of settings: secure, global and system. To check the status of the settings simply run one of:

settings list system
settings list global
settings list secure

Store result in a variable %Settings. You can also use Set Clipboard to %Settings, and use Join to bring it on your PC, or use Write file with %Settings to save it to a text file.  In the file, you will find the list of available settings to be toggled. These will have their current state already specified by the number at the end (0= disabled, 1=enabled).

There are 2 more commands I want you to learn.

settings get secure/global/system name_of_the_setting
settings put secure/global/system name_of_the_setting 0 or 1
  • GET allows you to get the current status of the setting
  • PUT allows you to set the setting to your desired value

This alone will let you compose about 100 Run Shell commands on your own! Something I have noticed, to see the setting being changed on your mobile, you will have to leave the equivalent menu and re-enter it again, so changes made would reflect in the user interface. Simply putting the screen to the background and going back won’t work. I kept few most popular toggles in the list as an example, and for an easy access.

You can use a semicolon to add more than one command to the Tasker run shell.

Run Shell actions in Tasker (root may be required):

Airplane Mode on/off
settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
settings put global airplane_mode_on 0; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
Mobile Data on/off
svc data enable
svc data disable
Check if folder is present (1=no 0=yes)
-d /sdcard/DCIM/Camera/ echo 1 || echo 0
Store output %Variable
Extract ZIP file (%File)
unzip %file /sdcard/
Move file, copy file
mv /original/path /new/path
cp /original/path /new/path
Delete file, delete folder
rm /path/to/file
rm -r /path/to/folder
Read file, write variable (%var) to file
cat /path/to/file
echo %var > /path/to/file
Store output %Variable
Make /system rewritable, make system read-only
mount -o remount,rw /system
mount -o remount,ro /system
Change file permission
chmod 644 /system/etc/hosts

(/system/etc/hosts as example) 
file permission types 
(7=rwx; 6=rw; 4=r) (chmod(root:group;user))
Check the md5sum of the file
md5sum /path/to/file
Check if process is running (returns process or empty)
pgrep -x com.package.name
Store output %Variable
Stop current download
am force-stop com.android.providers.downloads
pm clear com.android.providers.downloads
Kill an app (Chrome in my example)
am force-stop com.android.chrome
Restart system UI
pkill -l TERM -f com.android.systemui
Reboot, reboot to recovery
svc power reboot
svc power reboot recovery
Screenshot to sdcard
screencap -p /sdcard/screengrab.jpg
Open a URL or website
am start -a android.intent.action.VIEW -d https://www.google.com
Check if keyboard is out (1=no 0=yes)
cat /proc/$(pgrep com.touchtype.swiftkey)/oom_adj

or

dumpsys input_method | grep InputShown
Store output %Variable
Ping IP (-c count,-i interval, -s packetsize, -t ttl xxx = IP)
ping -c 3 xxx.xxx.xxx.xxx
Store output %Variable
Store last input coordinates
getevent -lc 3 /dev/input/event1 | grep ABS_MT_POSITION_.
Store output %Variable
Emulate user tap input
input tap X Y
Emulate user long tap input (duration 250)
input swipe X1 Y1 X1 Y1 250
Emulate text input
input text sampletext
Emulate user swipe (z = duration)
input swipe X1 Y1 X2 Y2 Z
Emulate specific key (back in this example)
input keyevent 4

(please be aware that device screen needs to be ON for this to work)

0 --> "KEYCODE_UNKNOWN"
1 --> "KEYCODE_MENU"
2 --> "KEYCODE_SOFT_RIGHT"
3 --> "KEYCODE_HOME"
4 --> "KEYCODE_BACK"
5 --> "KEYCODE_CALL"
6 --> "KEYCODE_ENDCALL"
7 --> "KEYCODE_0"
8 --> "KEYCODE_1"
9 --> "KEYCODE_2"
10 --> "KEYCODE_3"
11 --> "KEYCODE_4"
12 --> "KEYCODE_5"
13 --> "KEYCODE_6"
14 --> "KEYCODE_7"
15 --> "KEYCODE_8"
16 --> "KEYCODE_9"
17 --> "KEYCODE_STAR"
18 --> "KEYCODE_POUND"
19 --> "KEYCODE_DPAD_UP"
20 --> "KEYCODE_DPAD_DOWN"
21 --> "KEYCODE_DPAD_LEFT"
22 --> "KEYCODE_DPAD_RIGHT"
23 --> "KEYCODE_DPAD_CENTER"
24 --> "KEYCODE_VOLUME_UP"
25 --> "KEYCODE_VOLUME_DOWN"
26 --> "KEYCODE_POWER"
27 --> "KEYCODE_CAMERA"
28 --> "KEYCODE_CLEAR"
29 --> "KEYCODE_A"
30 --> "KEYCODE_B"
31 --> "KEYCODE_C"
32 --> "KEYCODE_D"
33 --> "KEYCODE_E"
34 --> "KEYCODE_F"
35 --> "KEYCODE_G"
36 --> "KEYCODE_H"
37 --> "KEYCODE_I"
38 --> "KEYCODE_J"
39 --> "KEYCODE_K"
40 --> "KEYCODE_L"
41 --> "KEYCODE_M"
42 --> "KEYCODE_N"
43 --> "KEYCODE_O"
44 --> "KEYCODE_P"
45 --> "KEYCODE_Q"
46 --> "KEYCODE_R"
47 --> "KEYCODE_S"
48 --> "KEYCODE_T"
49 --> "KEYCODE_U"
50 --> "KEYCODE_V"
51 --> "KEYCODE_W"
52 --> "KEYCODE_X"
53 --> "KEYCODE_Y"
54 --> "KEYCODE_Z"
55 --> "KEYCODE_COMMA"
56 --> "KEYCODE_PERIOD"
57 --> "KEYCODE_ALT_LEFT"
58 --> "KEYCODE_ALT_RIGHT"
59 --> "KEYCODE_SHIFT_LEFT"
60 --> "KEYCODE_SHIFT_RIGHT"
61 --> "KEYCODE_TAB"
62 --> "KEYCODE_SPACE"
63 --> "KEYCODE_SYM"
64 --> "KEYCODE_EXPLORER"
65 --> "KEYCODE_ENVELOPE"
66 --> "KEYCODE_ENTER"
67 --> "KEYCODE_DEL"
68 --> "KEYCODE_GRAVE"
69 --> "KEYCODE_MINUS"
70 --> "KEYCODE_EQUALS"
71 --> "KEYCODE_LEFT_BRACKET"
72 --> "KEYCODE_RIGHT_BRACKET"
73 --> "KEYCODE_BACKSLASH"
74 --> "KEYCODE_SEMICOLON"
75 --> "KEYCODE_APOSTROPHE"
76 --> "KEYCODE_SLASH"
77 --> "KEYCODE_AT"
78 --> "KEYCODE_NUM"
79 --> "KEYCODE_HEADSETHOOK"
80 --> "KEYCODE_FOCUS"
81 --> "KEYCODE_PLUS"
82 --> "KEYCODE_MENU"
83 --> "KEYCODE_NOTIFICATION"
84 --> "KEYCODE_SEARCH"
85 --> "TAG_LAST_KEYCODE"
Get the battery saver profile STATUS/ENABLE/DISABLE
settings get global low_power
settings put global low_power 1
settings put global low_power 0
Greenify Doze ENABLE/DISABLE
am stopservice com.oasisfeng.greenify/.DozeService
pm disable com.oasisfeng.greenify/.DozeService
/
pm enable com.oasisfeng.greenify/.DozeService
am startservice com.oasisfeng.greenify/.DozeService
Display your battery level, health and temperature (output needs formatting)
dumpsys battery | grep health
dumpsys battery | grep temperature
Store output %Variable
Wi-Fi (scanning always available) on/off
settings put global wifi_scan_always_enabled 1
settings put global wifi_scan_always_enabled 0
Resize the screen and reset
wm overscan 150,750,0,0
wm overscan reset
Query Wi-Fi (scanning always available) status
settings get global wifi_scan_always_enabled
Store output %Variable 
force-enabling doze mode
dumpsys deviceidle force-idle
dumpsys deviceidle unforce
get your network name and data service type (GPRS, EDGE, HSPA etc)
getprop gsm.operator.alpha
getprop gsm.operator.type
WiFi discovery
iw wlan0 scan
Query currently enabled Location providers
settings get secure location_providers_allowed
Store output %Variable
Query enabled Accessibility Services
settings get secure enabled_accessibility_services
Store output %Variable
Query enabled Notification Listeners
settings get secure enabled_notification_listeners
Store output %Variable
Enable an Accessibility Service (AutoInput in my example)
settings get secure enabled_accessibility_services
Store output %Variable 
settings put secure enabled_accessibility_services %Variable:com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility
Enable a Notification Listener (AutoNotification in my example)
settings get secure enabled_notification_listeners
Store output %Variable
settings put secure enabled_notification_listeners %Variable:com.joaomgcd.autonotification/com.joaomgcd.autonotification.service.ServiceNotificationIntercept
Clear Pending notifications
su -c service call notification 1
grab text from an UI application and save it to a file
su -c uiautomator dump --verbose /sdcard/uiautomator_dump--verbose.txt
retrieve my IP address, gateway, DNS info
ip -f inet addr | grep "inet" | grep -v " lo$" && ip route | grep -E "src|default" | sort && getprop | grep "dns.*.[0-9]"

If you have interesting run shell commands, send me an email or let me know via any of the social media, and I will keep this list updated. Thank you!

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?