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
Pages: (3) </ [1] 2 3 >/

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

reply to topic new topic new poll
Topic: Icon Grid Aligning< Next Oldest | Next Newest >
humpty Offline





Group: Members
Posts: 655
Joined: Sep. 2005
Posted: Nov. 16 2007,01:17 QUOTE

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 ?
I also need how to call system commands to move the files around.
There's also the problem that not only does it re-align the desktop
icons, but also any other it sees. Can't seem to find a way to
distinguish the desktop-only paths. Comments appreciated, or
even if anyone has a more efficient way of doing this.


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 ()
Back to top
Profile PM 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Nov. 16 2007,11:04 QUOTE

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 ?


pkill dfm && dfm

Quote

I also need how to call system commands to move the files around.


os.execute("your system command"), e.g.
os.execute("pkill dfm && dfm")

Personally, I don't like all the flashing resulting from having to restart window managers to get their menus redrawn, and now restarting dfm to effect some grid control. But lets see what develops.
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Nov. 16 2007,14:39 QUOTE

Quote
I don't like all the flashing resulting from having to restart window managers to get their menus redrawn
I agree with you on that, and as you said we'll see how the snap develops.

I'm positioning new icons manually because I also don't like the way dfm arranges them. It seems illogical to have a "sort" that rearranges icons in a particular array but also have "arrange" that does essentially the same thing. Arrange should, in my opinion, be "align" and simply snap to the nearest grid point.

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)


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





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Nov. 16 2007,20:01 QUOTE

With dfm there is no size limit on the icon,  no size limit or word wrap on captions, and with data icons, I can understand that a snap to grid would be troublesome.

xtdesk did not have snap grid, it was a lua program that I wrote for DSL v1.3. However, v3.x and prior did not have data icons, is heavily dependent on menus, as such a limited number of desktops icons (really program launchers as no drag-n-drop functionality). And finally, MyDSL extensions the icons are optional. Thus a much less complex task.

Perhaps a look in the C code of dfm would be a better approach.

humpty, let me know if you want the source.

I have only changed one option from the standard, that is to have .dfminfo be plain text and no gzipped.


Edited by roberts on Nov. 16 2007,20:04
Back to top
Profile PM WEB 
jpeters Offline





Group: Members
Posts: 804
Joined: April 2006
Posted: Nov. 16 2007,20:51 QUOTE

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)

After writing the icon image viewer, compiling imagemagick.... :D
Back to top
Profile PM 
11 replies since Nov. 16 2007,01:17 < Next Oldest | Next Newest >

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

Pages: (3) </ [1] 2 3 >/
reply to topic new topic new poll
Quick Reply: Icon Grid Aligning

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