Can a bash script refresh a wegpage?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Post Reply
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Can a bash script refresh a wegpage?

Post by Logansfury »

Hello,

I was trying with online resources to acquire a bash script that would work with my xdotool and auto refresh a specific Chromium tab for me.

The script I got however always returns it's built-in Tab with name not found error.

Is such a script possible? I would like it to run once a minute until stopped if it's doable. The page I want to refresh has the tab name:

Linux Mint Forums - Index page
forums.linuxmint.com


Thanks for reading,

Logan
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
1000
Level 6
Level 6
Posts: 1040
Joined: Wed Jul 29, 2020 2:14 am

Re: Can a bash script refresh a wegpage?

Post by 1000 »

It depends ...

- The browsers sometimes allows you to use keyboard shortcuts, but the browser must be open.
So, then you can use tools like xdotool.

- xdotool probably allows you to control the mouse cursor, which will click for you.
motoryzen
Level 10
Level 10
Posts: 3497
Joined: Sun Dec 08, 2019 12:25 am

Re: Can a bash script refresh a wegpage?

Post by motoryzen »

*nods to 1000 *

Indeed. Here's how my google chrome browser launches which includes youtube.com. Youtube.com for my setup is the 2nd browser tab...Thus..one ctrl+tab keypress combo to change focus to that exact webpage/tab,

( where alt+super+c is the keyboard Cinnamon hotkey combo to launch google chrome browser)

So if the tab/webpage you want is the 2nd in the open tab/pages list from left to right..open....then it would be whatever keyboard shortcut key combo you want to use to launch chromium ( let's pretend it's alt+super+c )...so similarly to below ( you may need to adjust the number values below to slightly higher if you're not on a hardcore fast internet connection (shrugs)...

xdotool key "alt+super+c" sleep 1 key "Ctrl+Tab" sleep 0.33 key F5

If you prefer that specific webpage/tab be the third or fourth one out of 3 or 4 tabbed pages opened.... instead of " key Ctrl+Tab ". ...shorter to do " keydown ctrl sleep 0.3 key Tab key Tab sleep 0.3 keyup ctrl " ( two " Tab " s for moving over two webpage/tabs. 3 for 3..etc )

** Note ***
The " f " in " F5 " must be capitalized or it won't execute that simulated keypress *** or you could also do instead of " key F5 " ... " key ctrl+r " same thing imo.

Incase you don't have a list of all or the majority of key-translations of xdotool. Let me know and i'll hook ya up :)
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can a bash script refresh a wegpage?

Post by Logansfury »

Hello!

This sounds very good! For cases where the Tab isn't consistently the 2nd or 3rd etc, is there a scripted way to open the tab by its name?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Can a bash script refresh a wegpage?

Post by Koentje »

Are you working in the same browser on another tab at the moment you want it to be refreshed?
Or are you doing other stuff outside the browser? And when doing other stuff, is that specific tab active/open?
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can a bash script refresh a wegpage?

Post by Logansfury »

Koentje wrote: Sat Feb 17, 2024 8:34 pm Are you working in the same browser on another tab at the moment you want it to be refreshed?
Or are you doing other stuff outside the browser? And when doing other stuff, is that specific tab active/open?
Most likely I would be doing things outside the browser. I had a python3 script that was working well for focusing chromium but I hadn't got as far as getting it to recognize a specific tab.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Can a bash script refresh a wegpage?

Post by Koentje »

If you ask me, it seems pretty annoying if you are doing other stuff and the script lets the browser focus, switch tabs and reload them every so seconds while doing other things?!
Isn't there some add-on for the browser that does the refreshing without focussing the browser?
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can a bash script refresh a wegpage?

Post by Logansfury »

Koentje wrote: Sat Feb 17, 2024 8:44 pm If you ask me, it seems pretty annoying if you are doing other stuff and the script lets the browser focus, switch tabs and reload them every so seconds while doing other things?!
Isn't there some add-on for the browser that does the refreshing without focussing the browser?
I hadn't thought of that, ill look into chrome extensions.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Can a bash script refresh a wegpage?

Post by Koentje »

Seems there are enough refresh extensions!

Schermafdruk van 2024-02-18 01-53-42.jpg
Last edited by Koentje on Sat Feb 17, 2024 8:56 pm, edited 1 time in total.
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can a bash script refresh a wegpage?

Post by Logansfury »

That will certainly get me started!

Thank you :)
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can a bash script refresh a wegpage? [SOLVED]

Post by Logansfury »

Logansfury wrote: Sat Feb 17, 2024 5:33 pm Hello,

I was trying with online resources to acquire a bash script that would work with my xdotool and auto refresh a specific Chromium tab for me.

The script I got however always returns it's built-in Tab with name not found error.

Is such a script possible? I would like it to run once a minute until stopped if it's doable. The page I want to refresh has the tab name:

Linux Mint Forums - Index page
forums.linuxmint.com


Thanks for reading,

Logan
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Scripts & Bash”