Icon Grid Aligning
Forum: Programming and Scripting
Topic: Icon Grid Aligning
started by: humpty
Posted by humpty on Nov. 16 2007,01:17My 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.
Posted by roberts on Nov. 16 2007,11:04
pkill dfm && dfm
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.
Posted by mikshaw on Nov. 16 2007,14:39
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)
Posted by roberts on Nov. 16 2007,20:01With 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.
Posted by jpeters on Nov. 16 2007,20:51
After writing the icon image viewer, compiling imagemagick....
Posted by mikshaw on Nov. 16 2007,22:22Well, I still have uses for the xpm viewer besides desktop icons, such as images for application interfaces (skins, for example).
ImageMagick is a vital tool for anyone who does graphics work.
I wonder if that allows manual (persistent) edits of the file while dfm is running?
Posted by humpty on Nov. 17 2007,01:43Thanks roberts, the extra code seems to do the trick.
dfm is constantly updating .dfminfo. Fortunately the script is fast
enough to change it, although I'm not sure what other side efffects
Unless dfm allows running calls to itself, I'm not sure how I can
interface with it using c code. Meanwhile here is the update for
those who want to play around with it.
******** Warning -- This works for 4.1RC1 !!! ******************
******** any less version will corrupt your .dfminfo !!! ****
Posted by jpeters on Nov. 19 2007,17:43I haven't tried this, since I'm still using 4.0. I just tried the present "arrange" feature, which appears to snap icons in line without re-arranging. What's different? Thanks
Posted by humpty on Nov. 19 2007,18:06the "arrange" feature arranges and snaps (so named 'arrange'). To see this, drag an
icon to the middle of the screen, do 'arrange' and it gets moved back near the rest of
the icons. for some of us, we like to divide out icons in different areas of the screen
but also want the 'snap' to an imaginary grid.
Posted by mikshaw on Nov. 20 2007,00:19I wonder why you are creating and writing to modified.dfminfo? Apparently this file overwrites .dfminfo immediately anyway, so is there a reason not to write directly to .dfminfo?
You could also (optionally) use io.popen("file .dfminfo") to check whether it is gzipped before writing to it. This could allow you to write to a tempfile, then gzip it if needed before overwititng the original.
Posted by humpty on Nov. 22 2007,18:18
read and write at the same time to .dfminfo? never tried that before.
it's doing it line by line, i guess i feel safer should the program crash in the middle.
since it's decided not be gzipped for future versions, i have not
bothered with that. hmm, io.popen - nice function though.
Posted by roberts on Nov. 23 2007,02:18Instead of grid snapping everything in .dfminfo, should use the the select & drag feature of dfm to provide a subset of lines to your script to process.