Program runs incorrectly when not run in terminal

I am running Linux (Debian Jessie 8.7 stable) with the LXDE desktop environment.

I have created a program which notifies me of events when the time is appropriate. It works by parsing a file which has information about the time of the events and what messages should be used to notify me. I have thoroughly tested the parsing part of my code, so I am sure it is correct.

After, getting all necessary information my program checks the current time to show the notifications at the right time. To notify me it uses the std::system() function (sorry for that!). I use it because to notify me there is a command line tool I installed called ruby-notify and to run it I run notify-send <Summary> <Description>. So, I use std::system().

The problem is when I run my program without the terminal with a keyboard shortcut or via Run, the notifications don't send (I don't know if the std::system() function isn't working or what). However, if I run it through the terminal like ./notify-time loop (my program's executable name is "notify-time" and takes either one of these arguments: now, loop), then everything works fine including the notifications.

The only notification that works in both ways of running my program is the startup notification.

The notification looks something like these: full-screen: http://prntscr.com/eqrahb zoom-in: http://prnt.sc/eqrb6x (clicking on the images will make them clearer)

Program code: https://pastebin.com/A4GfNuJE (114 lines and I tried to make it clean; no magic numbers, split into functions, etc. I have two functions other than main: one which loads the events from file into program and another that continuously checks the time to see if it is time to send the appropriate notification the time is parsed and all the info is put together to send notification when it is time])

File with events info example: http://s000.tinyupload.com/index.php?file_id=73552840936489675306 (Turn word wrap off in the editor and I added a lot of documentation [easy to understand] to make you guys understand).

Output for just first event: https://pastebin.com/XaeACrt9

I would seriously appreciate it a lot if you guys took a look and helped! I put a huge amount of effort into making my code clean and documenting the file with events info so it is extremely easy to understand (also making this post short as possible and concise). Please! Thanks a lot!
Last edited on
The working directory is probably different when you run it as a shortcut which will break relative paths such as "notify-time-conf".
@Peter87

Peter87 wrote:
The working directory is probably different when you run it as a shortcut which will break relative paths such as "notify-time-conf".


I have never thought of that! Shows how much I still don't know about Linux (lacked some knowledge of commands with keyboard shortcuts). I am resisting the urge to spam thanking you in all caps! Makes so much sense! I was thinking it was a much more complex problem. I changed the file path to open in my program code to the specific path and it works now.

Thanks a million!

P.S. Only answer, first answer, perfect answer.
Last edited on
Topic archived. No new replies allowed.