I am using a Raspberry Pi and I want to be able to change the input of the TV using cec-client.
I tried these two scripts:
echo "scan" | cec-client -s -d 1
and
echo "as" | cec-client -s -d 1
When I tried them on a monitor without having a TV, they ran fine, although obviously didn't do anything meaningful.
Afterwards I tried them on a TV. Scanning usually takes around 1 minute and gives back proper info but at the end also says "segmentation fault". The "as" command always resulted in segmentation fault without switching the input, and it took multiple minutes. I tried updating the firmware of the LG TV, but it did not help. Later tried it on a Philips TV, I still had these problems. I tried uninstalling then reinstalling cec-client. Tried restarting the Raspberry Pi. Nothing worked so far.
Related
I now this has been asked before, but I have spent hours and hours trying to find out how to do this and absolutely nothing has worked. I have a python file that I want to automatically run in a terminal window after the pi has booted and loaded its GUI.
I don't know what else to do, and the annoying thing is I had it working for the same project (it took a long time to find out how then as well), but the pi crashed today and I can't remember how to do it again. All I can remember is that I added something to a file ending in /autostart, if that helps.
I was able to launch a python file on startup by running sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart and adding #lxterminal -e python /home/pi/weatherStation/core.py at the end of the file
I had similar issues remembering where and how to do this. Then it all seemed to change again with Buster.
Having just freshly installed Buster onto a new SD card, I had to go through the whole process again. It's definitely easier the third or fourth time ;-)
I found that there was no lxsession folder in the path I had used before:
/home/pi/.config/lxsession/LXDE-pi/autostart
/home/pi/.config/lxsession did not exist in the Buster I just installed (May 2020)
I found a 2020 Buster related article here:
http://wideberry.com/autostart-python-script-after-boot-in-raspbian-buster/
and from that found the autostart file in this path:
/etc/xdg/lxsession/LXDE-pi
Note: this is a root file and will affect all users.
As I had previously found an issue with timings of when to issue the python command, I call a script to pause before running my python scripts.
I added an #lxterminal command in my /etc/xdg/lxsession/LXDE-pi/autostart as follows:
lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#lxterminal -e /home/pi/StartCollectors.sh
#xscreensaver -no-splash
Note: as /etc/xdg/lxsession/LXDE-pi/autostart this is a root protected file, it had to be edited with root powers, e.g. sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
StartCollectors.sh contains this
#!/bin/bash
# started from the /etc/xdg/LXDE-pi/autostart file (reminder)
cd /home/pi/ETA2-copy
echo "starting House Collectors in 20 seconds"
sleep 10
echo "starting House Collectors in 10 seconds"
sleep 10
lxterminal --working-directory='/home/pi/ETA2-copy' --command='python3 Hiverun.py' -t 'Hive'
lxterminal --working-directory='/home/pi/ETA2-copy' --command='python3 ETALog.py' -t 'ETA'
lxterminal --working-directory='/home/pi/ETA2-copy' --command='python3 ETADailySum.py' -t 'Summary'
echo "My work is done. Closing in 10 seconds
sleep 10
exit
the -t options put a recognizable name on the terminal window.
It works.
BTW I collect data from an ETA PU15 boiler over my local Lan. I collect data from my British Gas Hive home control system and the UK Met Office and integrate it into an sqlite table so that I can track the house performance. Why? Why not? Call it a hobby.
I think this is my first answer on this forum. I hope it conforms and that it helps others.
To learn about BASH scripting, I set myself the objective to write a Cron script which shuts down a PC with Mint 20 when activity on the Ethernet interface dropped below a threshold over an 1 hour.
I mainly (but not exclusively) use the PC as File/DLNA Server. The script works, but now I find that it also shuts down the PC the rare times I'm using the the front end. So I want my script to verify if the screen has been blanked (As per Power Management settings)
To test the principle I included this in my script:
screenon=$(/usr/bin/xset -q | grep 'Monitor is' | cut -d "s" -f 2)}
which when run in a terminal window gives (debug: set -x)
screenon= On
but when run from cron gives. (logger)
/usr/bin/xset: unable to open display ""
I have learned about similar problems, but cannot figure out how to solve this.
My script includes:PATH=$PATH:/usr/local/bin
and my PATH is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Thanks in advance for any help.
I am currently working on a home project with a Raspberry Pi and the 7" display. Almost everything works, only the last bit I am a bit confused with. A chromium window in kiosk mode is open which refreshes on mouse movement. Also on mouse movement I want to change the backlight for a few seconds to full light.
The script below works so far stand-alone:
#!/bin/bash
while true; do
pos1=$(xdotool getmouselocation)
sleep 0.5
pos2=$(xdotool getmouselocation)
if [[ $pos1 != $pos2 ]]; then
sudo /usr/local/bin/rpi-backlight -b 100
sleep 10
sudo /usr/local/bin/rpi-backlight -b 0 -d 2
fi
done
I already tried to make it happen by
putting it in one script together with the chromium call,
opening both in autostart,
creating a systemd service for the script above. It does not seem to work in the background.
Can anyone tell me, where I am mistaken?
I made it happen by putting both in autostart. My syntax seemed to be wrong.
#/path/script.sh &
#chromium-browser --kiosk http://website.xyz
works like a charme, where ampersand "&" is for making it a background process.
I have been following the "Get started with the dev board" page and am currently flashing my Coral for the first time using a mac as my host computer.
My screen terminal shows "request [####] was not queued to eplin-bulk," and my fastboot terminal show errors with clearing the input and output pipes, and is currently Rebooting into bootloader. It's been stuck like this for over 30 mins.
For reference, I used (Installing ADB on macOS) instructions to download fastboot, and (https://coral.withgoogle.com/docs/dev-board/get-started/) instructions for every other part of setup.
This is the output from the fastboot terminal:
Sending 'bootloader0' (1006 KB) OKAY [ 0.048s]
Writing 'bootloader0' OKAY [ 0.190s]
Finished. Total time: 0.264s
Rebooting into bootloader OKAY [ 0.024s]
Finished. Total time: 0.024s
Sending 'gpt' (33 KB) OKAY [ 0.018s]
Writing 'gpt' OKAY [ 0.309s]
Finished. Total time: 0.346s
ERROR: could not clear input pipe; result e00002ed, ignoring...
ERROR: could not clear output pipe; result e0004051, ignoring....
Rebooting into bootloader
The problem seems to be that the script does not sleep long enough after rebooting the board.
In the flash.sh script, look for the sleeps following the reboots. They are at lines 74 & 79. I changed them to sleep for 10 seconds and things were good to go.
Fixed the issue, but not entirely sure what it was that did it. I went back through the instructions I linked in the question, redownloaded the system image, and the flashing process was successful
I am trying to learn Hugo using a Go debugger called dlv. And I am pretty stuck. After:
go get -v github.com/gohugoio/hugo
cd $GOPATH/src/github.com/gohugoio/hugo
go build -gcflags="-N -l"
dlv exec ./hugo -- -s /path/to/the/projectdir
This hangs. Pressing Ctrl+C runs hugo as normal. As far as I can see dlv debug not only produces the same behavior but it's the exact same: the produced binary called debug is the exact same as the hugo I built with go build -gcflags="-N -l".
dlv launches a number of child processes, these disappear after a while. The hugo process is visible via ps and pidof hugo but strace -ppidof hugo`` reports strace: attach: ptrace(PTRACE_ATTACH, ...): No such proce. Checking after, it's still in the ps list, the same pid. I would guess because it's in t state as it is being traced.
How could I then watch Hugo running?
Aaaaand it's Linux subsystem for Windows! I never thought that'd make a difference but following Jonah B's answer " I am on fedora" I tried it on a Debian box and it worked. I am surprised because strace works fine on WSL (actually the github instructions on filing a report includes strace). I filed this bug.
Hmm, doesn't happen for me. dlv prompt appears right away. I am on fedora, have been using hugo regularly over the past week or so.
$ dlv exec ./hugo -- --cleanDestinationDir -s /path/to/blog/root/
Type 'help' for list of commands.
(dlv) c
| EN
+------------------+----+
Pages | 25
Paginator pages | 0
Non-page files | 0
Static files | 11
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 46 ms
Process 41032 has exited with status 0
$
Same experience here. However it doesn't hang, it just takes a significant time to reach the dlv prompt.
Check the usage of your memory (for instance with mpstat or vmstat if you are on Linux). I have 16G main mem and 16G of swap. Until the dlv prompt is reached, nearly all my memory and a significant amount of swap is consumed. During the startup time any playing video or music stutters and the PC is practically unusable until dlv is ready.
Hugo is pretty large app in that respect.