Need an Applet - How do you make them?

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Kurt3162
Level 4
Level 4
Posts: 480
Joined: Wed Apr 02, 2014 2:05 pm

Need an Applet - How do you make them?

Post by Kurt3162 »

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?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29588
Joined: Wed Jul 06, 2011 3:58 am

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

Post by xenopeek »

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: 480
Joined: Wed Apr 02, 2014 2:05 pm

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

Post by Kurt3162 »

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 25
Level 25
Posts: 29588
Joined: Wed Jul 06, 2011 3:58 am

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

Post by xenopeek »

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

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

Post by Habitual »

Writing applets

Get some.
Kurt3162
Level 4
Level 4
Posts: 480
Joined: Wed Apr 02, 2014 2:05 pm

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

Post by Kurt3162 »

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: 480
Joined: Wed Apr 02, 2014 2:05 pm

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

Post by Kurt3162 »

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.
Locked

Return to “Compiz, Conky, Docks & Widgets”