Arranging Icons in Finder Icon View

You asked this a while ago and then we got sidetracked onto rearranging Finder icons. Now that that's reached a slow spot while I contact the DIM author, I'm coming back to your question. Here's what I'm working on:

I use lots of Mission Control Desktops.

The names Mission Control gives them, Desktop 1, Desktop 2, ... Desktop 45, are mostly useless. I kind of remember that my KBM Meta desktop is #12, right next to my KBM Editor desktop at #13, and my main To Do List is in #3, but if I move a project desktop next to the To Do List desktop, or move To Do to be in between a couple of projects, to make it faster and easier to switch back and forth a lot, that changes the numbers of other Desktops.

I want to refer to Desktops by name, not number, so that the names can move along with them when I reorder the desktops. I have only been able to deal with so many desktops at all thanks to a program called CurrentKey Stats which does a lot of what I want (except no graphical display of desktops). Unfortunately, it's been withdrawn and with my finally upgrading to Catalina, I'm seeing more buggy behavior in it. So I'm trying to roll my own.

I have made a clone of TextEdit, called DeskSpaceID.app, using the public domain source from Apple. The only files that DeskSpaceID deals with are my Desktop Workspace Identification Windows (DTWSIWs) like this:

That sits in the lower left corner of my KBM Editor desktop:

You might notice that there are tiny (8pt) "[" and "]" characters surrounding the main mnemonic character. That lets me make changes to the text of that line and then just copy the whole line and paste it in as the new file name, and in the file name the mnemonic character get surrounded by the brackets while they don't clutter the displayed image. I might even make a KBM macro to automate the name pasting, but it doesn't happen often once the files are initially made.

I am in the process of creating a DTWSIW to have open on each desktop. I have all of those files saved in my DeskSpaceIDs folder and an alias to that folder on my desktop, top center. Here's that folder when it's open in Icon View:

The highlighted icon in position 12 is my KBM desktop. If I open that file in my DeskSpaceID app, with a hotkey that does "open this file in DeskSpaceID", since that file is already open on my KBM desktop, in DeskSpaceID, then that switches my working desktop from wherever I am to my KBM desktop. The first two rows are done, I'm working on DTWSIW files for other desktops in the lower two rows. All five rows provide enough space for the 45 desktops, but I'm only currently using 29 of them.

What I'm looking for in this OP thread is to be able to rearrange the icons in this folder whenever the Mission Control Desktop order changes. The names get automatically updated as filenames and as RTF thumbnails simply by changing the RTF file, which I can edit in either TextEdit or my DeskSpaceID.app. Auto-arranging the icons is not a "mission critical" feature, but it would be a really nice bit of polish.

To tag the files with their Mission Control Desktop Number (MCD#), you suggested putting the number in the file metadata, in Notes. I like that. I can get the number from WhichSpace.app. I could have a macro that steps through all the desktops and verifies which MCD# goes with each DTWSIW, and update the file if needed.

If I can't rearrange the files automatically, based on a number in the Notes, then I am thinking that I would add a large number, like the initial letter in each file, that would be visible in the RTF thumbnail but kept off screen in the window on each desktop. Then I can rearrange the thumbnails manually to match their numbers. But that's not as aesthetic a solution. I generally want the numbers hidden. So I'm researching the automatic possibilities.

If you examine that Finder window, you may notice that I have icons for my Research and Xcode Development desktops in there twice, the second ones being Pages files. I really like the look of the Pages thumbnails, the lack of the folded corner and lack of the superimposed RTF or RTFD makes it look really clean. But a simple Pages file is 25 to 50 times as big as as the corresponding TextEdit (or DeskSpaceID) file and I'm concerned that having 40 such files open at once could slow things down. I have not tested it. Also, I can't clone Pages to change the name and I really do need a dedicated app to keep the list of DTWSIW files separate from any other working files. What I would need is some other public domain app that displays large fonts inline and where Finder can display thumbnails. To meet all three criteria, so far it's TextEdit, cloned as DeskSpaceID.

So that's where I am at this point. Now that I have my DeskSpace.app Text Edit clone, I am working on the UI details. For instance, I like the way the KBM icon is highlighted. I'd like to work out a way to open the folder on the current desktop and have it automatically select whichever file is already on that desktop, thus highlighting the current DeskSpace. Then when I open a different file to go to another desktop, it would automatically close the Finder window so that it's available to open on that other desktop or any other.

I also want to have an icon on my desktop or simply a hotkey that when opened/invoked would identify which DeskSpace I'm in and open the corresponding To Do list.

There's lots of possibilities, once the basic framework is in place.

Thanks for listening. Brainstorming welcome.

1 Like

This is nuts! :joy:

If any of these questions seem silly, it's probably just me missing some of the detail in your rather complex setup...

Yes. Yes you do.

How about this?

Why not set DeskSpaceID as the default app for those files?

Why not use custom file icons?

Opening files is a clever way to trigger spaces, but couldn't you open them via a Prompt With List action? Why do you want to open them manually?

That looks interesting! And it's been around for a while so it likely doesn't demand a later OS than I have. The only other things I had seen on GitHub did a Dock patch that was not allowed in Mojave without breaking things and besides, only allowed two-character mnemonics. This looks great. Why or why did I not find this sooner?

At the moment, I need them to be RTF or RTFD to be able to get the thumbnails. I tried changing them to *.dsid files and set that to automatically open in DeskSpaceID, and that worked, excepy I lost the thumbnails showing the large initial mnemonic.

Because thumbnails automatically change. Custom file icons would require automating the creation of the icons and automating the setting of the icons on the files. Doable, but transparently automatic seems better in this round. That could be a later improvement.

I currently DO open them with a Prompt With List action, but the list is currently the list of CurrentKey Stats names which trigger CKS to do the changing of spaces. I'm trying to eliminate my dependency on CKS so I'm making sure that I have a working infrastructure before I rework and replace things at that level. I'm currently also dependant on CKS to set the hotkeys to switch to each room. When I get that figured out, I'll migrate.

Also, it turns out that under the hood, CKS works the same way: it places an "invisible" window on each desktop and changes spaces by activating the associated window. I've been working on an app in Swift/Xcode to place contentless, titlebar-only windows on each desktop. I can get the app to create a list of titlebars on startup and I can manually move them to each desktop, but haven't gotten it working with AppleScript to be able to generate them on each desktop or to automatically move them. Using the graphical image gives me the bonus of automatically getting identifiable file icons.

Down the road, if I get the titlebar-only app working, I might combine that with the custom icons for each file, if I can automate that process.

Either in the custom-icons future or the thumbnail present, I like having two different ways of choosing desktops, a graphical icon display or a list of names.

At the moment, because my PWL list is generated in CKS, it's always in most-recently-used order because that's the way CKS lists everything. That is useful, so in the back of my mind I'm thinking of how to order my new Prompt With List list that way.

The Graphical display of course wants things listed in Mission Control order, which is what automatically rearranging the order seeks to maintain (hence the OP question, which DIM may eventually answer).

1 Like

Now that I've dug into it a bit, I think I may have seen this before and rejected it because it requires disabling and only partially re-enabling System Integrity Protection (SIP). I'm not Mac Expert enough to want to run without SIP.

Too bad.

I always have SIP disabled. If you only need to disable it for installation, I wouldn't worry about it. Personal opinion, of course.

What do you mean by "partially"? As far as I know SIP is either on or off.

From the Github entry's Installation instructions:

Installation:

  1. Download MacForge, the newest incarnation of mySIMBL.
  1. Make sure that it's installed, including disabling SIP (use the command csrutil disable in Recovery mode by following this tutorial). There are additional commands for macOS Catalina, with details under the 'System' tab of MacForge. After it's installed you can partially re-enable SIP using csrutil enable --without debug --without fs. If you fully enable SIP, Spaces Renamer won't work.

I have repeatedly read advice against turning SIP off. Why did you/ do you?

I tend to feel fairly at ease with open-source distributions that have been around a while, but that's just me.

I started disabling it to continue using some legacy software, and have never felt the need to enable it again.

I have not heard back from the DIM author yet, but it's not necessary.

You and I both bought into the idea that somehow this was a desktop-only thing and that was reinforced when ...

RUBBISH

I found a reference in Ask Different that used position and bounds of files in a folder (https://apple.stackexchange.com/questions/314456/mac-os-finder-read-file-folder-order-positions-arrange-by-thru-command-line) so I hacked together a script using them that was more like psuedo-code:

-- THIS IS BAD CODE
tell application "Finder"
	set fileList to every file in folder POSIX file "/Users/amohr/Documents/Personal/DeskSpaceIDs/"
	for every thisFile in fileList
		set thisName to get the name of thisFile
		set thisPosition to get position of thisFile
		set thisBounds to get bounds of thisFile
		set thisComment to get comment of (thisFile as alias)
	end
end tell

Of course it didn't run. But I gave it to ChatGPT as a starting point and ChatGPT helped me create this script:

tell application "Finder"
	set folderPath to POSIX file "/Users/amohr/Documents/Personal/DeskSpaceIDs/"
	set fileList to every file in folder folderPath
	set resultText to ""
	repeat with thisFile in fileList
		set thisName to name of thisFile
		set thisPosition to position of thisFile
		set thisBounds to bounds of thisFile
		set thisComment to comment of thisFile
		
		-- Format the position property
		set formattedPosition to item 1 of thisPosition & ¬
						", " & item 2 of thisPosition
		
		-- Format the bounds property
		set formattedBounds to item 1 of thisBounds & ¬
						", " & item 2 of thisBounds & ¬
						", " & item 3 of thisBounds & ¬
						", " & item 4 of thisBounds
		
		set resultText to resultText & "Name: " & thisName & linefeed
		set resultText to resultText & "Position: " & formattedPosition & linefeed
		set resultText to resultText & "Bounds: " & formattedBounds & linefeed
		set resultText to resultText & "Comment: " & thisComment & linefeed & linefeed
	end repeat
end tell

-- Display the result in a dialog
display dialog resultText with title "File Info" buttons {"OK"} default button "OK" giving up after 30

Try it on a folder of your own. Add some comments to files using File > Get Info.

Formatting the position and bounds values that way was something I suggested to ChatGPT because it had never gotten the concept that those values were lists. It was writing a "format handler" that reset the list delimiter before assigning the list to a variable and that was just not working. Again I suggested a method using psuedo-code ("position[1] & ", " & position[2]") and it gave me the proper AppleScript syntax.

So, OK, I'm getting to like coding with ChatGPT's help. It does require that I know what it is that I want to do because it cannot figure that out for me. And it will cheerfully go down rabbit holes of stuff that doesn't work and then authoritatively declare that there is no way, and be dead wrong. But as a robot, it's useful.

1 Like

I just had a quick think about how I might switch Spaces based on an identifier, and came to the conclusion that I would use Stickies.

  1. Create a Sticky Note for each desktop space and click the top-right icon in its window to make it as small as possible.

CleanShot 2023-09-30 at 10.33.23

  1. Run this macro and choose a space by its Sticky Note name in the Stickies app Window menu.

Switch Space by Name (Stickies).kmmacros (23 KB)

Macro screenshot

CleanShot 2023-09-30 at 10.31.32

Stickies is where I started. I've found it recommended in various fora. It works OK for small numbers of Desktops.

But it has a lot of maintenance overhead for larger numbers of desktops. I gave up on Stickies in annoyance because every time I had to reboot, all the Stickies would reopen (glad I didn't have to recreate them) on the first desktop so I would spend 10 minutes or more moving them one by one to the appropriate desktop, which was often hard to figure out or remember because the Sticky itself had been how I kept track of which was which.

To really use them, I would need a way to automatically track the pairing of Mission Control Desktop Number (which I can now get for the current Desktop from the WhichSpace app) with my own Desktop Workspace Name. I tried a simple text list, on a Sticky too, which sort of worked but was annoyingly tedious and I would forget to maintain it as Desktop names and positions changed.

That's why I decided to find some app, I tried a lot, that supports multiple windows and which is able to reopen those windows in the same Desktop they had been in before the reboot. That was minimum. Support for AppleScript was also a big plus. TextEdit floated to top early on, but I used it too much for other things and I didn't want the two uses all muddled together.

I tried a bunch of lightweight text editors which mostly all did OK, but I had been spoiled by how, in both Stickies and TextEdit, I could use larger fonts so I had a more graphic ID rather than having to focus down and read the text on a window title. I suppose some people would like the ID to be invisible until needed, CurrentKey Stats works that way, you have to click the icon in the toolbar to see the name of the current desktop. I tried building my own app that just makes little titlebars, but I haven't gotten it AppleScript-able yet. I may still pursue that. At the moment, I like the graphical display of a large font, icon-like image that lets the context be more immediately obvious without the extra steps.

I even tried Pages, which worked, but a simple Pages file with the same graphical text display as a TextEdit RTF file could be 25 to 50 times as large. I assumed it would also be slower all around.

And for all of the dedicated app solutions, there was the annoying problem of the app name. Pages was at least kind of conceptually related to Desktops, but Folding Text was not.

I've very happily found the Public Domain version of TextEdit and gotten it to build renamed as DeskSpaceID. So I'm using DeskSpaceID files/windows instead of Stickies and it does everything Stickies does, and more, without the annoying downsides of Stickies. The one thing I still have to work out is how to get it to Save files with a .dsid extension instead of .rtf.

Dammit! I thought I'd come up with a novel solution but it turns out it's not that novel and not much of a solution after all...

Great minds think alike. The fact that others have come up with the same idea independently is no onus on you. E.g. macos - OSX Lion AppleScript : How to get current space # from mission control? - Stack Overflow

Your macro set is cool, well thought out, and useful if that's all you need or want. I like it.

I have in the back of my mind the idea that if I ever get this to a point where it's sharable with others, that I would rather share it as a tutorial book than try to package it as an Application. An app demands robustness and pre-thought-out customizability and more, all of which at least double the complexity.

My tutorial book, currently titled "A Highly Evolved Desktop", would start with Mission Control and then add concepts and features, starting with Stickies, so that people could follow it to start simply and then improve how their own system works as they need it, and ultimately create their own app in Xcode, if they get that far. They can stop wherever they want and come back later if they want. I think the system I'm currently building may be next-to-last, before the Xcode App. Or there may be two versions of the app, who knows.

Here's my cover for the book, from 1588:
image
[https://www.bridgemanimages.com/en/noartistknown/book-wheel-to-read-various-books-1588-engraving/engraving/asset/3939353]

I really like how this engraving shows the details of how various parts are made and how the whole thing goes together, the desktops, the pivots, the links between them, all the stuff to keep everything straight that's under the hood, which fits my book really well.

Would you mind if I shared your Stickies macros in the book?

I don't mind at all, but I wouldn't cite it as a good macro, as the Stickies don't maintain their Space position across restart. :man_facepalming:t2:

That seems to be the fundamental drawback of Stickies and what limits it to being used when you only have a handful of Spaces/Desktops. That doesn't take away from your macros being a good starting point.

Just poking around inside the package of the installed DIM, in Contents/Resources, is the (not copy protected, thanks DIM author) AppleScript file, "DIM.scpt". In the "memorize()" function, it looks like it has commands to save positions of items in a Finder window - it also does this for the Desktop, which has a separate branch of commands. But it looks like it works for both. I've been following this thread with some interest - thought I'd just point this out, if you hadn't seen it yet. :slightly_smiling_face:

There's a chance I've forgotten a main requirement of all this, but... Could you name all the files with a prepended number and then use Finder's built-in Clean Up By Name function to set their position?

Thanks for pointer, Ed @edmechem, and the reminder. I've been meaning to look into that.

I have DIM installed and I've also downloaded the source from Github. I've been in contact with the developere, G.J. Parker, who gave me a detailed overview of how DIM works. If you are interested, I can pass that along.

He also kindly pointed out that Apple doesn't allow AppleScript-based apps into the App Store without very stringent guidelines. Fortunately for me, I have no intention of selling anything from this in the App Store.

Where I left it with him was that I'd look at his AppleScript functions in the DIM source and get back to him with questions. And instead I've been pursuing a different thread in this project.

Thanks, I had thought of that, but wasn't really enthusiastic. For my aesthetics, I would have to temporarily rename everything by adding the numbers, do the "Clean up", and then rename everything back. That requires messing with the filenames which seems risky to me. But maybe it wouldn't be so bad. I'll think about it. Maybe I can run a test. If I can rename 40 files, rearrange the icon order based on the new names, and rename them back again, and if it just happens pop, pop, pop, nearly transparentlfy, that would eliminate my having to write my own sorting and repositioning functions.

Back in Pos #9 in this thread, you suggested using the Comments field. I've been working on that concept as a way to have the "current" Desktop Number the file is open in attached to the file. That's the sort order that I'm trying to implement.

Also, not well explained as a requirement, is the task of actually getting the numbers in the first place and associating them with the files. Unlike DIM, which just "memorizes" the current positions in the current folder, I need to know which Desktop each file is open on. To collect that information all at once, in a single pass, requires stepping through all of the Desktops, one at a time. That's tedious. I've tried it for other things and I need to allow at least two seconds, if not more, for the Desktop to "settle" before I do things with it. To gather info from 40 Desktops means keeping my hands off the keyboard or mouse for nearly two minutes. That's not a productivity booster.

Using the files' Comments field means that I will not necessarily need to collect that information all at once, it can be updated as I go along, with each Desktop change, while I'm working. And it adds to a concept that I've had about this whole system, that I don't want some out-of-sight database to be in control, and which has to be tracked and updated Instead, the files themselves are the database.

That also, I think, solves one of the problems in the CurrentKey Stats app. Repeatedly, especially on reboot, CKS looses track of the correspondence between name and Desktop number/position which requires slowly stepping through all the desktops while it, one at a time, figures out if it knows the name of each Desktop. I don't know the details of his system or why that bug occurs, but I think it's because he's working from a central database of names and desktop numbers. I'm hopeful that having permanent files with the current Desktop number saved in the the Comments, updated when I make changes, will prevent anything like that particular problem/confusion.

BTW, I really appreciate all the suggestions and questions. It's encouraging to feel your interest and collaboration. And it helps me to sort out my thinking to explain it and to recall my decision making, especially since I may ultimately write it up as a tutorial.

1 Like

Hi @noisneil,

To get back to your previous question:

I gave you my prior rationalization without actually taking in the whole of your suggestion. Since this is actually a finite set of files, actually all collected in one folder, there is no real need for a separate file type. All I need to do is set the Open With property (System Events "default application" property) of each file so that it opens with DeskSpaceID (my TextEdit clone). Done. Opens in the desired app and keeps the RTF thumbnail.

I only have about 30 icon files so far, so the task of setting those Open With app names is a bit tedious, but totally doable by hand. In the long run, I'm looking at automating all the various settings (icon, comment, openwith, etc.) as well as the font changes in creating the display image that I like. For automating the Open With property, I now have help from @ccstone and @tiffle in the Set the “Open With” of a Finder selection? thread of @MitchellModel.

1 Like

Another of your suggestions that I initially shrugged off with my then current rationalization and which I am now implementing.

The RTF icon automatically gives a thumbnail of the file, and my 200pt initial letter is visible in the thumbnail. That's what I like and I like it a lot. And based on your suggestion I've come up with another way.

I take a screenshot of the Desktop with only the Desktop Workspace Identification Window (DTWSIW) visible. I can even use DIM to temporarily hide the desktop icons. I take a screenshot of that and paste it in on the Get Info dialog as the icon for the file. (It's saved in the file metadata at a relatively low resolution.)

The 200pt initial is still visible in the screenshot icon, it gets rid of the pesky turned down corner and "RTF" overlay on the icon and it carries through my use of the desktop wallpaper as an aid to identifying which Desktop is which. Here's what it looks like with four of them done (without the DIM enhancement yet).

So thanks again for the suggestions and my apologies for initially dismissing them.

1 Like