Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get sqldeveloper icon to show in my unity bar

I'm setting up Ubuntu 13.10 on a Dell desktop. I've installed sqldeveloper and have a created a sqldeveoper.desktop file in my Desktop/ dir to launch the program. See code below. My problem is this: on my desktop screen I see the .desktop file as a sqldeveloper icon (the round db icon with a green arrow on it). I double-click the icon and the program launches. The icon appears in my Unity bar and then the image changes to a '?' question-mark symbol.

Any ideas why this happens? The icon.png (image) is in the location the desktop file is pointing to. Maybe the file is not seeing the path correctly from the Unity bar?

sqldeveloper.desktop code:

[Desktop Entry]
Type=Application
Version=1.0
Name=SQL Developer
GenericName=Oracle Development Environment
Comment=Proprietary environment for managing Oracle databases
Exec=sqldeveloper %F
Icon=/opt/sqldeveloper/icon.png
Terminal=false
Categories=Development;IDE;
StartupNotify=true

Thanks for any direction in this. JohnC

like image 981
John Cowan Avatar asked Oct 20 '22 16:10

John Cowan


1 Answers

Background

In version 4.1.5 of SQL Developer, the splash screen has WM_CLASS(STRING) = oracle-ide-osgi-boot-OracleIdeLauncher. Setting this as the value for key StartupWMClass in your .desktop file will work fine at first while the splash screen is visible.

The problem comes when SQL Developer's main window appears, because this second window has the generic WM_CLASS(STRING) = sun-awt-X11-XFramePeer only. Setting this generic value for StartupWMClass in your .desktop file doesn't work for reasons I don't fully understand.

A working solution for this problem is a .desktop file that uses a custom bash script. The custom script launches Oracle's startup script asynchronously, then waits for the main window to appear, and finally changes its WM_CLASS programmatically to the same value used by the splash screen. That WM_CLASS is also referred to by the .desktop file.

Custom bash script

Store this as $HOME/bin/launch-sqldeveloper.sh

#!/bin/bash
JAVA_HOME=/usr/lib/jvm/java-8-oracle
SQLD_HOME=/opt/sqldeveloper

# Launch Oracle's startup script asynchronously
env JAVA_HOME=$JAVA_HOME $SQLD_HOME/sqldeveloper.sh $* &

i="0"
while [ $i -lt 20 ]
do

# Try to get SQL Developer window ID
WIN_ID=$(xwininfo -root -tree \
| grep -i 'oracle sql developer' \
| grep -oP '(0x[a-f0-9]+)')

# If it is non-empty (window already exists)
if [ -n "$WIN_ID" ]
then
    echo "WIN_ID=$WIN_ID"

# Set WM_CLASS property of main window to same value
# that is used for the launcher window
    xprop -id $WIN_ID \
          -f WM_CLASS 8s \
          -set WM_CLASS "oracle-ide-osgi-boot-OracleIdeLauncher"

# and exit loop
    break
else

# Otherwise sleep for one second and increment loop counter
    echo "Sleeping: $i"
    sleep 1s
    i=$[$i+1]

fi
done
echo "Done"

.desktop File

[Desktop Entry]
Type=Application
Terminal=false
Name=SQL Developer
Exec=sh -c '$HOME/bin/launch-sqldeveloper.sh %F'
Icon=/opt/sqldeveloper/icon.png
StartupWMClass=oracle-ide-osgi-boot-OracleIdeLauncher
like image 172
lbo Avatar answered Nov 08 '22 14:11

lbo