here I wrote a c++ app that you can call in a script just add the filename and delay time, and message in that order on the command line. Message goes to stdout.
Code:
#include <iostream>
#include <cstring>
#include <chrono>
#include <thread>
using namespace std;
int main(int argc, const char **argv)
{
string afile;
string message;
string file = "/usr/bin/mpg123 -q ";
if (argc < 4)
{
cout<<"No Input"<<endl;
return EXIT_FAILURE;
}
message.append(argv[3]);
//add quotes to both string ends
afile.append("\"");
afile.append(argv[1]);
afile.append("\"");
//put it all together in one varable
//converting string to char for system()
file.append(afile);
char *command = new char[file.length() + 1];
strcpy(command, file.c_str());
int timer = stoi(argv[2]);
bool flag = true;
while (flag)
{
this_thread::sleep_for(chrono::seconds(timer));
cout<<message<<endl;
system(command);
}
delete[] command;
return 0;
}
Code:
$ ./alarm "/home/userx/Music/iphone_mp3.mp3" 1800 "Hey get up"