maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Disable/change alarm sound from python? (https://talk.maemo.org/showthread.php?t=91078)

int_ua 2013-08-20 09:27

Disable/change alarm sound from python?
 
Is it possible to disable or at least change alarm sound from python on Maemo 5?
Here is the code that doesn't work:
Code:

import alarm
from time import time

def set_alarm( message = "alarm"):
    event = alarm.Event()
    event.appid = 'test'
    event.message = message

    event.alarm_time = time() + 1
    event.sound = "/home/user/MyDocs/.sounds/sound.wav"

    action_stop, action_snooze = event.add_actions(2)
    action_stop.label = 'Stop'
    action_stop.flags |= alarm.ACTION_WHEN_RESPONDED | alarm.ACTION_TYPE_NOP
    action_snooze.label = 'Snooze'
    action_snooze.flags |= alarm.ACTION_WHEN_RESPONDED | alarm.ACTION_TYPE_SNOOZE

    cookie = alarm.add_event(event)
    return cookie

set_alarm()

According to C documentation sound can be NULL to disable it but python wrapper demands a string :(

kureyon 2013-08-21 14:58

Re: Disable/change alarm sound from python?
 
Create a silent sound file and point to that when you want to disable alarm?

juiceme 2013-08-21 20:02

Re: Disable/change alarm sound from python?
 
That occured to me also, but wouldn't it be a little too hacky a kludge :D

int_ua 2013-08-22 10:07

Re: Disable/change alarm sound from python?
 
Quote:

Originally Posted by kureyon (Post 1368551)
Create a silent sound file and point to that when you want to disable alarm?

Can you please try the code I've posted? It doesn't change the sound for me.

ade 2013-08-22 11:27

Re: Disable/change alarm sound from python?
 
AFAIK: custom sound per alarm does not work; it is simply ignored and your standard alarm sound is used.

freemangordon 2013-08-22 11:42

Re: Disable/change alarm sound from python?
 
Quote:

Originally Posted by ade (Post 1368681)
AFAIK: custom sound per alarm does not work; it is simply ignored and your standard alarm sound is used.

Confirming, https://gitorious.org/community-ssu/...larm.c#line685

Maybe someone can send a patch :)

ade 2013-08-22 20:04

Re: Disable/change alarm sound from python?
 
Quote:

Originally Posted by freemangordon (Post 1368685)
Confirming, https://gitorious.org/community-ssu/...larm.c#line685

Maybe someone can send a patch :)

Looks like a less-than-an-hour patch for someone like you.

What about you adding some additional code in case a custom sound is set, and I will try to add support for custom per alarm sound in the worldclock replacement. Deal or what ;) ?

freemangordon 2013-08-22 20:35

Re: Disable/change alarm sound from python?
 
Quote:

Originally Posted by ade (Post 1368785)
Looks like a less-than-an-hour patch for someone like you.

What about you adding some additional code in case a custom sound is set, and I will try to add support for custom per alarm sound in the worldclock replacement. Deal or what ;) ?

Deal :).

But I have no time to do it right now, I am chasing some more important bugs in ke-recv. But will do it when I am back to alarmui, anyway there is a bug in it that has to be somehow fixed

Ilmanowar 2015-08-19 17:46

Re: Disable/change alarm sound from python?
 
1 Attachment(s)
Hi guys,
here I reverse engineered the clockd, to disable clock alarms in vacations.
I have a calendar database added to maemo calendar to know local vacations, using informations of this database my script to disable the clock alarm that respond a specific name.
My solution needs of some tuning actions.
First you need to add a work alarm for your specific working days (e.g. Mon-Fry), and to call it with a specific name (e.g. "work alarm") that you will use in the script "tilafestapiccaniresta.sh".
Later you need to see the flag that results activating and deactivating this specific alarm in the file /var/cache/alarmd/alarm_queue.ini:
cat /var/cache/alarmd/alarm_queue.ini|grep -A 6 -B6 -i "work alarm"
The two number you found must be used in the file "change_flag_alarm.sh" (active_flag and deactive_flag).
And finally you need a calendar database file to add holidays to your calendar (this calendar database must contain the word "holidays" in the name).
The script that change the flag of the alarm can send an email by wget query if you create a php site to manage this (working example provided).

PS: It can be some translation error, I rapidly changed the language to English. You need to install sqlite3. You can decide if the entire August is vacations (for those that like me work in academic places).

Enjoy!!!


All times are GMT. The time now is 03:28.

vBulletin® Version 3.8.8