diff --git a/gui/scripts/linux/create-shortcuts.sh b/gui/scripts/linux/create-shortcuts.sh new file mode 100644 index 000000000..b7775ce6a --- /dev/null +++ b/gui/scripts/linux/create-shortcuts.sh @@ -0,0 +1,122 @@ +#!/bin/bash + +# IDEasy GUI Shortcut Creator for Linux +# Creates .desktop files for easy GUI launching from the Application Menu and Desktop +# Supports: GNOME, KDE, XFCE, and other freedesktop-compatible environments + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +LAUNCHER_SCRIPT="$SCRIPT_DIR/launch-gui.sh" +ICON_PATH="$SCRIPT_DIR/../../src/main/resources/com/devonfw/ide/gui/assets/devonfw.png" + +# Set error handling - exit on error but allow catching specific errors +set -o pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +function print_error() { + echo -e "${RED}Error: $1${NC}" >&2 +} + +function print_success() { + echo -e "${GREEN}✓ $1${NC}" +} + +function print_info() { + echo -e "${YELLOW}ℹ $1${NC}" +} + +# Verify launcher script exists and is executable +if [ ! -f "$LAUNCHER_SCRIPT" ]; then + print_error "Launcher script not found: $LAUNCHER_SCRIPT" + exit 1 +fi + +chmod +x "$LAUNCHER_SCRIPT" + +# Resolve icon: use bundled devonfw.png if available, otherwise fall back to system theme +if [ -f "$ICON_PATH" ]; then + ICON="$(cd "$(dirname "$ICON_PATH")" && pwd)/$(basename "$ICON_PATH")" +else + ICON="application-x-executable" +fi + +# Create Desktop Entry (.desktop file) +function create_desktop_entry() { + local target_dir="$1" + local desktop_file="$target_dir/ideasy-gui.desktop" + + if ! mkdir -p "$target_dir" 2>/dev/null; then + print_error "Failed to create directory: $target_dir" + return 1 + fi + + if ! cat > "$desktop_file" </dev/null; then + print_error "Failed to make executable: $desktop_file" + return 1 + fi + + print_success "Created: $desktop_file" + return 0 +} + +# Create application menu entry +APPLICATIONS_DIR="$HOME/.local/share/applications" +if ! create_desktop_entry "$APPLICATIONS_DIR"; then + print_info "Note: Could not create application menu entry (may require additional permissions)" +else + # Refresh the application menu database so the entry appears immediately + update-desktop-database "$APPLICATIONS_DIR" 2>/dev/null || true + print_info "Launch from: Application Menu or Launcher" +fi + +# Determine desktop directory via XDG standard (respects custom Desktop locations). +# On systems where xdg-user-dirs was never configured (e.g. minimal WM setups), +# xdg-user-dir falls back to printing $HOME itself — guard against that so we +# don't drop a loose .desktop file directly into the user's home directory. +DESKTOP_DIR=$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME/Desktop") +DESKTOP_DIR="${DESKTOP_DIR%/}" +if [ -z "$DESKTOP_DIR" ] || [ "$DESKTOP_DIR" = "$HOME" ]; then + DESKTOP_DIR="$HOME/Desktop" +fi +if [ -d "$DESKTOP_DIR" ]; then + if ! create_desktop_entry "$DESKTOP_DIR"; then + print_info "Note: Desktop entry creation requires write permissions" + else + # GNOME 3.28+: mark desktop file as trusted so it can be launched by double-click + gio set "$DESKTOP_DIR/ideasy-gui.desktop" "metadata::trusted" true 2>/dev/null || true + print_info "Launch from: Desktop" + fi +else + print_info "Desktop directory not found (Desktop feature may not be available)" +fi + +echo "" +print_success "IDEasy GUI shortcuts ready!" +echo "" +echo "Usage:" +echo " • Open your Application Menu and search for 'IDEasy GUI'" +echo " • Or double-click the shortcut on your Desktop" +echo " • First launch may take longer as Maven downloads dependencies" +echo "" diff --git a/gui/scripts/linux/launch-gui.sh b/gui/scripts/linux/launch-gui.sh new file mode 100644 index 000000000..84bf50894 --- /dev/null +++ b/gui/scripts/linux/launch-gui.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# IDEasy GUI Launcher for Linux +# This script launches the IDEasy GUI using the native 'ide gui' command +# The GUI runs in the background, the script exits immediately + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +LOG_FILE="$HOME/.ideasy-gui.log" + +# When launched from an application menu (Terminal=false), there is no console to +# show errors on. Redirect everything to a log file from the start so failures +# (e.g. 'ide' missing from the launcher's PATH) are diagnosable after the fact +exec >> "$LOG_FILE" 2>&1 +echo "---- $(date) ----" + +function notify_error() { + command -v notify-send &> /dev/null && notify-send -i dialog-error "IDEasy GUI" "$1" +} + +if [ ! -f "$PROJECT_ROOT/pom.xml" ]; then + echo "Error: IDEasy project root not found at $PROJECT_ROOT" + echo "Please ensure this script is located in: IDEasy/gui/scripts/linux/" + notify_error "Project root not found at $PROJECT_ROOT" + exit 1 +fi + +# 'ide' is a shell function defined in $IDE_ROOT/_ide/installation/functions and +# sourced by ~/.bashrc / ~/.zshrc — those only get sourced in interactive shells. +# Application launchers (Terminal=false) start a plain, non-interactive shell, so +# 'ide' is invisible there even though it works fine from a terminal. Route through +# an interactive bash so the function gets sourced regardless of launch context. +if ! bash -ic "command -v ide" &> /dev/null; then + echo "Error: IDEasy is not installed or not in PATH" + echo "Please install IDEasy first: https://github.com/devonfw/IDEasy#setup" + notify_error "'ide' command not found (see $LOG_FILE)" + exit 1 +fi + +cd "$PROJECT_ROOT" + +# Launch IDE GUI in background and exit immediately +bash -ic "ide gui" & + +exit 0 diff --git a/gui/scripts/macos/create-shortcuts.sh b/gui/scripts/macos/create-shortcuts.sh new file mode 100644 index 000000000..4e262b948 --- /dev/null +++ b/gui/scripts/macos/create-shortcuts.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +# IDEasy GUI Shortcut Creator for macOS +# Creates shortcuts for easy GUI launching from Finder +# Supports creating: Applications folder alias and Desktop alias + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +LAUNCHER_SCRIPT="$SCRIPT_DIR/launch-gui.command" + +# Set error handling - exit on error but allow catching specific errors +set -o pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +function print_error() { + echo -e "${RED}Error: $1${NC}" >&2 +} + +function print_success() { + echo -e "${GREEN}✓ $1${NC}" +} + +function print_info() { + echo -e "${YELLOW}ℹ $1${NC}" +} + +# Verify launcher script exists and is executable +if [ ! -f "$LAUNCHER_SCRIPT" ]; then + print_error "Launcher script not found: $LAUNCHER_SCRIPT" + exit 1 +fi + +chmod +x "$LAUNCHER_SCRIPT" + +# Create an alias/shortcut using osascript (AppleScript) +# Falls back to a symlink if Finder is not running or AppleScript fails +function create_alias() { + local source="$1" + local target_dir="$2" + local target_name="$3" + + if [ ! -f "$source" ]; then + print_error "Source file not found: $source" + return 1 + fi + + if ! mkdir -p "$target_dir" 2>/dev/null; then + print_error "Failed to create directory: $target_dir" + return 1 + fi + + # Properly escape paths for AppleScript + local escaped_source="$(printf '%s\n' "$source" | sed 's/\\/\\\\/g; s/"/\\"/g')" + local escaped_target_dir="$(printf '%s\n' "$target_dir" | sed 's/\\/\\\\/g; s/"/\\"/g')" + local escaped_target_name="$(printf '%s\n' "$target_name" | sed 's/\\/\\\\/g; s/"/\\"/g')" + + local output + output=$(osascript 2>&1 </dev/null; then + print_success "Created symlink: $target_dir/$target_name.command" + return 0 + fi + + print_error "Failed to create shortcut: $target_dir/$target_name" + [ -n "$output" ] && print_error "Reason: $output" + return 1 +} + +# Create Applications alias +APPS_DIR="$HOME/Applications" +if ! create_alias "$LAUNCHER_SCRIPT" "$APPS_DIR" "IDEasy GUI"; then + print_info "Note: Could not create Applications shortcut (may require additional permissions)" +else + print_info "Launch from: Applications > IDEasy GUI" +fi + +# Create Desktop alias +DESKTOP_DIR="$HOME/Desktop" +if create_alias "$LAUNCHER_SCRIPT" "$DESKTOP_DIR" "IDEasy GUI"; then + print_info "Launch from: Desktop" +else + print_info "Note: Desktop shortcut creation requires manual steps" + print_info "You can manually create a shortcut by:" + print_info "1. Open Finder" + print_info "2. Go to $SCRIPT_DIR" + print_info "3. Right-click 'launch-gui.command' → Make Alias" + print_info "4. Drag alias to Desktop or Applications" +fi + +echo "" +print_success "IDEasy GUI shortcuts ready!" +echo "" +echo "Usage:" +echo " • Open Finder and go to Applications" +echo " • Double-click 'IDEasy GUI' to launch" +echo " • Or double-click the Desktop shortcut" +echo "" diff --git a/gui/scripts/macos/launch-gui.command b/gui/scripts/macos/launch-gui.command new file mode 100644 index 000000000..91618250f --- /dev/null +++ b/gui/scripts/macos/launch-gui.command @@ -0,0 +1,34 @@ +#!/bin/bash + +# IDEasy GUI Launcher for macOS +# This script launches the IDEasy GUI using the native 'ide gui' command +# The GUI runs in the background, the script exits immediately + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" + +if [ ! -f "$PROJECT_ROOT/pom.xml" ]; then + echo "Error: IDEasy project root not found at $PROJECT_ROOT" + echo "Please ensure this script is located in: IDEasy/gui/scripts/macos/" + read -p "Press Enter to close..." + exit 1 +fi + +if ! command -v ide &> /dev/null; then + echo "" + echo "Error: IDEasy is not installed" + echo "" + echo "Please install IDEasy first:" + echo "https://github.com/devonfw/IDEasy#setup" + echo "" + read -p "Press Enter to close..." + exit 1 +fi + +cd "$PROJECT_ROOT" + +# Launch IDE GUI in background and exit immediately +LOG_FILE="$HOME/.ideasy-gui.log" +ide gui >> "$LOG_FILE" 2>&1 & + +exit 0 diff --git a/gui/scripts/windows/create-shortcuts.ps1 b/gui/scripts/windows/create-shortcuts.ps1 new file mode 100644 index 000000000..f1c122689 --- /dev/null +++ b/gui/scripts/windows/create-shortcuts.ps1 @@ -0,0 +1,140 @@ +#Requires -Version 5.0 + +# IDEasy GUI Launcher - Create Windows Start Menu Shortcut and Desktop Link +# This script creates shortcuts to launch the IDEasy GUI from Windows Start Menu and Desktop + +param ( + [switch]$SkipDesktop, + [switch]$SkipStartMenu +) + +$ErrorActionPreference = 'Stop' + +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$guiDir = Split-Path -Parent (Split-Path -Parent $scriptDir) +$projectRoot = Split-Path -Parent $guiDir + +$launcherBat = Join-Path $scriptDir "launch-gui.bat" +$pomFile = Join-Path $projectRoot "pom.xml" + +if (-not (Test-Path $launcherBat)) { + Write-Host "Error: launch-gui.bat not found" -ForegroundColor Red + exit 1 +} + +if (-not (Test-Path $pomFile)) { + Write-Host "Error: pom.xml not found" -ForegroundColor Red + exit 1 +} + +Write-Host "IDEasy GUI Launcher Setup" -ForegroundColor Cyan +Write-Host "Project: $projectRoot" -ForegroundColor Cyan +Write-Host "" + +# Wrap the PNG bytes directly into an ICO container (Windows Vista+ supports PNG frames in ICO). +# This preserves full color depth and alpha transparency without any image processing. +# The ICO is written next to the scripts so the shortcut has a stable reference path. +# Returns $true on success, $false on failure. +function Convert-PngToIco { + param([string]$PngPath, [string]$IcoPath) + try { + $pngBytes = [System.IO.File]::ReadAllBytes($PngPath) + + # PNG dimensions are stored big-endian in the IHDR chunk at bytes 16-23 + $width = ($pngBytes[16] -shl 24) -bor ($pngBytes[17] -shl 16) -bor ($pngBytes[18] -shl 8) -bor $pngBytes[19] + $height = ($pngBytes[20] -shl 24) -bor ($pngBytes[21] -shl 16) -bor ($pngBytes[22] -shl 8) -bor $pngBytes[23] + + # ICO directory encodes 256 as 0 + $icoW = if ($width -ge 256) { [byte]0 } else { [byte]$width } + $icoH = if ($height -ge 256) { [byte]0 } else { [byte]$height } + + $sizeBytes = [System.BitConverter]::GetBytes([int32]$pngBytes.Length) + $offsetBytes = [System.BitConverter]::GetBytes([int32](6 + 16)) # header(6) + one dir entry(16) + + # ICO header (6 bytes) + single directory entry (16 bytes) + $icoHeader = [byte[]]( + 0x00, 0x00, # reserved + 0x01, 0x00, # type: icon + 0x01, 0x00, # image count: 1 + $icoW, $icoH, 0x00, 0x00, # w, h, colorCount, reserved + 0x01, 0x00, # color planes + 0x20, 0x00, # bits per pixel (32) + $sizeBytes[0], $sizeBytes[1], $sizeBytes[2], $sizeBytes[3], # image data size + $offsetBytes[0], $offsetBytes[1], $offsetBytes[2], $offsetBytes[3] # image data offset + ) + + $stream = [System.IO.FileStream]::new($IcoPath, [System.IO.FileMode]::Create) + $stream.Write($icoHeader, 0, $icoHeader.Length) + $stream.Write($pngBytes, 0, $pngBytes.Length) + $stream.Close() + return $true + } + catch { + return $false + } +} + +# Resolve icon location: prefer devonfw.png converted to ICO, fall back to shell32 +$pngSource = Join-Path $guiDir "src\main\resources\com\devonfw\ide\gui\assets\devonfw.png" +$generatedIco = Join-Path $scriptDir "ideasy-gui.ico" +$iconLocation = "$env:SystemRoot\system32\shell32.dll,1" + +if (Test-Path $pngSource) { + if (-not (Test-Path $generatedIco)) { + if (Convert-PngToIco -PngPath $pngSource -IcoPath $generatedIco) { + Write-Host "Icon generated from devonfw.png" -ForegroundColor Cyan + } else { + Write-Host "Note: Icon conversion failed, using default icon" -ForegroundColor Yellow + } + } + if (Test-Path $generatedIco) { + $iconLocation = "$generatedIco,0" + } +} elseif (Test-Path (Join-Path $scriptDir "icon.ico")) { + $iconLocation = "$(Join-Path $scriptDir 'icon.ico'),0" +} + +function Create-Shortcut { + param( + [string]$Path, + [string]$Target, + [string]$Description + ) + + $wshShell = $null + try { + Write-Host "Creating shortcut: $Path" + + $wshShell = New-Object -ComObject WScript.Shell + $shortcut = $wshShell.CreateShortcut($Path) + $shortcut.TargetPath = $Target + $shortcut.WorkingDirectory = $projectRoot + $shortcut.Description = $Description + $shortcut.IconLocation = $iconLocation + + $shortcut.Save() + Write-Host "Created: $Path" -ForegroundColor Green + } + catch { + Write-Host "Error creating shortcut: $($_.Exception.Message)" -ForegroundColor Red + } + finally { + if ($wshShell) { + [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wshShell) | Out-Null + } + } +} + +if (-not $SkipDesktop) { + # Use Shell32 to resolve the Desktop folder — works correctly with OneDrive-redirected Desktops + $desktopShortcut = Join-Path ([Environment]::GetFolderPath('Desktop')) "IDEasy GUI.lnk" + Create-Shortcut -Path $desktopShortcut -Target $launcherBat -Description "Launch IDEasy GUI" +} + +if (-not $SkipStartMenu) { + $startMenuShortcut = Join-Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs" "IDEasy GUI.lnk" + Create-Shortcut -Path $startMenuShortcut -Target $launcherBat -Description "Launch IDEasy GUI" +} + +Write-Host "" +Write-Host "Setup complete!" -ForegroundColor Green diff --git a/gui/scripts/windows/launch-gui.bat b/gui/scripts/windows/launch-gui.bat new file mode 100644 index 000000000..753ed321a --- /dev/null +++ b/gui/scripts/windows/launch-gui.bat @@ -0,0 +1,50 @@ +@echo off +setlocal + +REM IDEasy GUI Launcher for Windows + +set "SCRIPT_DIR=%~dp0" + +REM Desktop/Start-Menu shortcuts are spawned by explorer.exe, which caches its +REM environment from login and does not pick up registry PATH/IDE_ROOT changes +REM made by the IDEasy installer until the user logs off or restarts explorer. +REM Re-read IDE_ROOT directly from the registry and extend PATH with it here, +REM so the shortcut works even with explorer's stale inherited environment. +if not defined IDE_ROOT ( + for /f "tokens=2,*" %%A in ('reg query "HKCU\Environment" /v IDE_ROOT 2^>nul') do set "IDE_ROOT=%%B" +) +if defined IDE_ROOT ( + set "PATH=%IDE_ROOT%\_ide\installation\bin;%PATH%" +) + +REM Check if ide command exists +where ide >nul 2>&1 || ( + echo. + echo Error: IDEasy is not installed or not in PATH + echo If you just installed IDEasy, log off/on once or restart Explorer so + echo the desktop shortcut picks up the updated environment. + echo https://github.com/devonfw/IDEasy#setup + echo. + pause + exit /b 1 +) + +REM Determine project root safely +pushd "%SCRIPT_DIR%..\..\.." +set "PROJECT_ROOT=%CD%" +popd + +REM Check project structure +if not exist "%PROJECT_ROOT%\pom.xml" ( + echo Error: IDEasy project root not found at %PROJECT_ROOT% + echo. + pause + exit /b 1 +) + +REM Launch GUI +cd /d "%PROJECT_ROOT%" +echo Starting IDEasy GUI... +START "" /B ide gui >> "%USERPROFILE%\.ideasy-gui.log" 2>&1 + +exit /b 0