Logging
- 
					
					
					
					
 Logging on raspberry pi. Building a few triggercmds on my raspberry pi. 
 Simple commands like shutdown and reboot work fine.
 If I want to launch foreground apps like the calculator "galculator" needs to launch a xterm or gnome app. The default user is pi and triggeragent runs as root.
 For debugging purposes of cmds how do I log and view the results.
 For example here is my calulator example.
 {"trigger":"Gnome Calculator","command":"galculator","ground":"foreground","voice":"calculator","allowParams": "false"},
 My assumption is that the command needs references to pi user and xterminal references to launch. But I cant see debug results to fix commands as they become more complex.
- 
					
					
					
					
 @legtod2, to add logging I recommend running a script instead of the galculator command directly. You can add commands in your script that send the output to a log file, like this: echo Running galculator script >> /tmp/galculator.logAs far as running GUI X windows apps as root that display in the Pi user's X windows environment, please look at this post. Basically you need these two things: In your bash script, add this command before it runs galculator: export DISPLAY=:0.0And in one of your bash shells running as the pi user, run: xhost +If you want the GUI app to run as pi instead of root, you can have your script run them with the su command like this: su pi -c galculator
- 
					
					
					
					
 @russ that makes sense and easy to implement. Thanks for the advise. 
- 
					
					
					
					
 @legtod2 That works pretty well 
 #!/bin/bash
 su - pi -c 'export DISPLAY=:0.0; galculator'{"trigger":"Gnome Calculator","command":"/home/pi/galc.sh","ground":"foregroun 
 d","voice":"calculator","allowParams": "false"},Now the next logical question is a close command. Should I have a 2nd script to perform a kill command or is there a slicker options of having a trigger command with option of open and close ? 
- 
					
					
					
					
 @legtod2 Ok so here's my open and close galculator that works 
 {"trigger":"Open Calculator","command":"/home/pi/open_galc.sh","ground":"foreground","voice":"open calculator","allowParams": "false"},
 {"trigger":"Close Calculator","command":"/home/pi/close_galc.sh","ground":"foreground","voice":"close calculator","allowParams": "false"},cat open_galc.sh 
 #!/bin/bash
 su - pi -c 'export DISPLAY=:0.0; galculator'
 pi@raspberrypi:~ $ cat close_galc.sh
 #!/bin/bash
 su - pi -c 'export DISPLAY=:0.0; killall -9 galculator'
- 
					
					
					
					
 @legtod2 Opps minor tweak on commands.json {"trigger":"Open Calculator","command":"/home/pi/open_galc.sh","ground":"foreground","voice":"calculator","allowParams": "false"}, 
 {"trigger":"Close Calculator","command":"/home/pi/close_galc.sh","ground":"foreground","voice":"exit","allowParams": "false"},I guess I need to learn about a command with options 
- 
					
					
					
					
 @legtod2, if you want to use the TRIGGERcmd Smart Home Alexa skill to turn on and turn off galculator, I'd recommend using the offCommand field like this: {"trigger":"Open Calculator","command":"/home/pi/open_galc.sh","offCommand": "/home/pi/close_galc.sh","ground":"foreground","voice":"calculator","allowParams": "true"},Notice I set "allowParams": "true" which is necessary to use offCommand, but because you're using offCommand, your /home/pi/open_galc.sh command won't receive the on parameter. Alternatively you could use one shell script that expects the on or off parameter like I did here. 
