Idesk desktop launcher script for FreeBSD

FreeBSD-idesk-linkmaker is a script for getting desktop laucher desktops like icewm, fluxbox, jwm, etc. Packages yad and idesk are required.

This script/program is not good, but it is the best available for making idesk launchers.

Custom launchers whose desktop files are located somewhere other than /usr/local/share/applications must be created manually.

The process:

Run FreeBSD-idesk-linkmaker.

Drag and drop desktop file. Desktop file must be into /usr/local/share/applications directory.

Drag and drop program or script.

Drag and drop an icon

New icon is into Desktop.

Code:
#!/bin/sh
## RPJ 4.9.2025 Idesk linkmaker for FreeBSD
# packages yad and idesk are required
# package icewm is recommended
# Name and caption works only with standart path (/usr/local/share/applications)
# For custom name and caption need to write/edit lnk-file by hand
#
#
###########################
### Program name dialog ###
###########################
xdg-open /usr/local/share/applications | \
yad --dnd --geometry=600x200 --on-top --no-buttons --center --title="Idesk desktop link program" --text="Drag and drop application for desktop into this box " | while read selection 
do
echo "$selection" | sed 's/file:\/\///' > /tmp/name.txt
#
sed -i '' "s|/usr/local/share/applications/||g" /tmp/name.txt
sed -i '' "s|.desktop||g" /tmp/name.txt
sleep 0,1
pkill yad

NAME=$(cat /tmp/name.txt)

###########################
##### Program dialog ######
###########################
xdg-open /usr/local/bin | \
yad --dnd --geometry=600x200 --on-top --no-buttons --center --title="Idesk desktop link program" --text="Drag and drop program for desktop link into this box " | while read selection 
do
echo "$selection" | sed 's/file:\/\///' > /tmp/prog.txt
#
sed -i '' "s|/usr/local/share/bin/||g" /tmp/prog.txt
sleep 0,1
pkill yad

PROG=$(cat /tmp/prog.txt)

###########################
### Program icon dialog ###
###########################

xdg-open /usr/local/share/icons | \
yad --dnd --geometry=600x200 --on-top --no-buttons --center --title="Idesk desktop link icon" --text="Drag and drop icon for desktop link into this box " | while read selection 
do
#
echo "$selection" | sed 's/file:\/\///' > /tmp/icon.txt
pkill yad

ICON=$(cat /tmp/icon.txt)

###########################
### build entry section ###
###########################

mkdir -p $HOME/.idesktop
{
echo 'table Icon'
echo "Caption: $NAME"
echo "ToolTip.Caption: $NAME"
echo "Icon: $ICON"
echo 'Width: 48'
echo 'Height: 48'
echo 'X: 400'
echo 'Y: 400'
echo "Command[0]: $PROG"
echo 'end'
} > $HOME/.idesktop/$NAME.lnk

done
done
done

sleep 1
KILLIDESK=$(pkill idesk)
/bin/sh -c "$KILLIDESK"
sleep 1
idesk &
exit 0

cd /tmp && rm icon.txt name.txt prog.txt

 
you may like to learn about posix shell substitutions and get rid of the sed and temp files abuse
Code:
TEST=file:////usr/local/share/applications/thunar.desktop
BASE=${TEST#file:////usr/local/share/applications/}
echo ${BASE%.desktop}
also don't hardwire tempfile names because if somehow you get to run the script concurrently it will cause race conditions
a quick hack is to use /tmp/somename.$$.tmp ($$ will be replaced by the shell's pid)
 
Back
Top