ebruck / radiotray-ng

An Internet radio player for Linux
GNU General Public License v3.0
262 stars 25 forks source link

How to create a radiotray alarm clock to go off at a specified time using cron (Solved) #207

Closed LinuxMint20 closed 1 year ago

LinuxMint20 commented 1 year ago

I'm posting this as an issue because github won't allow me to make a pull request.

Here is the code.


#!/bin/bash
#you need the bash shebang on the top line to make the whole thing run. 

notify-send "Launching Radio Tray" ;  #launches a little popup notification

/usr/bin/radiotray-ng --play & #launches the app

sleep 10 #Pauses between tasks. Won't make your computer go to sleep. Promise.

notify-send "Changing Station" ; #Launches another popup notification

/$HOME/.config/radiotray-ng/rtng-dbus play_station 'group' 'station' #substitute the group and station names here. keep the apostrophe's. 
#Requires directories and files as shown to be in your home folder (.config, radiotray-ng) to execute correctly

exit #exits the script in the bash

<<COMMENT #comments out everything (paragraph style) between this command and ending COMMENT, so it doesn't get 
interpreted as bash script/code. Used as an alternative to the hashtag, which only comments out to the end of the line.

crontab -e #type this in your command line editor (terminal) to open cron and schedule your script 

0 5 * * * export DISPLAY=:0 && XDG_RUNTIME_DIR="/run/user/1000" /home/user/.scripts/radiocron 
#enter the above line in the cron editor exactly as shown to make your script execute every day at specified time. substitute 
#radiocron for the name of your script, and user for your username.
#Make SURE you leave an empty line at the bottom of the cron editor or you will get an error.

chmod +x .scripts/radiocron #makes your script executable (like a program). It won't work unless you do this. Also, make sure file and directory are accurate