Quote |
have .dfminfo be plain text and no gzipped. |
Code Sample |
#!/bin/lua x_align = 56 y_align = 64 x_mid = math.floor(x_align/2); y_mid = math.floor(y_align/2); fin = assert(io.open("/home/dsl/.dfminfo", "r")) fout = assert(io.open("/home/dsl/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 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 fin:close () fout:close () os.execute ("mv -f /home/dsl/modified.dfminfo /home/dsl/.dfminfo") os.execute ("pkill dfm && dfm") -- restart dfm |