WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: OnDemand for LXDE  (Read 2951 times)

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
OnDemand for LXDE
« on: December 29, 2009, 03:00:18 AM »
I loved the idea of the OnDemand script, however the current version in TC works only for FLWM, which isn't much good for anyone using anything else..

This is a version I hacked together for those of us making use of the LXDE desktop environment.

Code: [Select]
#!/bin/sh
# (c) Robert Shingledecker 2009
# Edited by Justin Steward (Althalus) for compatibility with LXDE.
[ "$DESKTOP" == "lxde" ] || exit 1
[ -s /opt/.tce_dir ] || exit 1
TCEDIR="$(cat /opt/.tce_dir)"
TMP=/tmp/ondemand.$$.tmp
ls "$TCEDIR"/optional | grep -E .tcz[ml]*$ > "$TMP"
select "OnDemand Tool for LXDE" "$TMP"
EXTN="$(cat /tmp/select.ans)"
rm "$TMP"
[ "$EXTN" == "" ] && exit
APPNAME="${EXTN%%.*}"

TITLE="$APPNAME"
echo
echo -n "Title: $TITLE (to change enter): "; read ANS
if [ "$ANS" != "" ]; then
  TITLE="$ANS"
  echo "Title changed to: $TITLE"
fi 

BINARY="$APPNAME"
echo
echo -n "Binary: $BINARY (to change enter or 'none'): "; read ANS
if [ "$ANS" != "" ]; then
  BINARY="$ANS"
  echo "Binary changed to: $BINARY"
fi 

[ -d /home/"$USER"/.ondemand ] || mkdir -p /home/"$USER"/.ondemand
FILE=/home/"$USER"/.ondemand/"$TITLE"
echo '#!/bin/sh' > "$FILE"
echo '[ -e /opt/.tce_dir ] || exit 1' >> "$FILE"
echo 'read TCEDIR < /opt/.tce_dir' >> "$FILE"
echo '[ -e /usr/local/tce.installed/'"$APPNAME"' ] && exit 0' >> "$FILE"
echo 'tce-load -i "$TCEDIR"/optional/'"$EXTN" >> "$FILE"
if [ "$BINARY" != "none" ]; then
  echo '[ $(which '"$BINARY"') ] && '"$BINARY" >> "$FILE"
fi
chmod +x "$FILE"

[ -d /home/${USER}/.local/share/applications ] || mkdir -p /home/${USER}/.local/share/applications
MENUENTRY="/home/${USER}/.local/share/applications/${BINARY}.desktop"
echo "[Desktop Entry]" > ${MENUENTRY}
echo "Name=${TITLE} OnDemand" >> ${MENUENTRY}
echo "Comment=${TITLE} OnDemand" >> ${MENUENTRY}
echo "Exec=${FILE}" >> ${MENUENTRY}
echo "Terminal=False" >> ${MENUENTRY}
echo "Type=Application" >> ${MENUENTRY}
echo "Categories=OnDemand;" >> ${MENUENTRY}

Currently, entries show up in "Other" - Creating a new directory doesn't seem as easy as creating an application entry in the menu - Maybe this could be included as part of the lxpanel extension?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7035
    • My Community Forum
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: OnDemand for LXDE
« Reply #2 on: December 29, 2009, 03:46:18 AM »
I'm not sure how that relates to the OnDemand feature? TC2freedesktop works with wbar icons, neither the flwm version of ondemand nor mine create wbar icons.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7035
    • My Community Forum
Re: OnDemand for LXDE
« Reply #3 on: December 29, 2009, 04:05:11 AM »
I'm not sure how that relates to the OnDemand feature? TC2freedesktop works with wbar icons, neither the flwm version of ondemand nor mine create wbar icons.

Common is that both are creating standard menu entries for LXDE. Of course they are different.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: OnDemand for LXDE
« Reply #4 on: December 30, 2009, 03:12:49 PM »
Code: [Select]
#!/bin/sh
# (c) Robert Shingledecker 2009
# Edited by Justin Steward (Althalus) for compatibility with LXDE.
[ "$DESKTOP" == "lxde" ] || exit 1
[ -s /opt/.tce_dir ] || exit 1
TCEDIR="$(cat /opt/.tce_dir)"
TMP=/tmp/ondemand.$$.tmp
ls "$TCEDIR"/optional | grep -E .tcz[ml]*$ > "$TMP"
select "OnDemand Tool for LXDE" "$TMP"
EXTN="$(cat /tmp/select.ans)"
rm "$TMP"
[ "$EXTN" == "" ] && exit
APPNAME="${EXTN%%.*}"

TITLE="$APPNAME"
echo
echo -n "Title: $TITLE (to change enter): "; read ANS
if [ "$ANS" != "" ]; then
  TITLE="$ANS"
  echo "Title changed to: $TITLE"
fi 

BINARY="$APPNAME"
echo
echo -n "Binary: $BINARY (to change enter or 'none'): "; read ANS
if [ "$ANS" != "" ]; then
  BINARY="$ANS"
  echo "Binary changed to: $BINARY"
fi 

[ -d /home/"$USER"/.ondemand ] || mkdir -p /home/"$USER"/.ondemand
FILE=/home/"$USER"/.ondemand/"$TITLE"
echo '#!/bin/sh' > "$FILE"
echo '[ -e /opt/.tce_dir ] || exit 1' >> "$FILE"
echo 'read TCEDIR < /opt/.tce_dir' >> "$FILE"
echo '[ -e /usr/local/tce.installed/'"$APPNAME"' ] && exit 0' >> "$FILE"
echo 'tce-load -i "$TCEDIR"/optional/'"$EXTN" >> "$FILE"
if [ "$BINARY" != "none" ]; then
  echo '[ $(which '"$BINARY"') ] && '"$BINARY" >> "$FILE"
fi
chmod +x "$FILE"

[ -d /home/${USER}/.local/share/applications ] || mkdir -p /home/${USER}/.local/share/applications
MENUENTRY="/home/${USER}/.local/share/applications/${FILE}.desktop"
echo "[Desktop Entry]" > ${MENUENTRY}
echo "Name=${TITLE} OnDemand" >> ${MENUENTRY}
echo "Comment=${TITLE} OnDemand" >> ${MENUENTRY}
echo "Exec=${BINARY}" >> ${MENUENTRY}
echo "Terminal=False" >> ${MENUENTRY}
echo "Type=Application" >> ${MENUENTRY}
echo "Categories=OnDemand;" >> ${MENUENTRY}
Slightly corrected version.

Offline baz

  • Full Member
  • ***
  • Posts: 216
Re: OnDemand for LXDE
« Reply #5 on: January 02, 2010, 06:05:02 PM »
bmarkus, I installed tc2freedesktop.tcz, then I installed other applications like vlc and opera however I didn't see them pop-up in the LXDE menu. Is there something else I need to do?


Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7035
    • My Community Forum
Re: OnDemand for LXDE
« Reply #6 on: January 03, 2010, 04:24:35 AM »
bmarkus, I installed tc2freedesktop.tcz, then I installed other applications like vlc and opera however I didn't see them pop-up in the LXDE menu. Is there something else I need to do?



VLC installs its menu for LXDE/Xfce4 itself, no need for any extra step. See LXDE Sound & Video menu.

You must run tc2freedesktop in a console or add to LXDE startup. Opera will be added to 'System Tools' menu.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."