Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: UCI Umounter, flua script< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Dec. 08 2005,06:16 QUOTE

So the subject came up on #dsl-chat a while ago about how to make it convenient to umount UCI applications, instead of having to browse to the file or remember where it's located.  This little flua script will grab a list of .uci files from /etc/mtab and display them for you. Select a file and press umount to uninstall the program.
Code Sample
#!/bin/flua
ww = 400
wh = 120
Fl_Widget.initializers = {textfont=15,labelfont=15,labelcolor=0,scrollbar_width=15}
Fl_Window.initializers = {box=Boxtype.thin_down,color=15}
Fl_Button.initializers = {box = Boxtype.thin_up, down_box = Boxtype.thin_down}
tempfile = "/tmp/lsuci.tempfile"

w_main = Window{ww,wh,"UCI files mounted"}

file_list = Hold_Browser{10,10,ww-20,wh-50}
refresh = Button{40,wh-30,80,20,"refresh"}
function refresh.callback()
execute("grep \".uci \" /etc/mtab|awk '{print $1}' >"..tempfile)
file_list:load(tempfile)
remove(tempfile)
end
umount = Button{ww-120,wh-30,80,20,"umount"}
function umount.callback()
if file_list.value > 0 then  
execute("mydsl-load "..file_list:text(file_list.value))
refresh.callback()
end
end

w_main.size_range(w_main,ww,wh)
w_main.resizable = file_list
refresh.callback()
w_main:show()

EDIT: awk '{print $1}' /etc/mtab | grep .uci$ would probably be less likely to grab an inappropriate line.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
struppi Offline





Group: Members
Posts: 93
Joined: Dec. 2004
Posted: Dec. 08 2005,09:17 QUOTE

i use rox and made this one for automatic loading/unloading of clicked uci-files:
Code Sample
#!/bin/flua -f

-- Install and uninstall .UCI-files

if getn(arg) == 1 then
   uci = arg[1]
else
   print("usage: uci-load-choice.lua [uci_name]")
   exit(1)
end

local file = openfile("/etc/mtab", "r")

-- uci-name
l=strlen(uci)

for counter=1,l,1 do
x = strsub(uci,counter,counter)
if x=="/" then
 lastSlash=counter
end
end

p=(l-lastSlash)*-1

uciFile=strsub(uci,p)

--escaping
escapedUciFile=""
blankFileName=uciFile
l=strlen(uciFile)
for counter=1,l,1 do
x = strsub(uciFile,counter,counter)
if x=="-" then
 x="%-"
end
escapedUciFile=escapedUciFile..x
end
uciFile=escapedUciFile

-- analyse
filetable = {}
line = read(file, "*l")
while line do
  if strfind(line,uciFile) then
     if fl_ask(blankFileName.." is allready mounted!\n\nDo you want to unmount "..blankFileName.."?") then
        execute("mydsl-load " .. uci )
closefile(file)
        exit(0)
       else
        return
      end
  end
  line = read(file,"*l")
end

closefile(file)

if fl_ask(blankFileName.." is not mounted!\n\nDo you want to mount "..blankFileName.."?") then
 execute("mydsl-load " .. uci )
 exit(0)
else
 exit(0)
end
Back to top
Profile PM 
1 replies since Dec. 08 2005,06:16 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: UCI Umounter

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code