GNU/Linux'ta Web Kısayolu Oluşturma

Programlama ve Script dilleri konusunda bilgi paylaşım alanıdır.
Cevapla
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15656
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2738 kez
Teşekkür edildi: 5660 kez

GNU/Linux'ta Web Kısayolu Oluşturma

Mesaj gönderen TRWE_2012 »

Merhabalar

Windows tarafında .URL formatında web kısayolu oluşturmak kolaydır.(İki tıklatmaya bakar)
Resim
Ama iş, GNU/Linux tarafına gelince çıkmaza girer ama fazla değil...Burada devreye otomasyon girmekle beraber kodlanacak bir bash shell betiği iş görür ve bu ufak sorunu çözer...
Resim
KOD İÇERİĞİ : ( create_web_shortcut.sh )

Kod: Tümünü seç


#!/bin/bash
export LANG=tr_TR.UTF-8
export LC_ALL=tr_TR.UTF-8

# create_web_shortcut.sh
# Creates a cross-platform web shortcut pair:
#   - a .desktop link file for GNU/Linux desktop environments
#   - a .url link file (Windows Internet Shortcut format, CRLF line endings)
# Useful for dual-boot systems where the shortcut should work under both OSes,
# for example when saved to a shared NTFS data partition.

set -e

DEFAULT_DIR="$HOME/Desktop"

echo "Where should the shortcut files be saved?"
echo "Leave empty to use the default Linux Desktop folder: $DEFAULT_DIR"
echo "Tip: to make the shortcut usable from Windows too, point this to a"
echo "shared NTFS partition mount point, e.g. /media/linuxmaster/Data"
read -rp "Target directory: " TARGET_DIR

if [ -z "$TARGET_DIR" ]; then
    TARGET_DIR="$DEFAULT_DIR"
fi

if [ ! -d "$TARGET_DIR" ]; then
    echo "Directory not found: $TARGET_DIR"
    echo "Creating it now."
    mkdir -p "$TARGET_DIR"
fi

read -rp "Enter the web address (e.g. https://example.com): " WEB_URL

if [ -z "$WEB_URL" ]; then
    echo "No URL entered. Aborting."
    read -rp $'\nPress ENTER to exit.' _
    exit 1
fi

read -rp "Enter a name for the shortcut (e.g. Example Site): " SHORTCUT_NAME

if [ -z "$SHORTCUT_NAME" ]; then
    SHORTCUT_NAME="Web Shortcut"
fi

# Sanitize filename: replace spaces with underscores
FILE_SAFE_NAME=$(echo "$SHORTCUT_NAME" | tr ' ' '_')

DESKTOP_FILE="$TARGET_DIR/${FILE_SAFE_NAME}.desktop"
URL_FILE="$TARGET_DIR/${FILE_SAFE_NAME}.url"

# --- Linux .desktop file ---
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Version=1.0
Type=Link
Name=$SHORTCUT_NAME
Comment=Shortcut to $WEB_URL
URL=$WEB_URL
Icon=text-html
EOF

chmod +x "$DESKTOP_FILE"

# --- Windows .url file (Internet Shortcut format, requires CRLF line endings) ---
# Includes the extended metadata blocks that Windows Explorer normally adds
# automatically (icon/property cache CLSID block and empty IDList field).
# These are not required for the shortcut to function, but make the file
# structurally identical to a native Explorer-generated .url file.
printf '[{000214A0-0000-0000-C000-000000000046}]\r\nProp3=19,11\r\n[InternetShortcut]\r\nIDList=\r\nURL=%s\r\n' "$WEB_URL" > "$URL_FILE"

echo ""
echo "Shortcuts created successfully:"
echo "  Linux:   $DESKTOP_FILE"
echo "  Windows: $URL_FILE"
echo ""
echo "Notes:"
echo "1. On Linux, you may need to right-click the .desktop file and select"
echo "   'Allow Launching' or 'Mark as Trusted' the first time you use it."
echo "2. The .url file only works correctly when opened from Windows"
echo "   (double-click launches the default browser)."
echo "3. If TARGET_DIR is on the shared NTFS data partition (sda1), both"
echo "   files will be visible and usable from Windows and Linux Mint alike,"
echo "   though each OS will only recognize its own matching format."

read -rp $'\nPress ENTER to exit.' _

SONUÇ :
Resim
Güle güle kullanın GNU/Linux Sisteminiz de.....
Cevapla

“Programlama ve Script dilleri” sayfasına dön