0

I have been making scripts to open and close a specific website with a cronjob on the raspberry Pi. The opening script works perfectly. It is as follows:

#!/bin/bash
export DISPLAY=:0 && epiphany-browser http://mywebsite
sleep 30
xte "key F11" -x:0
xte "key F5" -x:0

But the one to close the browser doesn't work at all, and I can't figure out why. Is there something wrong with the script? I made it by looking at this SuperUser question.

#!/bin/bash 

WID = `xdotool search "epiphany-browser" | head-1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+q 

Note: Couldn't get this code to work but the "killall" command works just fine.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
angelfmf
  • 23
  • 5

1 Answers1

0

Kill it!

#!/bin/bash
killall epiphany

And btw: on my system (Debian Jessie) the process name is just epiphany. You can see the process list e.g. with ps -A.

Jodka Lemon
  • 3,143
  • 13
  • 42
  • Sorry, i tried that before but it didn't work – angelfmf Jul 29 '15 at 11:31
  • Changed the binary name. – Jodka Lemon Jul 29 '15 at 11:34
  • Still doesn't work :S I thought it could be from being in fullscreen mode so i removed the line related to the key F11 but nothing. Maybe it is an epiphany issue from closing with terminal? – angelfmf Jul 29 '15 at 11:51
  • I just tried it and it works here. Try `killall -s 9 epiphany`. And start Epiphany for a test manually from a console and see what it drops to stdout/stderr. – Jodka Lemon Jul 29 '15 at 11:52
  • sorry nothing, i checked the process of epiphany and it says "epiphany-browse" but it still doesn't work. Could you be a bit more specific with the stdout/stderr? – angelfmf Jul 29 '15 at 12:07
  • Start it in a terminal and see what it messages it prints there while you try to kill it. Try to start `epiphany` and `epiphany-browser`. – Jodka Lemon Jul 29 '15 at 12:30
  • sorry about the long wait, was having lunch. When i type epiphany and try to kill it it shows" no process was found" but it works with epiphany-browser, although it won't work in the script. – angelfmf Jul 29 '15 at 13:06
  • Updated the answer with all the errors it shows from starting the process "epiphany-browser" and i can't type anything after because the process doesn't finish, it stucks on the last line i posted above. – angelfmf Jul 29 '15 at 13:20
  • To start clear: What is the output of `ps -A|grep epiphany` when the browser is running? – Jodka Lemon Jul 29 '15 at 13:44
  • Do you mind moving the discussion on to chat? It might become too long and confusing here with some posts. I've done what you suggested and this comes up `14661 ? 00:00:17 epiphany-browse` – angelfmf Jul 29 '15 at 13:53
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/26393/discussion-between-angelfmf-and-jodka-lemon). – angelfmf Jul 29 '15 at 14:01
  • Found the problem. Should have known that the issue was the script and not the commands. It was missing the permissions to run. A simple "chmod" solved it. Thanks for the help anyway. – angelfmf Jul 29 '15 at 15:16