View Full Version : Automatic Muting via cron
cybergypsy
06-13-2008, 04:31 PM
I'd like to use cron to automatically mute the volume of my OS2008 N800 every night and unmute it again in the morning , is this possible ?
thanks
maillaxa
06-13-2008, 05:22 PM
In short: yes :)
cybergypsy
06-14-2008, 04:12 AM
Thanks maillaxa, thats great!
For anyone else who would like to get this working , here is what I have done.
I set all this up via SSH on my desktop rather than the built-in terminal, this allows easy copy & paste as well as file transfers via secure copy (scp)
Installed the aumix-gtk applcation from the repositories.
Installed the cron package from this thread (http://www.internettablettalk.com/forums/showthread.php?t=12572).
As root created a crontab containing :-
30 23 * * * aumix -w 0
00 7 * * * aumix -w 90
This mutes the tablet at 11:30pm and un-mutes it at 07:00am
Either reboot or run cron from the command line.
Good Luck
cybergypsy
maillaxa
06-14-2008, 11:31 AM
You should put this onto the wiki, I guess.
Bravo !
alephito
06-20-2008, 08:23 AM
Thanks, Cybergypsy.
My first contact with Linux was with my N810 and managing to set a crontab to mute and un-mute the device was really entertaining.
What other uses you have for cron?
aNoble
06-20-2008, 08:50 AM
I wonder if it would be possible to do something similar to this for the indicator light. I sometimes wake up to an annoying flashing blue light in the middle of the night when I receive an email.
cybergypsy
06-20-2008, 08:53 AM
I have turned off the LED notifications :-
Settings > Control Panel > Display > LEDs
....and sleep easy.
alephito
06-20-2008, 09:22 AM
I wonder if it would be possible to do something similar to this for the indicator light. I sometimes wake up to an annoying flashing blue light in the middle of the night when I receive an email.
Yes! That would be great.
BoxOfSnoo
06-20-2008, 10:38 AM
I already clicked it, but THANK YOU! (the automated ones are a little cheap)
I was envisioning that this would be an ideal task for a linux handheld, just never got to test it and list it out so directly.
I have also set it to mute for regularly scheduled meetings I have.
qwerty12
06-20-2008, 11:06 AM
I wonder if it would be possible to do something similar to this for the indicator light. I sometimes wake up to an annoying flashing blue light in the middle of the night when I receive an email.
Well, yes it can be done.
Make cron run gconftool which turns off the LED value (not sure on specifics but I know for SURE that the LED's are controlled via gconf)
aNoble
06-20-2008, 11:06 AM
I have turned off the LED notifications :-
Settings > Control Panel > Display > LEDs
....and sleep easy.
Yea, but I really like having the LED notifications during the day. And I'd rather not have to turn them on and off every night/morning.
alephito
06-20-2008, 11:58 AM
Maybe this thread (http://www.internettablettalk.com/forums/showthread.php?t=15467) can be of help.
qwerty12
06-20-2008, 12:56 PM
Here is a rip of cybergypsy's brilliant instructions but to do something else.
Putting the following into crontab should in theory put the tablet into offline mode at 11:30 PM and take it out at 7:00 AM.
Well, the dbus commands work as I spent 30 mins figuring them out but I don't know if cron will use them :p (you also may need to do dbus-uuidgen --ensure=/var/lib/dbus/machine-id as root)
30 23 * * * /usr/bin/dbus-send --system --type=signal /com/nokia/mce/signal com.nokia.mce.signal.sig_device_mode_ind string:"flight"
00 7 * * * /usr/bin/dbus-send --system --type=signal /com/nokia/mce/signal com.nokia.mce.signal.sig_device_mode_ind string:"normal"
aNoble
06-20-2008, 02:07 PM
Thanks for all of the great advice and I'm definitely going to see if I can the LED situation improved through cron.
But I was thinking what might possibly be an even better solution would be turn dim the LED based on the light sensor. So the darker it is the dimmer the LED gets. Because the LED tends to fade in and out at times I assume that it's able to be dimmed.
I'm a web developer so I don't have a lot of experience in programming at this level or in most of the languages typically used in Maemo. But if somebody can point me in the right direction I'd be happy to attempt to write something to do this sort of thing. Right now it's looking like I'll have to do my homework on DBUS and maybe Python. I'm comfortable with C# so maybe Vala would be better for me than Python?
Benson
06-20-2008, 02:32 PM
That's quite interesting; it's a good idea, and possible from a hardware perspective, but I doubt it's readily doable right now. Support should exist for an overall brightness control in mce, and I'm pretty sure it doesn't exist now. Alternatively, all LED patterns could be scaled and resubmitted, but I'm not sure whether there's a clean way to apply such changes. That's an inferior solution, anyway; if filing feature requests, the former is what you really want.
alephito
06-21-2008, 01:37 PM
Is there any way to set special hours for weekends?
For instance:
00 7 * * 1,2,3,4,5 aumix -w 90
00 10 * * 0,6 aumix -w 90
Is this valid if I want to sleep longer on Saturdays and Sundays?
alephito
06-21-2008, 08:01 PM
Yea, but I really like having the LED notifications during the day. And I'd rather not have to turn them on and off every night/morning.
I turned the "Device on" option off and left all the other options on.
This has stopped the device flashing the blue LED to indicate that the device is switched on when the display is in power save mode.
Now, with cron muting and switching to offline mode, there is no possible sound and LED use by night. Great.
alephito
06-24-2008, 11:35 AM
After upgrading to Diablo I am trying to install cron again.
After running 'tar zxvvf cron.tar.gz', I execute './cron/INSTALL' (as root) but the output is '/bin/sh: ./cron/INSTALL: Permission denied'.
What am I doing wrong? I don't remember if I had this problem the first time.
qwerty12
06-24-2008, 11:41 AM
I think you need to make sure you are root and make sure that the INSTALL script is set as executable.
alephito
06-24-2008, 12:39 PM
I am sure I am root (I see the # in the command line) and I run tar with the 'zxvvf' parameters. How can I check if the script is set as executable?
Thanks maillaxa, thats great!
For anyone else who would like to get this working , here is what I have done.
I set all this up via SSH on my desktop rather than the built-in terminal, this allows easy copy & paste as well as file transfers via secure copy (scp)
Installed the aumix-gtk applcation from the repositories.
Installed the cron package from this thread (http://www.internettablettalk.com/forums/showthread.php?t=12572).
As root created a crontab containing :-
30 23 * * * aumix -w 0
00 7 * * * aumix -w 90
This mutes the tablet at 11:30pm and un-mutes it at 07:00am
Either reboot or run cron from the command line.
Good Luck
cybergypsy
Can you tell a little more please?
As root, I installed cron, and run crontab -e .. I entered something similar, " 30 23 * * * mplayer file.mp3 " but nothing happens at 23:30... I tried to edit /etc/crontab.. nothing happened
thx
cybergypsy
06-24-2008, 03:59 PM
you might need to specify the path to the .mp3 file as the command will be running as root and not as user.
I don't think the crontab files are stored in /etc , I think they're in /var somewhere but I can't check at the moment as I don't have it all installed currently due to the diablo upgrade this afternoon.
alephito
06-24-2008, 04:51 PM
The crontab files are stored in /tmp.
alephito
06-24-2008, 05:06 PM
I am sure I am root (I see the # in the command line) and I run tar with the 'zxvvf' parameters. How can I check if the script is set as executable?
EDIT: Where should I be positioned to untar the files? If I am in the root directory (/root) the permissions are well assigned (but ./cron/INSTALL fails for other reason). The problem happened standing in mmc1.
Now, I get this when I execute ./cron/INSTALL:
~# ./cron/INSTALL
./cron/INSTALL: line 3: ./UNINSTALL: not found
cp: omitting directory './cron'
cp: cannot stat './crontab': No such file or directory
chmod: /usr/bin/cron: No such file or directory
chmod: /usr/bin/crontab: No such file or directory
ln: /etc/rc2.d/S89cron: File exists
alephito
06-24-2008, 06:52 PM
I solved doing this:
cd /root/cron
./INSTALL
Why './cron/INSTALL' did not work to begin?
Benson
06-24-2008, 10:57 PM
Because it was looking for ./UNINSTALL, not ./cron/UNINSTALL, and so on.
The crontab files are stored in /tmp.
actually it seems to be in /var (chinook)
Anyway.. doesn't work for me >o<
# more /var/cron/tabs/root gives me
===========
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.3312 installed on Wed Jun 25 13:33:30 2008)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
35 13 * * * /usr/sbin/reboot
===========
which i created with crontab, as root.
But no reboot at 13H35.. Is my command ok?
I think cron is running since it shows with ps -aux | grep cron
I'm puzzled
qwerty12
06-25-2008, 01:47 AM
Can you tell a little more please?
As root, I installed cron, and run crontab -e .. I entered something similar, " 30 23 * * * mplayer file.mp3 " but nothing happens at 23:30... I tried to edit /etc/crontab.. nothing happened
thx
" 30 23 * * * run-standalone.sh mplayer file.mp3 "
Mplayer sends a dbus command along the line. cron runs as root. dbus and root don't go so well on tablets hence the run-standalone.sh.
" 30 23 * * * run-standalone.sh mplayer file.mp3 "
Mplayer sends a dbus command along the line. cron runs as root. dbus and root don't go so well on tablets hence the run-standalone.sh.
Nope, doesn't work for me... mplayer or anything else, run-standalone.sh or not... Nothing never happens :mad:
What am I doing wrong???
Recap :
1- on my n810, downloaded the package from the thread "cron has gone".. cron.tar.gz (.zip)
2- as root, used the INSTALL script
3 - rebooted, checked with ps -aux | grep cron... which gives me
1220 root 1548 SW /etc/rc2.d/S89cron start
4 - as root, crontab -e, added the line
30 23 * * * run-standalone.sh mplayer file.mp3
5 - checked it's in /var/cron/tabs/root
6 - wait
7 - weep
alephito
06-25-2008, 07:19 AM
Because it was looking for ./UNINSTALL, not ./cron/UNINSTALL, and so on.
Does it mean there is an error in the INSTALL file?
alephito
06-25-2008, 07:28 AM
actually it seems to be in /var (chinook)
And what do you have in /tmp/crontab.3312 ?
And what do you have in /tmp/crontab.3312 ?
There's no cron related files in /tmp :confused:
alephito
06-25-2008, 08:11 AM
===========
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.3312 installed on Wed Jun 25 13:33:30 2008)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
35 13 * * * /usr/sbin/reboot
===========
I think there is (I am a newbie to Linux, I might be wrong). And look at what I quote from your file.
I think there is (I am a newbie to Linux, I might be wrong). And look at what I quote from your file.
# (/tmp/crontab.3312 installed on Wed Jun 25 13:33:30 2008)
wtf?
No crontab.3312 in /tmp.. though there is mention of it in /var/cron/tabs/root ...
A problem with my config?
cybergypsy
06-26-2008, 04:00 AM
DistantFire asked me :-
Default Cron & Aumix
I've been following your thread on Aumix and cron with great interest. I'd love to set up some cronjobs on my IT like the muting and/or the LED disabling during night hours.
Problem: I'm not a Linux or even Unix guru. I've never set up a chron job, never installed except from deb files, never did anything with tar.
2nd Problem: I tried to install cron (tar method), and can't tell if I succeeded or not.
3rd Problem: I tried to install aumix and got an "incompatible application" error message.
Is there some other s/w I need to install first ... like GTK or something? (I don't know what GTK is.)
I don't want to trash the forum with my petty problems, so I thought I'd ask you...
thanks,
DF
__________________
IT: N800 / Chinook
PC: Windows XP
Cell: LG Fusic (Sprint)
MP3: Insignia NS-DV4G or IT/Canola
So I have created a wiki page on wiki.maemo.org (http://wiki.maemo.org/Automatic_Muting_via_cron) detailing the whole procedure.
BoxOfSnoo
06-26-2008, 10:45 AM
A couple of modifications should be made to the detailed procedure...
if you copy to an external memory card, it's probably going to be FAT or FAT32. chmod probably won't do anything.
I suggest that a) it either be temporarily copied to root's home directory and done from there or b) explicitly passed to the interpreter (probably the best choice) as in:
# sh /media/mmc2/cron/INSTALL
Are there any other problems foreseen with that?
alephito
06-26-2008, 11:00 AM
if you copy to an external memory card, it's probably going to be FAT or FAT32. chmod probably won't do anything.
Yeah, that is what was happening to me.
Another thing I do not think is OK is the recommendation to install all Gronmayer repositories. Why not just install the required ones?
cybergypsy
06-26-2008, 11:24 AM
Thanks guys , excellent points.
Feel free to edit the wiki page (http://wiki.maemo.org/Automatic_Muting_via_cron) and make the corrections.
BoxOfSnoo
06-26-2008, 11:35 AM
I made the change to copy it to the root folder, it seemed like the lowest impact change to make. I also changed it so you unpack on the device instead.
If you disagree, or prefer running it off the card, or whatever, feel free to re-edit.
L0cutus
06-27-2008, 01:38 AM
i've made a tar.gz of dcron 3.2 that support also:
user crontab (not only root)
/etc/cron.daily
/etc/cron.hourly
/etc/cron.weekly
/etc/cron.montly
for more info and download see here (http://www.zamprogno.it/TimeWiki.html#Maemo)
hope it helps
Under diablo I've just installed the cron.tar.gz package (http://www.internettablettalk.com/forums/attachment.php?attachmentid=605&d=1196504852) which works great! I then installed aumix-gtk from the elkins repo (http://gronmayer.com/it/dl.php?id=128), which doesn't work so well. While 'aumix -w 0' run as root doesn't give any errors it also doesn't mute the IT's output. Can anyone confirm that this does work in diablo? TX
alephito
07-04-2008, 02:29 PM
Aumix does work, grog.
Aumix does work, grog.
Of course it does, and of course it's only after I post here about it do I find out what I did wrong :o. I was playing with the system volume control, thinking that just because I could hear the chimes as I changed the volume that it wasn't working. But what I didn't realize is that just by accessing that control it was restoring the volume automatically. So every time I shut it off using aumix, I was turning it back on with the volume control :rolleyes:.
Thanks for the quick response.
allnameswereout
07-05-2008, 07:05 PM
Nice concept, but if you are bothered by the light and don't want to hear sounds why not simply hang the device on the power, and put it off? Then put it on when you wake up. Booting the device has very much improved with Diablo.
Also, what if the device went off while inbetween those 2 cron scripts? The scripts will have to be executed on boot as well.
Then there are weekend days with perhaps different preferences but thats easily fixed in cron.
Perhaps a cron frontend a-la Windows Scheduler would be nice for the NIT.
Have an alarm in the form of an MP3 being your alarm clock.
Nice concept tho but IMO these scripts should also save the current setting IOW save the setting before it goes into 'night' mode, and then in morning return to this original setting before it went into 'night' mode. Currently. reminds me of ALSA in its early days, hehe.
Laughing Man
09-02-2008, 04:06 PM
Thanks maillaxa, thats great!
For anyone else who would like to get this working , here is what I have done.
I set all this up via SSH on my desktop rather than the built-in terminal, this allows easy copy & paste as well as file transfers via secure copy (scp)
Installed the aumix-gtk applcation from the repositories.
Installed the cron package from this thread (http://www.internettablettalk.com/forums/showthread.php?t=12572).
As root created a crontab containing :-
30 23 * * * aumix -w 0
00 7 * * * aumix -w 90
This mutes the tablet at 11:30pm and un-mutes it at 07:00am
Either reboot or run cron from the command line.
Good Luck
cybergypsy
Can you setup several scripts? For example, I have classes on different days that I'd like it to auto mute on.
TrueJournals
09-04-2008, 10:55 PM
Try using http://www.webmaster-toolkit.com/cron-generator.shtml to generate your crontab lines. You can have as many lines in the crontab file as you want. Just remember that aumix -w 0 will mute, and aumix -w 90 will unmute.
alephito
09-05-2008, 07:05 AM
I unmute with 'aumix -w 93', since 93 is the default volume in a brand new NIT.
Laughing Man
09-05-2008, 04:07 PM
Thanks! Though I have a question.. say..
0 10 * * * aumix -w 0
That would mean 10 AM on a Sunday it would mute my n800 using aumix.
Now I can set one up for each day.. but is it possible to say.. create a crontab that does Monday, Wed, and Friday? Or would I need three different crontabs? For example, could I do something like this?
0 10 * * 1,3,5 aumix -w 0
Or would I need
0 10 * * 1 aumix -w 0
0 10 * * 3 aumix -w 0
0 10 * * 5 aumix -w 0
And if so, could I put them all in one textfile instead of having an individual text file for each one?
Benson
09-05-2008, 04:17 PM
http://linux.die.net/man/5/crontab
Laughing Man
09-05-2008, 05:06 PM
Ok, thanks for the help everyone. I've written the file and loaded it with crontab.. so I guess I'll find out Monday *crosses fingers*.
alephito
09-05-2008, 07:39 PM
0 10 * * 1,3,5 aumix -w 0
I have been using this syntax and works well.
Laughing Man
09-05-2008, 08:27 PM
Good, that's what I used. :)
Mikma
09-12-2008, 06:24 PM
So here's how I did my cron-scripts. First line changes volume to mute/max, and second line switches Instant Message -led on/off.
Setting stuff OFF.
gconftool -t int -s /apps/osso/sound/master_volume -- -100
gconftool -t bool -s /system/osso/dsm/leds/PatternCommunicationChat false
Setting stuff ON.
gconftool -t int -s /apps/osso/sound/master_volume 100
gconftool -t bool -s /system/osso/dsm/leds/PatternCommunicationChat true
To make the screen turn off in case you have charger connected:
gconftool -t bool -s /system/osso/dsm/display/display_on_with_charger false
Here's the whole crontab. http://mikma.reaktio.net/maemo/crontab.txt
codeMonkey
09-14-2008, 06:29 PM
Much nicer solution. Thanks Mikma
Does anyone know whether gconftool can mute & un-mute the volume, i.e. not set to zero, leave the volume set to whatever level it is, just mute & un-mute? TX
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.