LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-24-2018, 03:15 AM   #16
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121

As a general statement I think you should have persevered with systemd timer. It's the best general solution, and a good skill to have. I reckon you over complicated things, but in this case I have an inkling that there are problems with running alsa as root ... might have been your problem.
 
Old 03-24-2018, 12:32 PM   #17
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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"

Last edited by BW-userx; 03-24-2018 at 02:28 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
14.2 - canberra-gtk-play - failed to play sound sound disabled... LQSlacker Slackware 3 11-03-2020 12:41 AM
Can ds linux play a sound on the hour thisbl3 Linux - Software 4 02-26-2007 09:28 PM
my sound works on boot and shutdown and on test but i cannot get a cdrom to play audi tbrownarcher Linux - Hardware 8 04-10-2006 03:49 PM
mandrake 10 command line to gui boot, then stuck at boot with hour glass chris008 Linux - Laptop and Netbook 1 11-14-2004 05:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration