Need an Applet - How do you make them?

Forum rules
Before you post please read how to get help
Kurt3162
Level 4
Level 4
Posts: 204
Joined: Wed Apr 02, 2014 2:05 pm

Need an Applet - How do you make them?

Postby Kurt3162 » Thu Apr 06, 2017 4:32 am

I'm looking for a very simple applet which checks the system clock and plays a given sound every full hour, and another sound every half hour (with an option to deactivate it when not needed).

I didn't find anything doing this, but it's so simple I think I might (potentially) be able to make it myself. Except I have no clue how Cinnamon Applets are made...

Would somebody be so kind to help me please?
I'm no programmer, though I have done some prototyping in VB and dabbled in (web) JavaScript a couple dozen years ago... And from what I've seen they might be baked out of some flavor of JavaScript. Is that true?

User avatar
xenopeek
Level 24
Level 24
Posts: 21468
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Need an Applet - How do you make them?

Postby xenopeek » Thu Apr 06, 2017 6:47 am

You could just use the crontab to schedule the sound to be played? If the sounds are mp3 files you can install something like mpg123 to play mp3 files from the terminal and then use the command crontab -e (do not add sudo!) to edit your personal crontab and add these two lines to the end of the file:

Code: Select all

0 * * * * mpg123 /path/to/whole-hour-sound.mp3 >/dev/null 2>&1
30 * * * * mpg123 /path/to/half-hour-sound.mp3 >/dev/null 2>&1

Replace with correct path for your files.
Image

Kurt3162
Level 4
Level 4
Posts: 204
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need an Applet - How do you make them?

Postby Kurt3162 » Thu Apr 06, 2017 2:53 pm

Wow, that's even easier! Thanks a lot!

Where do I find my user crontab file?
Going through crontab -e created a file, but I can't find it. I thought it would appear inside /etc/cron.d, but it's not there.
(I just added some comment lines, to create the file and also be sure I'm looking at the right one, so doing a crontab -l I see it does indeed exist, somewhere.)

Why am I looking for it? Well, I want to be able to switch this "feature" on and off easily, and commenting in/out those lines in VI isn't the most user-friendly way I can think of. So I thought I might move my user crontab file around (or rename it), it's empty besides those lines.
Would that work?


--Edit

Found it. Stupid Nemo can't tell me it hasn't permission to display stuff, it just pretends there is nothing there... So okay, the file is in /var/spool/cron/crontabs, which my user can't access, this means my idea of moving the file around won't work easily. Vi it is, then.

User avatar
xenopeek
Level 24
Level 24
Posts: 21468
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Need an Applet - How do you make them?

Postby xenopeek » Thu Apr 06, 2017 3:25 pm

nano is friendlier (that is the default editor crontab recommends the first time you run it and it asks you which editor to use). But you can use your preferred graphical editor. If you are on Linux Mint 18.x Cinnamon/MATE/Xfce you do so with the command:
EDITOR=/usr/bin/xed crontab -e

For Linux Mint 17.3 or earlier Cinnamon/Xfce replace "xed" with "gedit" and for MATE with "pluma".

If you're using KDE replace "xed" with "kate", regardless of your Linux Mint version.
Image

Habitual
Level 13
Level 13
Posts: 4866
Joined: Sun Nov 21, 2010 8:31 pm
Location: 0.0.0.0

Re: Need an Applet - How do you make them?

Postby Habitual » Thu Apr 06, 2017 5:44 pm


Kurt3162
Level 4
Level 4
Posts: 204
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need an Applet - How do you make them?

Postby Kurt3162 » Fri Apr 07, 2017 9:57 am

xenopeek wrote:If you are on Linux Mint 18.x Cinnamon/MATE/Xfce you do so with the command:
EDITOR=/usr/bin/xed crontab -e

Great, that's much faster for me (and much less error-prone). Thank you!

Kurt3162
Level 4
Level 4
Posts: 204
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need an Applet - How do you make them?

Postby Kurt3162 » Fri Apr 07, 2017 10:11 am

Habitual wrote:Writing applets

Thank you, bookmarked it. I'm happy though I don't need to use it...
You see, I looked through that tutorial, and while I can clearly see what each line of code is doing, I'm afraid I would be totally unable to find those lines myself. I've never been a programmer, just a dabbler, and it's 20+ years since.


Return to “Compiz, Conky, Docks, & Widgets”