The question is published on by Tutorial Guruji team.
I want to open Chromium browser and then open a couple of web pages, let’s say “google.com”, and “stackexchange.com”. My code for the same is below.
#!/bin/bash #website 1 chromium-browser xdotool type http://google.com xdotool key --delay 2000 'Return' xdotool key 'ctrl+Tab' #website 2 xdotool type http://stackexchange.com xdotool key --delay 2000 'Return'
1) This piece of code only works when I already have a Chromium browser open. Then only, it opens another Chromium browser (as per the code) and performs everything perfectly.
2) If I don’t have a browser already open, then this script just opens the browser and does nothing.
Where am I going wrong? Why do I need to have another browser open for the code to work?
Chromium open the tabs on its own, without needing
chromium-browser http://google.com http://stackexchange.com &
Will open a new chromium window (if none was opened before) with 2 tabs
then you can switch between the tabs with
xdotool search --onlyvisible --class "chromium" windowfocus key 'ctrl+Tab'
if you want to repeat every 5 seconds :
while true ; do sleep 5 ; xdotool key 'ctrl+Tab' ; done