Code Sample |
#!/bin/lua x_align = 48 y_align = 64 x_mid = math.floor(x_align/2); y_mid = math.floor(y_align/2); fin = assert(io.open("unzipped.dfminfo", "r")) fout = assert(io.open("modified.dfminfo", "w")) count = 1 while true do line = fin:read() if line == nil then break end pattern = "_POS" i= string.find (line, pattern) if i then -- if possible candidate s = string.sub(line, i+6) from,till,x,y = string.find (s, "%s*(%d+)%s*(%d+)") if (x and y) then -- if candidate io.write (count," : ", x, ",", y,"\n") mod = math.mod (x, x_align) x = x - mod if mod > x_mid then x = x + x_align; end mod = math.mod (y, y_align) y = y - mod if mod > y_mid then y = y + y_align; end s=string.sub (line, 1, i+5) -- the start of the line fout:write (s,x," ",y, "\n") -- the modification else fout:write (line, "\n") -- unaltered candidate end count = count + 1 else fout:write (line, "\n") -- unaltered non-candidate end end io.write (string.format("%6d ", count), "\n") fin:close () fout:close () |
Quote (humpty @ Nov. 15 2007,17:17) |
My first lua program. It tries to align the icons on a grid (without re-arranging). I can more or less align the icons, but don't know how to restart dfm without quiting X. Does anyone know the commands to do this ? |
Quote |
I also need how to call system commands to move the files around. |
Quote |
I don't like all the flashing resulting from having to restart window managers to get their menus redrawn |
Quote (mikshaw @ Nov. 16 2007,09:39) |
In any case, I'm coming close to the point where desktop icons have once again worn out their stay. I'll soon be returning to purely keyboard control, so I probably should just keep my opinions to myself =o) |