Author Topic: Axel + Zenity  (Read 1460 times)

Offline brilz

  • Full Member
  • ***
  • Posts: 107
Axel + Zenity
« on: November 17, 2011, 03:50:17 AM »
hi guys (and girls).. :)

i just made this simple script for the better use of axel integration on web browser,,

it's working with flashgot add-on for firefox and download assistant for chrome

just save this script and make it executable.and make sure you change every file path to your own local path :)

Quote
#!/bin/bash


#choose the file type

ans=$(zenity  --list  --text "Choose File Type" --radiolist  --column "Pick" --column "Tipe" TRUE "Video & Music" FALSE "Document & Picture" FALSE "Program & Game" FALSE Other --width 400 --height 300);

#go to a folder based on previous answer

case "$ans" in
"Video & Lagu")
cd ~/DropBox/Video
;;
"Document & Picture")
cd ~/DropBox/Document
;;
"Program & Game")
cd ~/DropBox/Program
;;
"Other")
cd ~/DropBox/Other
esac

#make some log

echo Axel:download from ["$1"] at:[`date`] >>~/cloudcity/ax.log

#downloading with zenity GUI progress

axel -n 10 "$1" |sed -un 's_^.* \([0-9]\+%\).* \([0-9.]\+[GMKB]\).*_#Downloading:...........[\1]Speed:.........[\2B]_p' |zenity --progress --pulsate --auto-close --width 500

#notification part.just use your preferred player and music file

cvlc --no-loop --play-and-exit ~/DropBox/i.ogg |zenity --notification --text "Download Process is Finished"


for firefox:open flashgot option menu>General Tab>add and browse>your script location
ex:


for chrome: save the executable script in /usr/bin then open download assistant option menu from chrome extension manager..fill the command box with your-script-name "$URL"
ex:



that's it..enjoy ;)


--------------------------------------------------------
Acer 4740 i3 2,1ghz 1gb ddr3 intel gma hd 320gb sata, PcLinuxOS kde4

Offline brilz

  • Full Member
  • ***
  • Posts: 107
Re: Axel + Zenity
« Reply #1 on: November 17, 2011, 03:55:00 AM »
for other browser..i made some modification so that the script would stand as a standalone downloader with URL input function

here's the script

Quote
#!/bin/bash

url=$(zenity --entry --text "Enter a Url")

#choose the file type

ans=$(zenity  --list  --text "Pilih Jenis File" --radiolist  --column "Pilih" --column "Tipe" TRUE "Video & Lagu" FALSE "Document & Picture" FALSE "Program & Game" FALSE Other --width 400 --height 300);

#go to a folder based on previous answer

case "$ans" in
"Video & Lagu")
cd ~/DropBox/Video
;;
"Document & Picture")
cd ~/DropBox/Document
;;
"Program & Game")
cd ~/DropBox/Program
;;
"Other")
cd ~/DropBox/Other
esac

#make some log

echo Axel:download from ["$url"] at:[`date`] >>~/cloudcity/ax.log

#downloading with zenity GUI progress

axel -n 10 "$url" |sed -un 's_^.* \([0-9]\+%\).* \([0-9.]\+[GMKB]\).*_#Downloading:...........[\1]Speed:.........[\2B]_p' |zenity --progress --pulsate --auto-close --width 500

#notification part.just use your preferred player and music file

cvlc --no-loop --play-and-exit /home/frozen/DropBox/i.ogg |zenity --notification --text "Download Process is Finished"


Quote
Some Screenshots







« Last Edit: November 17, 2011, 03:57:05 AM by brilz »


--------------------------------------------------------
Acer 4740 i3 2,1ghz 1gb ddr3 intel gma hd 320gb sata, PcLinuxOS kde4

Offline brilz

  • Full Member
  • ***
  • Posts: 107
Re: Axel + Zenity
« Reply #2 on: November 17, 2011, 06:46:19 PM »
since this thread has been moved to the advanced section,,i might as well ask some suggestion to the script,no? ;D

1. the zenity progress bar is supposed to show real progress not just pulsating back and forth..but i can't get it to work.my guess is i messed something in sed regular expression but i dont know which part.

2. i'm thinking of using gtkdialog so that every command box can be put into a window,and got the basic idea of how to use it for this script,but the axel - sed - zenity part of the script just not fit in gtkdialog xml format..and i'd like to ask how the "case statement" of my script can be put into gtkdialog radiolist action.

here's the draft,,yes i know this script is plain wrong..just bear with me please :)

Quote
#!/bin/bash

export main='
<window><frame Axel DM>
<hbox>
     <text><label>Add URL</label></text>
    <entry><variable>url</variable></entry>
</hbox>


<hbox homogeneous="true" spacing="20">
    <button>
    <label>Download now!</label>
    <action>axel -n 10 '$url' --output '$places' &</action>
  </button>
</hbox>

</frame>
<frame>
<hbox>
<list>
<variable>LIST</variable>
<item>First item</item>
<item>Second item</item>
<item>Third item</item>
<action>echo Chosen item is $LIST</action>
</list>
</hbox>
</frame>
</window>
'

gtkdialog --program=main


--------------------------------------------------------
Acer 4740 i3 2,1ghz 1gb ddr3 intel gma hd 320gb sata, PcLinuxOS kde4

Offline brilz

  • Full Member
  • ***
  • Posts: 107
Re: Axel + Zenity
« Reply #3 on: November 18, 2011, 12:28:14 PM »
this section sure is a quiet one :D

made some changes

-progress bar is now really progressing..no need --pulsate option anymore :D
-add a loop to check zenity,,so that cancel button in progress bar will really kill axel process if pressed
-add some additional command to kill axel and zenity ,since it seems like those 2 process still running in the background after the download finished..

Code: [Select]
#!/bin/bash


url=$(zenity --entry --text "Masukkan Url")
ans=$(zenity  --list  --text "Pilih Jenis File" --radiolist  --column "Pilih" --column "Tipe" TRUE "Video & Lagu" FALSE "Document & Picture" FALSE "Program & Game" FALSE Other --width 400 --height 300); #echo $ans


case "$ans" in
"Video & Lagu")
cd ~/DropBox/Video
;;
"Document & Picture")
cd ~/DropBox/Document
;;
"Program & Game")
cd ~/DropBox/Program
;;
"Other")
cd ~/DropBox/Other
esac

echo Axel:download from ["$url"] at:[`date`] >>~/cloudcity/ax.log

axel -n 10 "$url" |sed -un 's_^.* \([0-9]\+%\).* \([0-9.]\+[GMKB]\).*_\1\n#Downloading:...........[\1]Speed:.........[\2B]_p' |zenity --progress --auto-close --width 500 --auto-kill

cvlc --no-loop --play-and-exit /home/frozen/DropBox/i.ogg |zenity --notification --text "Download Process is Finished" | pkill axel | pkill zenity



#Start a loop testing if zenity is running, and if not kill axel
RUNNING=0
while [ $RUNNING -eq 0 ]
do
if [ -z "$(pidof zenity)" ]
then
  pkill axel && pkill zenity
  RUNNING=1
fi
done

i'm still trying to understand gtkdialog..since i've just known about its existence at the time neal moved this thread to this section.. ;D


--------------------------------------------------------
Acer 4740 i3 2,1ghz 1gb ddr3 intel gma hd 320gb sata, PcLinuxOS kde4

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Axel + Zenity
« Reply #4 on: November 18, 2011, 01:56:31 PM »
brilz,     
Quiet or not, Advanced Users (or Code Hackers, when asking assistance) is the place to post such topics. Posting a new script of your or anyone's creation in other sections of the forum, with advice/instructions to install it is a "do not do that" action. It is the same as telling someone to install from outside sources.
Bear in mind, this part of the forum is the "Development" area.     

Offline brilz

  • Full Member
  • ***
  • Posts: 107
Re: Axel + Zenity
« Reply #5 on: November 18, 2011, 11:13:36 PM »
yes sir.. :)

err..don't get the wrong impression neal,the last part of my previous post is actually my way of thanking you because if you never removed this thread to this section maybe i'll never take a look at this area..
there's so much thread i can learn from here.. :)


--------------------------------------------------------
Acer 4740 i3 2,1ghz 1gb ddr3 intel gma hd 320gb sata, PcLinuxOS kde4