r/tasker • • Jun 03 '25

How To [How To] Utilize Shizuku to run ADB shell commands (without intermediate apps)

53 Upvotes

51 comments sorted by

8

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 03 '25

Now that Shizuku (v13.6.0) can automatically enable itself on boot without root

Wow, this is incredible news, like, really amazing news. If someone reading this doesn't understand why this is important:

Shizuku (if it were properly implemented by João) means that you can use a good chunk of Root Actions in Tasker without Root, on a unmodified device. The biggest pain point was that you needed to do a manual setup every time your phone rebooted, this step is now automatically for Android 13+ devices.

The only thing missing is Tasker implementing it natively so we don't need to redo our projects, but with Shell Action in the method described, we have access to Shizuku.

This is huge: We can have Bluetooth and Wifi-esque actions without Root or Tasker Settings. We can disable and enable apps as well. All while not requiring the user to babysit their phone to enable Shizuku on the current boot

7

u/[deleted] Jun 03 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 03 '25

Ideally João would do a.... Very complicated rewrite and basically flip the logic on Root Actions: they should be ADB actions with the option of using Root instead in the background. And what's left of Root actions would be things that can only be done with Root.

The idea would be that ADB actions could be done through Shizuku or ADB Wifi or whatever. But that's way too much work

1

u/CoooolRaoul Jun 09 '25

How about a simple "use shizuku" option in the "run shell" action, like we have for "use root"?

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 10 '25

This would get messy when sharing projects on the TaskerNet:

I'm a user using Shizuku, so all my projects using Run Shell will have Use Shizuku option. You are a user using Root instead, all your projects are using Use Root instead. Now, if either of us share a project on TaskerNet, the other will have to manually edit it every single Run Shell action to swap the method, this is a lot of manual work and goes against the idea of the TaskerNet being a way for simple users to have access to powerful projects without having to dive into the task creation process.

It is already cumbersome enough that ADB Wifi is pretty much Run Shell with a different skin, and AFAIK you can't easily "swap" the underlying method without changing the action (I actually didn't play with ADB Wifi due to how cumbersome it looks, so I may be talking of my ass)

In an ideal world, the Run Shell Action should try to automatically escalate based on the command:

  1. Locally

  2. ADB Wifi, if Tasker has it

  3. Shizuku

  4. Root

In that order. This way you could just build your project once, and it would work on any setup that has the appropriate privilege required for the command. Way easier to share on the TaskerNet

5

u/eliasacab Jun 03 '25

Been using Shizuku + Rish + Tasker for a couple years and it's been great! Obviously, wish Tasker supported Shizuku natively.

2

u/anuraag488 Jun 03 '25

Whenever i try this there is 50% of times output is stored in error stream when using run shell action.

2

u/berdmayne Jun 03 '25

This is amazing! Great find, thank you for including the steps too

2

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 08 '25

After almost an hour of frustration and almost thinking that Shizuku cannot do pm disable-user, I found out that you NEED to wrap things in single quotes. I've read your tutorial a couple of times and this little bit here:

%AdbShell 'your adb shell command'

made it appear that the quotes are meant to be replaced with your adb shell command, not that your adb shell command needs to be wrapped in quotes. That was it.

2

u/[deleted] Jun 08 '25 edited Jun 08 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 08 '25

Yeah, I figured out due to the example, but as I was trying to pm disable-user and not pm susped I just overlooked it until I needed to follow step by step.

1

u/Lefty_Pencil Jun 03 '25

Christmas in June 🎊

1

u/Scared_Cellist_295 Jun 03 '25

What would happen if I use both the other method AND your method?  Does my device go thermo-nuclear?

2

u/[deleted] Jun 03 '25

[removed] — view removed comment

1

u/Scared_Cellist_295 Jun 03 '25

😆

Unfortunately it's not working for me

chmod failed: ENOENT (No such file or directory)

I'd upload my description but I can never get quote boxes to work on Reddit.

1

u/Lord_Sithek Pixel 9 Pro | Redmi Note 4 | Galaxy Watch 6 Classic Jun 04 '25

Is there anything special to be done to start Shizuku on boot? I'm on A13 without root and I don't see any such option in 13.6.0 nor I can find any documentation except mentioning it on Github release page... And obviously Shizuku doesn't start automatically on boot

1

u/[deleted] Jun 04 '25

[removed] — view removed comment

1

u/Lord_Sithek Pixel 9 Pro | Redmi Note 4 | Galaxy Watch 6 Classic Jun 04 '25

Ye I've seen that but assumed it's not for unrooted. Anyway, it finally started to work, not sure why it didn't at first

1

u/CoooolRaoul Jun 05 '25

On my device the Tasker "copy file" action produce garbage in the destination file. I've also tried as a test to use a destination in a subdirectory of /storage/emulated/0/ and here's what I get : screenshot

1

u/CoooolRaoul Jun 05 '25

I've used "read file" and "write file" instead and now everything works. That's weird

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 08 '25

Yeah, same here u/mylastacntwascursed

3

u/[deleted] Jun 08 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 08 '25

And what about using Run Shell with command cp /path/to/rish /data/data/net.dinglisch.android.taskerm/? Does that work?

Nope, didn't work. The CoooolRaoul method worked tho.

I think it might be easier to share a project on TaskerNet that uses this? Shizuku only exports using a folder, so a Scoped Variable would work without the need for the user to manually select each file

2

u/[deleted] Jun 09 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 09 '25 edited Jun 09 '25

Yes, I've made a basic one, check if it works for you.

Since I'm using read and write file actions, It also automatically edits the rish file before writing, and it enables ADB WiFi on boot in the developer settings (unsure why, but it got disabled on a reboot...?)

Edit: Updated the Project with some examples of what you can do with Shizuku

2

u/[deleted] Jun 10 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 10 '25

Replyign both comments here cause it is easier:

When people talk about enabling ADB WiFi at boot, they usually mean automating the process of running adb tcpip <port> so Tasker can use ADB WiFi functionality, so if it were me, I would change it to USB debugging in the project description, profile name and task name, as that's how the setting is called in Developer Options.

Nice catch, I have a tendency to call it ADB WiFi because it is what it is in a general context, but in Tasker it means a specific thing. Just a correction: It is called Wireless Debugging, USB Debugging requires, well, a USB connection.

Nice touch that you're also including an inactive-by-default Delete action to remove the files! However, it only removes rish_shizuku.dex. You could change it to a Run Shell action with command rm /data/data/net.dinglisch.android.taskerm/rish /data/data/net.dinglisch.android.taskerm/rish_shizuku.dex or add a second Delete action.

Yeah, that wasn't intentional, I left it by mistake because I was trying to see it the project would work from scratch and I already had things set up, but It might be required once Shizuku gets updated. I also don't like to use Run Shell actions unless absolutely necessary, I'd rather keep things "natively" using Tasker language rather than commands because it makes it easier for users to understand what it is doing at a glance.

Anyway, I'm guessing this is a work in progress. I like that you've also included some Examples, as well as the Tasker Permissions that people can now grant through the power of Shizuku. Rock on!

Yeah, I figured people needed to know what is possible with Shizuku because there's a lack of examples, I'm always interested in more ideas.

What I really want to do is a way for Tasker to know if Shizuku is enabled, so that it can wait until it gets enabled before it runs the actions that use it. I have a bunch of actions using Shizuku that I want to use on boot, but since it takes a while for Shizuku to enable itself, those actions results in error.

Another thing I just thought of: make picking the folder the first step in the Setup task instead of incorporating it as a project variable, so that when people need to run the setup again months after importing the project (after a Shizuku update), they get the chance to also pick the folder again, as they may not export rish to the same folder every time.

Yeah, you are right, I love Scoped Variables and used even when it was not the best option, in my defense an scoped variable makes running the task easier to troubleshoot.

I've updated the Project with all your suggestions

1

u/[deleted] Jun 11 '25

[removed] — view removed comment

1

u/EtyareWS Moto G84 - Stock - Long live Shizuku Jun 11 '25

What exactly do you mean with "scoped variables"? Aren't all variables scoped? There's the Global, Project, Profile, Task and Scene scopes that I know of. I don't know how a variable could not "be scoped". Are you using it to mean persistent vs ephemeral maybe?

Project/Profile/Task Variables all work in the same manner, and they are unofficially (at least by me...) called "scoped variables". Aint no way I'm writing Project/Profile Task Variables all the time...

I tried v.03, works great, but when cleaning up afterwards I noticed rish_shizuku.dex doesn't actually get deleted by the delete actions in the Setup task, since %rish_shizuku.dex_exists is not a valid variable name because of the dot character.

Yeah, I forgot whether it works with a dot or not, got lazy to check and used it. It didn't appear to cause any issue, so I assumed it worked. My bad

You could use that as a clear indication that Shizuku is not running and keep retrying until it is. Or have one test Task that does this and sets a variable shizuku_enabled to true once it succeeds, and include shizuku_enabled ~ true as a condition in the profiles that require it.

The issue is that there's no easy way of checking it itself. If there was a command that we could issue to Shizuku itself to know if it is working and then store that into a variable, we would have a way of putting every Shizuku action on a buffer of sorts until it enables itself

There are countless things you can do, but here's one I used recently:

cmd wifi status | grep "Wifi is connected to" | cut -d " -f 2

It retrieves the current wifi name/SSID without needing to have location enabled. I use it to set a global variable %SSID which I can then use in conditions in profiles and tasks. (I'm privacy-minded and have location disabled by default.)

I've also used adb shell to replicate the functionality of Tasker actions that didn't work, e.g. for collapsing Quick Settings after tapping a custom Tasker/AutoNotification tile:

cmd statusbar collapse

Very useful to work around Tasker bugs and limitations!

I could go on...

I'm more interested in "Action-Actions", I.e. "Do Stuff", not "Get Action", they are useful, but have less "wow factor", specially if you can already do it without Shizuku. Plus, I'm re-refactoring my Project to use commands, my idea is that rather than using the commands itself as in the example task, you would signal a command in a task to trigger my project. This way in the future I can figure out how to add a buffer of sorts

You are right that WD is disabled on boot. Shizuku does/can enable it by itself though, but then it fails to connect to it (you can see this by stopping Shizuku and disabling WD and then tapping Start in Shizuku; it fails but now WD is enabled and when you tap Start another time it succeeds). So it helps if you can make Tasker enable WD before Shizuku starts to work around this bug in Shizuku, sure. But alas most of the time this didn't work in the testing I did yesterday, as a lot happens after boot and we have no influence on the order in which things start.

As of yet, I'm not so impressed with Shizuku's ability to "automatically enable itself on boot without root" as I wrote in the main post after succesfully testing it once. Yesterday I rebooted many times and it failed most of the time.

I'll stick to Tasker with Termux to enable WD, detect the random port, connect and run adb tcpip 5555, disable WD, then use ADB WiFi to start the Shizuku service. Works like a charm and using ADB WiFi in Tasker has none of the downsides of Shizuku (which I use for other apps).

Well, based on the description, I think the issue is that Shizuku right now can't both enable WD AND Enable itself. Probably some quirky that will take care of itself.

I've updated the Project, check it out. It now prevents you from cleaning %AppData (made this mistake then wondered why nothing works...) and sets it on boot to prevent some edge case, the Project also reacts to commands in the following way: shizuku=:=type=:=action=:=app_package

  • type can be: bluetooth, mobiledata, wifi and app

  • action can be: enable and disable

  • app_package is only used for the app type, and it needs, you guessed, the app package. It has a failsafe to prevent you from messing with Tasker and Shizuku, but haven't tested if it works.

→ More replies (0)

1

u/mensageirodedeus Jun 10 '25

Poderia fazer um vídeo 

1

u/Scared_Cellist_295 Jun 11 '25

This is so frustrating that it will not work on my Pixel 8a. Ugh

1

u/Scared_Cellist_295 Jun 12 '25

Nevermind. It's working now!

1

u/Frostybear3736126 Jul 21 '25

I'm having issue with getting this working, scratching my head here.

I have rish files exported to Downloads/Shizuku directory.

Imported the project from tasker. Ran the setup task no problem, can see it changed the PKG in the rish file appropriately and set the %AdbShell variable.

None of the examples work and I'm not sure why.

Here's output of the Bluetooth On example command:

15.58.37/Variables doreplresult: |%AdbShell 'svc bluetooth enable'| -> |sh /data/data/net.dinglisch.android.taskerm/rish -c 'svc bluetooth enable'|
15.58.37/Variables doreplresult: |%AdbShell 'svc bluetooth enable'| -> |sh /data/data/net.dinglisch.android.taskerm/rish -c 'svc bluetooth enable'|
15.58.37/E Run Shell:  ->
15.58.37/E Run Shell:  ->
15.58.37/E Run Shell:  ->
15.58.37/Shell runBackground sh /data/data/net.dinglisch.android.taskerm/rish -c 'svc bluetooth enable' root: false timeout: -1
15.58.37/Shell start process-thread ID 266
15.58.37/E add wait task
15.58.38/E Error: 1 

I really just want to start the shizuku server on boot, using the following command (taken from start via computer):
%AdbShell '/data/app/~~0O9oC1Vyl7bDBKevBiipZQ==/moe.shizuku.privileged.api-gmGz1beNb7AIUykdkPWNtg==/lib/arm64/libshizuku.so'

Any help greatly appreciated

1

u/[deleted] Jul 21 '25

[removed] — view removed comment

1

u/Frostybear3736126 Jul 21 '25

Thanks for the response. Start on boot doesn't work for me, no idea why. Ive a pixel 8a and everyone else with same phone says it works.

I'm using shizuku with delta automated via tasker to turn on/off wireless hotspot when I get in and out of my car (so I won't have WiFi most of the time). Was working before just via tasker but an android security update killed it.

I'll have to investigate the other options you mention.

1

u/Coolbicbic Apr 01 '26

What’s the process in using a bot to get information out of Vale private and Instagram?

1

u/TrumpetsInMyAss Apr 22 '26

Hello. Thanks for this! However the taskernet link is not working anymore. Can you please update it?

2

u/[deleted] Jun 04 '25

[removed] — view removed comment

1

u/Lord_Sithek Pixel 9 Pro | Redmi Note 4 | Galaxy Watch 6 Classic Jun 04 '25

I'm not sure and I don't think so, but you can do this with this project

I'm testing the method with Shizuku only but I suppose I stay with the ADB WiFi mostly. Mainly because Tasker allows to check ADB WiFi state and it's not the case with Shizuku

1

u/[deleted] Jun 04 '25

[removed] — view removed comment

1

u/Lord_Sithek Pixel 9 Pro | Redmi Note 4 | Galaxy Watch 6 Classic Jun 04 '25

Wierd, it basically always click in right away for me... Maybe try to increase number of passes in action no. 21 of the Enable ADB WiFi task. Also I disabled actions no. 2 and 3 as I concluded they're unnecessary