Code Sample |
#!/bin/flua volnum = execute("/opt/mpc | grep volume | sed 's/[[:alpha:]]//g' | sed 's/%//g' | sed 's/[[:space:]]//g' | sed 's/://g'") volcmd = {} window = Window{210,65; label="jukebox control"} b1 = Button{10,10,30,30, "<<"} function b1.callback() execute("/opt/mpc prev") end b2 = Button{50,10,30,30, "->"} function b2.callback() execute("/opt/mpc play") end b3 = Button{90,10,30,30, "||"} function b3.callback() execute("/opt/mpc toggle") end b4 = Button{130,10,30,30, "[]"} function b4.callback() execute("/opt/mpc stop") end b5 = Button{170,10,30,30, ">>"} function b5.callback() execute("/opt/mpc next") end -- volume slider begin volume = Value_Slider{20,50,185,15,"V:"; align=Align.left, type=Slidertype.horiz, minimum=0, maximum = 100, step = 1, value=volnum} function volume:callback() volnum = self.value volcmd = "/opt/mpc volume" .." ".. volnum execute (volcmd) end -- volume slider end window:end_layout() -- ends the layout of the window window:show() |
Code Sample |
> myfilename=tmpname() > print(myfilename) /tmp/fileZh6gak > execute("date > " .. myfilename) > myfile = openfile(myfilename,"r") > mystring = read(myfile,"*a") > print(mystring) Thu Jun 8 07:09:19 EDT 2006 > closefile(myfile) > execute("rm " .. myfilename) > > mynewstring=gsub(mystring,"\n","") > print(mynewstring) Thu Jun 8 07:23:22 EDT 2006 |