Search code examples
linuxbashxdgutils

xdg-open URL from text file


I have a python script that writes a url to a txt file every x minutes.

I'm looking to open this url on browser by xdg-open.

xdg-open /home/user/test.txt (opens the txt file)
xdg-open https://example.url (opens the url)

I've tried to combine cat command with xdg-open but didn't worked.

Is there any way i can get this done without a secondary script?


Solution

  • You could try it with xargs:

    url.txt:

    https://google.com
    https://github.com
    

    Command:

    < ~/url.txt xargs -I % xdg-open %