Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
414 views
in Technique[技术] by (71.8m points)

linux - open .url windows file in a browser on kde plasma 5 gracefully without having terminal closure kill browser

We migrated our media PC from Windows 7 to Kubuntu Linux 20.10.

There are many text files saved with a .url extension that have a line URL=https://website.com

I would like to be able to open them the same ways I would any other document. Lets say, double click, or right click and say open, or open with _browser_name
(I know I could write another wrapper script for /usr/bin/firefox and all the other browsers, but I am ok with telling it to open in my shellscript)

This basically works, but If I close the konsole window, the firefox window closes. (unless there is another firefox open before, and then it works fine)

I tried the ampersand, i tried disown.. I've corrupted my firefox profile a few times because of how it gets clobbered when it closes ungracefully.

What can I do?

I need to use Dolphin file manager. I want this script to be able to handle errors, which is why I have a few extra arguments to commands than I saw in the examples.

If I include the ampersand at the end, the browser closes immediately.

#!/bin/bash
#bash -c "cat $1 | grep URL | cut -d'=' -f2 | xargs firefox &"
echo OpenWinURL in firefox
echo Closing this window will close your firefox.
echo Try opening firefox before opening a OpenWinURL
#echo Copyright 2021 Aaron Peterson GPL V2 or later
#echo  The ampersand doesn't work after firefox
#echo "$1"
#
jobs -l
cat "$1" | grep  -m 1 URL= | cut -d'=' -f2- | xargs -0 -i firefox {} #&
#jobs -l
disown -h -a
#jobs -l
#read  -n 1 -p "Input Selection:" mainmenuinput

#echo testing
#wait 1000

#
#| head -n 1
#| cut -d'=' -f2 | xargs firefox &

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...