[Script Solved] doule click to activate/de module in Lxde !!

New features which should be implemented in Porteus; suggestions are welcome. All questions or problems with testing releases (alpha, beta, or rc) should go in their relevant thread here, rather than the Bug Reports section.
User avatar
KSA_ARAB
Black ninja
Black ninja
Posts: 52
Joined: 29 Dec 2010, 00:54
Location: Saudi Arabia
Contact:

[Script Solved] doule click to activate/de module in Lxde !!

Post#1 by KSA_ARAB » 25 Jan 2011, 00:41

hello every body,
for me it's better to work on Lxde because I have low RAM memory,
I deleted , kde.lzm + kdeapps.lzm, but I can not activate modules by double click !!!

so ,
I took a look in '/usr/bin/kactivate', I saw there is 'kdialog' but I deleted kde.lzm, kdeapps.lzm.
then I installed 'xdialog'
http://slackware.schoepfer.info/13.1/sl ... 86-1js.tgz
http://slackware.schoepfer.info/13.1_64 ... 4-1jsc.txz

then I modified 'kactivate' and replace 'kdialog' syntax , to 'Xdialog' syntax, to let script work on Lxde and KDE.

Code: Select all

#!/bin/bash
# This script is used in LXDE and KDE to provide a GUI for 'activate'
# It has the same syntax like 'activate', moreover it accepts HTTP addresses
# to be mounted remotely using httpfs
# (you may kactivate a LZM module over HTTP, no need to download it!)
#script modified by KSA_ARAB

PATH=.:$(dirname $0):/usr/lib:$PATH
. liblinuxlive || exit 127

# make sure to work only with *.lzm files
while [ "$(echo "$1" | grep '.lzm$')" = "" -a "$1" != "" ]; do shift; done

FILE="$1"

if [ "$FILE" = "" ]; then
   FILE=$(xdialog --icon folder_open --getopenurl "" "*.lzm" --title "Select LZM module")
   if [ $? -ne 0 ]; then exit 1; fi
   FILE=$(echo "$FILE" | sed -r "s,file://,,")
fi

BASE=$(basename "$FILE" 2>/dev/null)

# if the module is already activated, suggest deactivation
if ismountpoint "/mnt/live/memory/images/$BASE"; then
   Xdialog --yesno "Deactivate the module?" 6 30
   if [ $? -eq 0 ]; then deactivate $BASE; exit 0; fi
   exit 2
fi

SLIK=${FILE:0:4}

# handle slik (Slax Klik) and HTTP requests/urls
if [ "$SLIK" = "slik" -o "$SLIK" = "http" ]; then

   # if a module is loaded from untrusted site (everything else than slax.org, ask for confirmation)
   DOMAIN=$(echo "$FILE" | cut -b 8- | egrep -o "^(www.)?([^/]+)")
   DOMAIN=${DOMAIN##www.}
   if [ "$DOMAIN" != "slax.org" ]; then
      xdialog --icon configure --dontagain "kactivate:trust-$DOMAIN" --title "unsafe domain $DOMAIN" --warningyesno "Warning! You are about to load a module from $DOMAIN...\nThis may be unsafe. Are you sure?"
      if [ $? -ne 0 ]; then exit 127; fi
   fi

   MNT="/mnt/live/memory/httpfs/$BASE"
   mkdir -p "$MNT"
   xdialog --passivepopup "$BASE: module insertion in progress, wait please..." 10000 & KILLPID=$!
   ERR=$(httpfs http${FILE:4} "$MNT" 2>&1)
   if [ $? -ne 0 ]; then
      kill $KILLPID
      xdialog --icon error --title "network error" --error "Can't mount the module remotely.\nError message: $ERR\n\nTry to download the module to your computer."
      exit 128;
   fi
   echo "http${FILE:4}" >$MNT/slik.url
   kill $KILLPID
   FILE="$MNT/$BASE"
fi

# show info message and remember PID of the process (we'll need to kill the message later on)
Xdialog --msgbox "Module Insertion..." 6 25 10000 & KILLPID=$!

# insert the module to live filesystem
activate -k "$FILE"

if [ $? -ne 0 ]; then
   kill $KILLPID
   Xdialog --msgbox "error Module." 6 25
   exit 3
else
   # Rebuild the system configuration cache for KDE (mainly to update KDE menu)
   kbuildsycoca 2>/dev/null
   kill $KILLPID
   Xdialog --msgbox "Module Activated" 6 25 5 &
fi

exit 0

after that you can open module with command 'kactivate' , or
you need to add 'lzm' extension to PcmanFM file manager

Code: Select all

echo "application/octet-stream=userapp-kactivate-DKZMPV.desktop;" >> /root/.local/share/applications/mimeapps.list 
echo "[Desktop Entry]" >> /root/.local/share/applications/userapp-kactivate-DKZMPV.desktop
echo "Type=Application" >> /root/.local/share/applications/userapp-kactivate-DKZMPV.desktop
echo "Name=kactivate" >> /root/.local/share/applications/userapp-kactivate-DKZMPV.desktop
echo "Exec=lxactivate %f" >> /root/.local/share/applications/userapp-kactivate-DKZMPV.desktop
echo "NoDisplay=true" >> /root/.local/share/applications/userapp-kactivate-DKZMPV.desktop
Image

you are welcome to suggestions , fix it , or add.
regards

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: [Script Solved] doule click to activate/de module in Lxd

Post#2 by brokenman » 25 Jan 2011, 03:26

Excellent. Thanks very much, i will include it in next release. I should have used xdialog when i wrote it originally. I may include xdialog in next release and convert all kdialog scripts. Your help would be appreciated.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
KSA_ARAB
Black ninja
Black ninja
Posts: 52
Joined: 29 Dec 2010, 00:54
Location: Saudi Arabia
Contact:

Re: [Script Solved] doule click to activate/de module in Lxd

Post#3 by KSA_ARAB » 25 Jan 2011, 16:24

you are welcome :)
this script should remove from 004-kde.lzm and put it in 001-core.lzm.
I tried to convert others scripts for example, right click and chose 'dir2lzm,lzm2dir,txz2lzm,rpm2txz,deb2txz,installpkg tgz,txz'.
but really I am busy now, I will try to convert these on weekend.

thanks.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: [Script Solved] doule click to activate/de module in Lxd

Post#4 by brokenman » 26 Jan 2011, 00:43

I've put Xdialog in core for next release. I will hold off putting these scripts in though as extensions will change to .xzm for for porteus. Also this script does not include my modification to automatically convert older sq3 modules to sq4 if called. I will also add a function to convert .lzm to .xzm automatically.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
KSA_ARAB
Black ninja
Black ninja
Posts: 52
Joined: 29 Dec 2010, 00:54
Location: Saudi Arabia
Contact:

Re: [Script Solved] doule click to activate/de module in Lxd

Post#5 by KSA_ARAB » 26 Jan 2011, 09:00

good ,
will try new version and let you know if it need to fix or add something.
thanks.

Post Reply