I have created a script to display a random line from a file created in a script.
It works fine, the chosen line comes up in a Featherpad window on my desktop. But there is a big problem.
For background information, please find bellow the lines I wrote to achieve that:
- Starting with my_library.txt (a 70 Million-word file containing all my book collection), I choose a character name to create my_hero.txt containing all the lines mentioning this character.
grep hero-name ~/Desktop/my_library.txt > ~/Desktop/my_hero.txt
- Now, I create display.txt with a random line from my_hero.txt
shuf -n 1 ~/Desktop/my_hero.txt > ~/Desktop/display.txt
- I ask display.txt to be displayed on the desktop with Featherpad and ask the program to sleep for a while.
featherpad ~/Desktop/display.txt
sleep 180
All good so far, but the idea is to repeat step 2 and 3 every 180 seconds. I have tried but the Featherpad window is not updating on my desktop!
I have tried to close Featherpad with a 4th line to solve the problem, did some research but nothing worked so far:
- The command such as xkill does not work
- killall is useless as it requires an ID that changes all the time.
- I tried to add :
pkill featherpad
after sleep 180
with no more luck (it does kill windows that have been opened from the desktop though).
Also, I noticed that it is possible to reload display.txt: it solves the problem, but it has to be done from the app itself, which is useless too. Unless there is a way to reload within the script.
I went to "settings" in Featherpad to autosave the files every 1 minute: not good either...
Quite frankly, all this is very frustrating, as I am sure that the solution is so simple that it is too obvious to be mentionned.
I realize that the question is "how can I do a alt+F4 in a .sh file?" and I can't find the answer! This is my second script, but still...
I have checked the "Create, Write and Save file from a Shell script" but did not find an answer that I could understand.
Any help or hint would be greatly appreciated.
Many thanks in advance.