How to refresh an application with bash: useful for Twitter clients
If you have the necessity to refresh or reload every a specified time an application that doesn't have this feature, you can adapt my bash script to your duties. Indeed it allows you to kill and reload an application in the same position after a fixed interval of time. I wrote it to refresh every 10 minutes the timeline of Corebird a third-party twitter client.
Why do I have make this script? Because starting from 2018 Twitter removed the UserStream API which many third party clients used, including Corebird, my favourite application. It's a vital part of the user experience and is used for:
- pushs notifications (now they will no longer arrive);
- refreshes the timelines automatically.
Of course I tried others clients and a new window of the internet browser in which I only have loaded Twitter... but the result was the same: no automatic refresh. Hence I wrote a bash script to simulate a timeline refresh every 5 minutes. Simple and pain-free!
The only application that probably you have to install is wmctrl1 :
sudo apt-get update sudo apt-get install wmctrl
How it works
My bash script bypasses that limitation and kills the application every the prefixed time has elapsed, then reloads it in the same position, size and workspace if there are more than one.
So in order to make it works it is necessary to provide all this data. The setup is easy and I explain it in the next section highlighting the suggested command for complete every requested item.
- launch, move and size the application window that you want to reload in a specified amount of time;
- edit my script inserting your data, you can use the command that come first the item to have the correct output:
## SETTINGS: # :~$ whereis application_name executable="/usr/bin/your_application_executable" # :~$ ps -u $USER |more process_name="your_application_process" # :~$ wmctrl -l program_name="your_application_name" # :~$ wmctrl -lG (in pixel) program_coordinates="2,x,y,width,height" # 0 if it is in the first workspace workspace_number=0 # in seconds interval=600
- save, make executable2 and launch it from a terminal or at startup of your window manager.
Get the zip or clone my repository from GitHub: rainnic/bash-scripts
- 1wmctrl is a command that can be used to interact with an X Window manager that is compatible with the EWMH/NetWM specification. wmctrl can query the window manager for information, and it can request that certain window management actions be taken. Source: https://linux.die.net/man/1/wmctrl
- 2In order to make executable a text file, use this command: “chmod +x refresh_app.sh”