Need updated Shell script for alarm deletion please.

176 views
Skip to first unread message

Logan Fury

unread,
May 15, 2017, 9:20:27 AM5/15/17
to Tasker
Good Morning all,

I web researched and found this page here at the forums: https://groups.google.com/forum/#!topic/tasker/M5_-7cB4TaM

It presented code that deleted alarms from the stock alarm clock. This code no longer works. I posted to the thread to ask if anyone had updated code, but the thread resisted a necro. Please forgive me for double posting but I really want an answer to this and the orig thread authors may not even be tasker users any longer for all I know.

This is the code in question, to be performed from use root enabled Run Shell:

sqlite3 /data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm'

This was presented as KitKat version of above:

sqlite3 /data/data/com.android.deskclock/databases/alarms.db 'UPDATE alarm_templates SET delete_after_use=1'

neither of these work on my Lollipop 5.1.1 rooted platform.

looking at the code with as much logic as a new student to this could muster, I determined that "com.sec.android.app.clockpackage" is the package name for the default clock, and confirmed that it is still the valid package name for my phone's clock.

With this realization, I replaced that section with the package name for my preferred clock, Smart Alarm:

sqlite3 /data/data/jp.tanyu.SmartAlarm/databases/alarm.db 'DELETE FROM alarm'

This gives the error:

06.13.14/E Run Shell:  -> 
06.13.14/E Run Shell:  -> 
06.13.14/E Run Shell:  -> 
06.13.14/Shell runBackground sqlite3 /data/data/jp.tanyu.SmartAlarm/databases/alarm.db 'DELETE FROM alarm' root: true timeout: -1
06.13.14/Shell start process-thread ID 8480
06.13.14/E add wait type Shell1 time 2147483647
06.13.14/E add wait type Shell1 done
06.13.14/E add wait task
06.13.14/E Error: 127

Making sure to have an enabled alarm in stock and running the script for stock alarm gives this error:

06.16.19/E Run Shell:  -> 
06.16.19/E Run Shell:  -> 
06.16.19/E Run Shell:  -> 
06.16.19/Shell runBackground sqlite3 /data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm' root: true timeout: -1
06.16.19/Shell start process-thread ID 8485
06.16.19/E add wait type Shell1 time 2147483647
06.16.19/E add wait type Shell1 done
06.16.19/E add wait task
06.16.19/E Error: 127

If this worked in 2013/14 im sure it could work now with tweaking but ive no coding knowledge with which to do so. Could any of our experienced shell coders please lend a hand if youve time? Id be ecstatic with a working script for either clock app to utilize in tasks.

Thank you very much for reading,

Logan


George Boyce

unread,
May 15, 2017, 12:28:17 PM5/15/17
to Tasker
Not all programs save their data in a SQLite database (.db file), Logan.

You may find Smart Alarm saves its data in an XML file, not a .db file.

Logan Fury

unread,
May 15, 2017, 6:18:22 PM5/15/17
to tas...@googlegroups.com
I see what you're saying George, so my placing Smart Alarm's package into the script was just a shot in the dark with no idea of their data protocol.

Is it probable that the stock alarm using the same package name from the time of this script origin has kept the same .db coding with just a slight semantic change thats rendered this script inoperable?

If anyone can look into the coding of stock Clock and discover how to re-enable the previously working script that would be amazing. Just having control of alarm deletion is what im chasing, im more than happy to use any successful version of this for any clock app. I installed Gentle Alarm to see how it worked with Tasker, but it has a disable, not a delete, for alarm.

On Mon, May 15, 2017 at 9:28 AM, George Boyce <ceria...@gmail.com> wrote:
Not all programs save their data in a SQLite database (.db file), Logan.

You may find Smart Alarm saves its data in an XML file, not a .db file.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/D1oZbCr9ijY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

George Boyce

unread,
May 15, 2017, 8:04:02 PM5/15/17
to Tasker
To be horribly blunt, yes! (sorry)

You have said you have confirmed this is the package name of your clock app:
com.sec.android.app.clockpackage.

Check
in the Root of your file system for this folder: /data/data/com.sec.android.app.clockpackage/databases?

If it exists, is there a .db file inside? If so, what's it called?
It may be called alarm.db. We can go from there if there is a .db file there?.

Can you also confirm what Android OS you are using. :)

On Monday, 15 May 2017 23:18:22 UTC+1, Logan Fury wrote:
... so my placing Smart Alarm's package into the script was just a shot in the dark with no idea of their data protocol.

Logan Fury

unread,
May 15, 2017, 8:09:38 PM5/15/17
to tas...@googlegroups.com
Hello George,

Wonderful to have your help! 

Im on a Lollipop 5.1.1 rooted platform.

Ive just navigated to the instructed dir and I do see alarm.db

--

Logan Fury

unread,
May 15, 2017, 8:11:07 PM5/15/17
to tas...@googlegroups.com
There is also:

alarm.db-journal

Scott Miller

unread,
May 15, 2017, 8:28:33 PM5/15/17
to tas...@googlegroups.com
I don't mean to discourage you from learning how to do this with sql, but have you looked at this plugin for Tasker?


There is also:

alarm.db-journal
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+unsubscribe@googlegroups.com.

Logan Fury

unread,
May 15, 2017, 8:31:36 PM5/15/17
to tas...@googlegroups.com
Hi Scott,

that plugin is unfamiliar to me but ill certainly check it out, thank you.

I do definitely want to see the sql solution as well, I need to learn all I get the opportunity to!

George Boyce

unread,
May 15, 2017, 8:44:20 PM5/15/17
to Tasker
Hi Logan,

The above command you quoted is the correct command: sqlite3 /data/data/com.sec.android.
app.clockpackage/databases/alarm.db 'DELETE FROM alarm' - (don't forget to check 'use root'). You are aware this command removes ALL alarms, aren't you?

Hi Scott, I was going to get around to plugins, mate. :)

Logan, you could look at the plugin Scott mentions, but if you really want to do this with SQL, you can do so very easily in Tasker using this excellent, free plugin: https://play.google.com/store/apps/details?id=com.jordanhotmann.taskersqliteplugin&hl=en (it requires root, of course)

Good thing about this plugin is, you just put filename in the first box, and SQL query in the next box. You're smart; you'll figure it out.

Logan Fury

unread,
May 15, 2017, 8:50:29 PM5/15/17
to tas...@googlegroups.com
I wonder why that command isnt working when I execute it. I did make sure the shell had root checked.

Ill try this again using the sqlite plugin. Filename in the first box is the only thing that doesnt immediately make sense to me, but ill check out the documentation.

Thank you very much :)

--

George Boyce

unread,
May 15, 2017, 8:53:30 PM5/15/17
to Tasker
Logan, I meant to add, SQL is very powerful: one slip and you can lose a lot of/all of your data! Don't be tempted to "just try stuff" without backups!

Tread very carefully!

Read, read, read!

Logan Fury

unread,
May 15, 2017, 9:01:14 PM5/15/17
to tas...@googlegroups.com
Thank you for that warning!

All im trying to do atm, is have the ability to create up to 4 alarms, using hour and min variables (%SUNRISE1, %SUNRISE2, %SUNSET1 etc) for dawn, dusk, sunset, and sunrise, and the ability to delete any of these.

ClockTask doesn't seem to want to accept custom variables for hour/min so that may stop me dead in the water right there for that route. Im going to keep playing with it and see what I can do.

Last time I put a test alarm in default clock and ran the shell script it had no effect on the alarm. Ill give my phone a reboot and try that one more time to make certain its just not playing nice on my phone. Without knowing what to put in the first field (I think it was called path?) im very hesitant to do anything with sql lite.

--

Logan Fury

unread,
May 15, 2017, 9:21:18 PM5/15/17
to tas...@googlegroups.com
I rebooted the Lollipop and still the same error, I tried it on Marshmallow phone as well and same thing.

dont see why the correct syntax sql command would fail on both phones >.<

George Boyce

unread,
May 15, 2017, 9:32:26 PM5/15/17
to Tasker
Why can't you just use the Set Alarm action in Tasker to set your alarms? It's under System.

Is it because %SUNRISE1, %SUNRISE2, etc. are in the format hh:mm? You could split each on the ':' and set your alarms in Tasker using %SUNRISE11 for hour, %SUNRISE12 for minutes... and so on.

As for the SQL command, you've got me there; that should work. Try the plugin:

In the first area (Database Path) put your file path, i.e. /data/data/com.sec.android.app.clockpackage/databases/alarm.db
In the second area (SQL Statement) put your SQL query, i.e. DELETE FROM alarm
Click the FAB (circle with the tick)
Run the task.
Profit!

Logan Fury

unread,
May 15, 2017, 9:34:47 PM5/15/17
to tas...@googlegroups.com
Thank you George, ill try that in the plugin now.

That is exactly how ive been setting the alarms, Set Alarm works flawless to set my variables and I can choose to send them to default or the Smart Alarm clock. The brick wall came when I wanted to be able to control/delete them after creation.

--

Logan Fury

unread,
May 15, 2017, 9:40:06 PM5/15/17
to tas...@googlegroups.com
George, does the SQL Statement need to be surrounded with single quote marks as in the code for shell, or do those become unnecessary in this plugin?

Logan Fury

unread,
May 15, 2017, 9:41:45 PM5/15/17
to tas...@googlegroups.com
never mind sorry, I entered without the quotes, hit the FAB and the configuration shows the quote marks automatically added. I think im good to fire it. 

Please hold onto anything solid.

George Boyce

unread,
May 15, 2017, 9:43:00 PM5/15/17
to Tasker
Quotes not required.

Logan Fury

unread,
May 15, 2017, 9:43:44 PM5/15/17
to tas...@googlegroups.com
Heres what im firing:

Del Wea Alarm (440)
A1: Tasker SQLite Plugin [ Configuration:%dbreturn: The data returned from your sql statement
%dbrows(): An array of rows returned from your sql statment
%dbreturncount: The number of rows returned
%dbcolumnname(): An array of values for each column (replace columnname with the actual column name)
%dberr: The error message (if any)

SQLite command: sqlite data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm ' Timeout (Seconds):10 ] 
A2: Flash [ Text:Check clock Long:On ] 
A3: Launch App [ App:Clock Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]

Logan Fury

unread,
May 15, 2017, 9:47:19 PM5/15/17
to tas...@googlegroups.com
Just exited Tasker, checked that I had a test alarm ready to go, and when I relaunched tasker I saw this:

Inline image 1

I havent actually fired the task yet, is any of this cause for worry?

George Boyce

unread,
May 15, 2017, 9:50:12 PM5/15/17
to Tasker
This ---> data/data/com.sec.android.app.clockpackage/databases/alarm.db needs an opening /.

It needs to be:
/data/data/com.sec.android.app.clockpackage/databases/alarm.db

Logan Fury

unread,
May 15, 2017, 9:53:32 PM5/15/17
to tas...@googlegroups.com
Thank you so much for being here George!

On Mon, May 15, 2017 at 6:50 PM, George Boyce <ceria...@gmail.com> wrote:
This ---> data/data/com.sec.android.app.clockpackage/databases/alarm.db needs an opening /.

It needs to be:
/data/data/com.sec.android.app.clockpackage/databases/alarm.db

--

George Boyce

unread,
May 15, 2017, 9:56:43 PM5/15/17
to Tasker
Almost 3am here. :)

Logan Fury

unread,
May 15, 2017, 9:57:22 PM5/15/17
to tas...@googlegroups.com
It Worked :)

final question, is there any additional data that can be added to this command to recognize a specific alarm based on its Label?

Logan Fury

unread,
May 15, 2017, 9:59:45 PM5/15/17
to tas...@googlegroups.com
So sorry to keep you up! Task fired, worked like a charm, any experimentation with specific deletion if possible can certainly wait for a more likely time when you feel like giving assistance.

Thank you so very much for seeing this thru to the firing of the task and protecting my system, that means a lot!

--

George Boyce

unread,
May 15, 2017, 10:21:56 PM5/15/17
to Tasker
That depends on the layout of the tables in the alarm.db. You would need a WHERE clause in your SQL statement. Something like DELETE FROM ALARM WHERE label = 'labelname'.

That assumes the label column is actually called label, if you follow me.

To see inside the alarm.db go get yourself a free program called SQLite Debugger (it's not on the Play Store, try a Google Search; you should find it on one of the apk mirror type sites). Last version was SQLite Debugger 1.6.17 (it requires root, of course).

Once it's installed, open it, click on 'App' and it will list all the Apps it finds with a .db file. You are looking for your Clock app obviously.
The main table containing your alarms is probably called 'alarm' or 'alarms'.
Tapping that will show how the table is laid out.
It will also insert a SQL statement in the line above the tables - something like "SELECT * FROM alarms".
Clicking the run arrow (top right) will show the results of the query.
Swipe left and right to see all the colums.
From those results you should be able to work out the alarm label names (set a couple of alarms; call them Stan & Ollie to make them easy to find).

Once you know the column with the alarm label name/s, you can then change your statement in the plugin to
DELETE FROM ALARM WHERE label = Stan', etc.

By the time I return tomorrow, you'll have it all sussed. Thus endeth the lesson!

Finally, you haven't kept me up; it's been my pleasure. :)

Logan Fury

unread,
May 15, 2017, 10:24:53 PM5/15/17
to tas...@googlegroups.com
Sleep well when you get there :)

George Boyce

unread,
May 15, 2017, 10:25:26 PM5/15/17
to Tasker
Oops! Missed a line.

Should be line after this one here: "Once it's installed, open it, click on 'App' and it will list all the Apps it finds with a .db file. You are looking for your Clock app obviously."

I should have added, "You want to choose the alarm.db file to open."

Logan Fury

unread,
May 15, 2017, 11:07:03 PM5/15/17
to tas...@googlegroups.com
George whenever you get back to the thread here is where im at. 

Ive made two named alarms "Logan" and "Fury" (out of pure narcissism).

SQLite Debugger 1.6.17 worked like a charm, detected and was granted root permissions. The columns I found my alarms in was named NAME. (all fields were all capitols)

I used the following:

Del Named Alarm (512)

A1: Tasker SQLite Plugin [ Configuration:%dbreturn: The data returned from your sql statement
%dbrows(): An array of rows returned from your sql statment
%dbreturncount: The number of rows returned
%dbcolumnname(): An array of values for each column (replace columnname with the actual column name)
%dberr: The error message (if any)

SQLite command: sqlite /data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm WHERE Name = Fury' Timeout (Seconds):10 ] 

A2: Flash [ Text:Check clock Long:On ] 
A3: Launch App [ App:Clock Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]

I tried this, WHERE NAME = and WHERE name =

all three variants failed to do anything. no error codes, the script ran to end and displayed the clock, but unlike before the edit, the clock is still populated with the two alarms.

Is there any different syntax I could try?

--

Logan Fury

unread,
May 15, 2017, 11:10:25 PM5/15/17
to tas...@googlegroups.com
im looking at this and wondering if 

WHERE %dbNAME = Fury

would be valid. Im a bit afraid to run it without consulting with the experts first however!

George Boyce

unread,
May 16, 2017, 9:42:42 AM5/16/17
to Tasker
Your quotes are in the wrong place; the SQL Statement you enter into the plugin should simply be: DELETE FROM ALARM WHERE NAME = 'Fury' (This assumes ALARM is the name of the table, and NAME is the name of the column containg the alarm names/labels.)  Tip: for the moment keep your stuff case-sensitive.

You said:"im looking at this and wondering if 

WHERE %dbNAME = Fury"

No, because the column names in the database are fixed; you can't change them (well, you can, but you'll break stuff). As I said earlier SQL = Power - Do Not Guess! I cannot stress this point enough; especially to someone new at it. :)

Later, when you start asking Tasker to do this selective deleting is when you will use variable names, e.g. DELETE FROM ALARM WHERE NAME = '%alarmname'

I'm off to work, (late shift). I'll pop in tonight to see how you are going along.


On Tuesday, 16 May 2017 04:07:03 UTC+1, Logan Fury wrote:
George whenever you get back to the thread here is where im at. 

<snip>

SQLite command: sqlite /data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm WHERE Name = Fury' Timeout (Seconds):10 ] 
<snip>

Logan Fury

unread,
May 16, 2017, 4:43:07 PM5/16/17
to tas...@googlegroups.com
Hello George,

I hope you had a great day at work. 

Your instructions were flawless, the changing of Fury to 'Fury' generated a few different error messages on Launching tasker, but theres been mention of SQL lite on every launch since creating the first task. I put the single quotations around Fury and that individual alarm was cleanly stripped from the list of two alarms.

Here is the working script for anyone following the thread. Note that I entered 'Fury' and the script places its own opening and closing single quote marks around this statement, making it appear to be 'Fury":

Del Named Alarm (512)
A1: Tasker SQLite Plugin [ Configuration:%dbreturn: The data returned from your sql statement
%dbrows(): An array of rows returned from your sql statment
%dbreturncount: The number of rows returned
%dbcolumnname(): An array of values for each column (replace columnname with the actual column name)
%dberr: The error message (if any)

SQLite command: sqlite /data/data/com.sec.android.app.clockpackage/databases/alarm.db 'DELETE FROM alarm WHERE Name = 'Fury'' Timeout (Seconds):10 ] 
A2: Launch App [ App:Clock Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]

This is amazing, I can now have full control of the creation and deletion of Dawn, Sunrise, Sunset, and Dusk alarms, or anything else similar that occurs to me in the future.

Thank you so much for the precious time and assistance George, we can call this thread successfully closed :)

--

George Boyce

unread,
May 16, 2017, 6:26:40 PM5/16/17
to Tasker
Hi Logan, Glad you've got it going; I was glad to help.

About the messages you mentioned in your post, i.e. "...but theres been mention of SQL lite on every launch since creating the first task." I can't imagine they are error messages if all is working.

Aren't you just seeing the toasts from your root app (I assume SuperSU) telling you that the plugin has been granted root privileges? If that's what you're seeing, go into your root app and turn off toasts if it troubles you.

Things to do; I'll check back on your progress tomorrow sometime.

On Tuesday, 16 May 2017 21:43:07 UTC+1, Logan Fury wrote:
...but theres been mention of SQL lite on every launch since creating the first task.

Logan Fury

unread,
May 16, 2017, 6:36:39 PM5/16/17
to tas...@googlegroups.com
"I can't imagine they are error messages if all is working."

I agree its perplexing, and the script is definitely working. I think this may be something that broke in my install of Tasker. I was getting an error message about a bad color code from a web project I imported. I used the search feature to eliminate or edit every element containing that reference, and search fails to find any more instances of it, but my Tasker still tries to tell me that bad variable is present. It seems older error messages are failing to clear from its memory.

Would a backup, uninstall reinstall and restore deal with this? Or would the restore just carry over the problem?

--

Logan Fury

unread,
May 16, 2017, 10:11:32 PM5/16/17
to tas...@googlegroups.com
the result of all this: Inline image 2

probably worthless to all but insomniacs and vampires but it was very fun to create.

Logan Fury

unread,
May 17, 2017, 3:23:38 AM5/17/17
to tas...@googlegroups.com
Ive done additions to the button functions. Now any of the 4 set buttons set the alarm, then add 5 mins to the minutes variable, assign that and the hour variable to a new auto delete alarm variable, and turn on a profile set to that variable as a launch time, which then launches a task to delete the alarm in question automatically 5 mins after its fired.

Ive finished the coding, punched the Dawn button, and am now waiting out the 5+ hours for its first live run test.

How do I export coding in the Tap section of Scene buttons to be shared here? I exported Scene as discription in email but all I got was the construction of the scene info, none of the button scripting.

Logan Fury

unread,
May 17, 2017, 4:33:02 AM5/17/17
to tas...@googlegroups.com
George, here is a capture of those sql related errors im receiving. This displays despite everything working perfectly:
Inline image 2

none of these look particularly serious, but they persist in popping up every few launches of Tasker. Your opinion please?
Message has been deleted

Logan Fury

unread,
May 17, 2017, 9:00:47 AM5/17/17
to tas...@googlegroups.com
Will do. As there is no smoke coming out of the phone I wont panic until Ive reached out and heard back from Pent.

My profile setup worked and auto-deleted the Dawn alarm :)

On Wed, May 17, 2017 at 5:57 AM, George Boyce <ceria...@gmail.com> wrote:
I've got no idea what those errors mean. UIn my experience only devs can make any sense of log files/error messages.

You'd be better asking Pent directly, especially if they are popping up frequently.

George Boyce

unread,
May 17, 2017, 9:03:22 AM5/17/17
to Tasker
Ignore my now deleted reply. Just realised what it is you're seeing.

Go into your Tasker prefrences and turn off "Popup Errors/Warnings" in the Misc tab.

Logan Fury

unread,
May 17, 2017, 9:05:06 AM5/17/17
to tas...@googlegroups.com
can do!

On Wed, May 17, 2017 at 6:03 AM, George Boyce <ceria...@gmail.com> wrote:
Ignore my now deleted reply. Just realised what it is you're seeing.

Go into your Tasker prefrences and turn off "Popup Errors/Warnings" in the Misc tab.

--
Reply all
Reply to author
Forward
0 new messages