Score:0

File created in a script (file is modified at regular interval) : when displayed on the Desktop, the file is not updated automatically

ag flag
bee

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:

  1. 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

  1. Now, I create display.txt with a random line from my_hero.txt

shuf -n 1 ~/Desktop/my_hero.txt > ~/Desktop/display.txt

  1. 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:

  1. The command such as xkill does not work
  2. killall is useless as it requires an ID that changes all the time.
  3. 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).

  1. 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.

  2. 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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.