Pergunta

I have following batch-script:

echo [InternetShortcut] > "%basepath%\files\new\link.URL"
echo URL=http://google.com >> "%basepath%\files\new\link.URL"
echo IconFile=http://google.com/favicon.ico >> "%basepath%\files\new\link.URL"
echo IconIndex=0 >> "%basepath%\files\new\link.URL"

In Windows 7, this creates a symlink on the desktop and when clicked it opens Google in the webbrowser.

I am trying to achieve the exact same thing with a small bash script, but this:

ln -s http://google.com ~/Arbeitsfläche/new

doesnt work, but at the same time its the only way I can think of doing it.

p.s. if it does matter: the bash script is supposed to work on Debian.

Foi útil?

Solução

You should be able to create a .desktop file (see Desktop Entry spec), here's an example:

[Desktop Entry]
Version=1.0
Type=Link
URL=http://www.google.com

Outras dicas

ln in linux is used to create name-aliases, kind of, in linux. Suppose you have file /somelocation/X and what the same file to be referred like /someotherlocation/Y, then one uses ln.

What you need is Launcher.

Right Click on the linux desktop, select "Create Launcher"

Use the Following Settings to make a link to google:

Type: Location
Name: Google
Location: http://www.google.com

Create bash script file (~/bin/urlfile):

#!/bin/bash

launcher="$(pwd)/$1.desktop";

#echo -e "#!/usr/bin/env xdg-open\n\n[Desktop Entry]\nVersion=1.0\nName=$1\nComment=Open Link (URL): $2\nComment[ru_RU]=Открыть ссылку (URL): $2\nIcon=applications-internet\nURL=$2\nType=Link" | tee "$launcher"

echo -e "#!/usr/bin/env xdg-open\n
[Desktop Entry]
Version=1.0
Name=$1
Comment=Open Link (URL): $2
Comment[ru_RU]=Открыть ссылку (URL): $2
Icon=applications-internet
URL=$2
Type=Link" | tee "$launcher" &&

chmod +x "$launcher"

& Run:

urlfile 'Bash Script + Create Symlink to Website' 'http://stackoverflow.com/questions/10532754/bash-script-create-symlink-to-website'

You'll get a file in home directory.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top