How to refresh an application with bash: useful for Twitter clients

Submitted by Nicola Rainiero on 2019-09-08

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:

  1. pushs notifications (now they will no longer arrive);
  2. 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!

How to refresh an application with bash: useful for Twitter clients

Requirements

The only application that probably you have to install is wmctrl1:

sudo apt-get update
sudo apt-get install wmctrl

How it works

the script in action

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.

Configuration

  1. launch, move and size the application window that you want to reload in a specified amount of time;
  2. 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
  3. save, make executable2 and launch it from a terminal or at startup of your window manager.

Download

Get the zip or clone my repository from GitHub: rainnic/bash-scripts

  • 1. wmctrl 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
  • 2. In order to make executable a text file, use this command: “chmod +x refresh_app.sh”

TAGS MULTI


Related Content:

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.