3

How can the max. width (fixed width≈425) of Safari's download-popover-window be made wider?

Is there a way to get at Safari's "download pop over window" in any way so its max-size is larger than 425 px and longer file names are no longer abbreviated?
Maybe via AppleScriptObjC?

[[ Answers: So far (w/o use of AS-objC) just three "workarounds" have come around...

  • Original Workaround #1 ... a mixture of (do) shellScript (cat/sed), AS, Html and Automator
  • Workaround # 1 ... uses only Automator modules but also contains the above shell script
  • Workaround # 2 ... with direct AS access on Safari's plist file, a dialog & a "button" in Safari

WA #2 is my favorite; the others' "windows" are more flexible. Both use Automator shortcuts. ]]

4
  • Not sure if it works, but sometime web browsers have a page dedicated to downloads, so I'd try downloads:// (like bookmarks://) Commented Nov 22, 2015 at 0:21
  • Thanks, IronCraftMan, but sadly your idea doesn't work with El Capitan's Safari ... although the Bookmarks thing DOES. Commented Nov 22, 2015 at 19:33
  • Could you hit us up in the chat room or ask on meta how to fix this? It's a mess of a blog post and Q/A seems a bit destroyed at this point. Also, we need to sort out code level issues and get this to stack overflow if that fits your audience better.
    – bmike
    Commented Dec 7, 2015 at 7:24
  • You're right, I assume I use this page as a kind of "notebook" for myself. Actually I've stumbled over so many workarounds, using combinations of applescript or automator or inline-shell scripts, that I may have lost a clear path. But AS YET there has not been posted an answer directly approaching the "Safari popover window size" issue, I'm afraid ... I wouldn't mind if this Question was moved to stackoverflow at all. Commented Dec 7, 2015 at 9:21

3 Answers 3

3

Original Workaround #1:

The first one here has got the advantage to use only one Automator action and allows quite precise settings of the resulting Safari-owned window. Its end results are a "service" in Safari's menus plus a keyboard shortcut.
These components are involved:

  • Safari's "Download.plist" (in: Library/Safari)
  • A shell script running cat & sed, filtering the plist-file's input into "Downloads1.html"
  • An Html file "Downloads2.html" holding Html tags of your choice (w/o finishing tags: </...)
  • An AppleScript containing a "do shell script" command, "telling" Safari to open an
  • ... Html file "Downloads.html", generated by shell script, in order to at last get …
  • Automator to place a workflow in Safari's "Services" menu.

This code runs as an Automator Service (without "run" commands it's plain AppleScript):

on run {input, parameters} 
 -- [Only if needed, place: "LANG=C; LC_CTYPE=C; LC_ALL=C;" in front of "cd"]

    do shell script "cd ˜/Users/[myName]/Library/Safari/;
             rm Downloads.html;
             cat Downloads.plist | sed -n ' { s/.*Downloads/<p>D`load => /; ¬
                     s/.*Trash/<p>Trashed => / ; s/.*Movies/<p>Movies => /; ¬
                     s/mp4.*/mp4<p>/ p; }' > Downloads1.html';
             cat Downloads2.html Downloads1.html > Downloads.html;"

    tell application "Safari"
        make new document at end of documents with properties ¬
            {URL:"file:///Users/[myName]/Library/Safari/Downloads.html"} 
        set bounds of window 1 to {700, 62, 1280, 450} 
    end tell 
    return input 
end run

(The shell script and "make new document…" are meant to be one liners each.)

Integrated are two "filters" to the sed part (.*Movies & .*Trash) so my browser window looks like this (you may edit these filters or/and add Extensions to your needs):

+----------------------- Toolbar -------------------------+
|                                                         |
|  D'load => /Some_sinster_TV_series_S02E01_15.11.21_00-  |
|  40_BBC3_93_TVOON_DE.mpg.HQ.avi.otrkey                  |
|                                                         |
|  Movies => DS9.4.07_Little_green_men.mp4                |
|                                                         |
|  Trashed => /DS9.3.09_Defiant.mp4                       |
|                                                         |
|  Trashed => /DS9.3.07_Civil_Defense.mp4                 |
|                                                         |
+---------------------------------------------------------+

(Those leading slashes suck… hard to filter out, though.)

  • The commented out second line may be needed, or may not…
  • Replace [myName] with your own user name.
  • To use this code as "service" in Safari, you have to paste it inside a "Run AppleScript" field in automator. Save it as "workflow".
  • You can then create a shortcut (e.g.: opt-cmd-d) that will run it instantaneously (System-Prefences / Keyboard / Shortcuts / Services).
  • My solution is not really sophisticated, but I learned (glimpsed) a lot about sed, awk, cat and AppleScript/Automator.
5
  • I've cleaned up your answer a bit with code formatting. Don't use HTML — this is a Markdown editor. Feel free to edit further if I've lost important information from your answer.
    – grg
    Commented Dec 5, 2015 at 14:20
  • Thanx a lot grgarside. I couldn't find a way to get my mixture of shell and applescript displayed here correctly as all those special characters tend to behave quite weird when posted here. MY FAULT ... Commented Dec 5, 2015 at 14:26
  • Here's a quick guide to Markdown. Using four spaces to indent a line will preserve the text; four spaces can be batch-inserted with the toolbar button or ⌘K.
    – grg
    Commented Dec 5, 2015 at 14:28
  • Is this easier than putting a downloads folder set to fan view in the dock?
    – samh
    Commented Dec 6, 2015 at 0:54
  • I just answered that question as an EDIT in my original question on this page. I've got good reasons NOT to display all dozens of files in my Downloads folder ... ; -) Commented Dec 6, 2015 at 10:45
0

Workaround #2

My preferred solution uses applescript to access "Downloads.plist" directly (no shell scripting), and places a link in Safari's favorites bar for your convenience.
First you save these scripts into "~/Library/Scripts/Folder action scripts/" folder, next you attach them (context menu: configure folder actions) to a new "Folder1" somewhere deep down on your Mac.
To activate them, you will address a (meaningless) dummy "Folder2" inside "Folder1" thru this bookmark:

file:///Path/to/first/Folder1/Folder2   [place link in your favorites bar!]

Now, what's happening:
- The clicked-on toolbar link will open "Folder1" because the called upon "Folder2" is inside.
- Thus BOTH attached scripts are launched, #-1 closing the bookmarked "Folder2" window...
- ... next ordering "System Events" to get all of Safari's "DownloadEntryPath" items.
- These paths are shortened to name plus parent-folder and collected into a "dialog alert".
- (Waiting for "dialog window":) #-2 script immediately on pop-up moves it to the top-right.

on opening folder this_folder
    tell application "Finder" to close front window
    tell application "System Events"
        set the plist_path to "~/Library/Safari/Downloads.plist"
        set the plist_file to property list file plist_path
        set downloadItems to property list items of property list item ¬
            "DownloadHistory" of plist_file
        set DL_display to ""
        set AppleScript's text item delimiters to {"/"}

        repeat with i from 1 to number of items in downloadItems
            set DL_item to (get text items -2 thru -1 of ((value of ¬
                property list item "DownloadEntryPath" of property ¬
                list item i of property list item 1 of plist_file) as string))
            set DL_display to DL_display & return & "[" & ¬
                text item 1 of DL_item & ":]" & return & text item 2 of ¬
                DL_item & return
        end repeat

        tell application "Finder" to display dialog DL_display as string ¬
            buttons {"Close"} default button 1 -- NEW: tell appl. "Finder" to
    end tell
end opening folder

If you attach this 2nd "folder action script", it'll move the "dialog" to the right/top of your screen:

on opening folder this_folder
    tell application "Finder"
        set screenRgt to bounds of the window of desktop
        set rightEdge to (item 3 of screenRgt) - 425
    end tell
    tell application "System Events" to tell process "Finder"
        repeat while not (exists window "Recent downloads")
        end repeat
        delay 0.1   -- wait (and make sure...) for "dialog window" !
        set position of window "Recent downloads" to {rightEdge, 61}
    end tell
end opening folder

The only drawback to this solution IMO is, that for a moment each the opened folder and the alert "flash" over your screen...

0

Workaround #1

As so far no answer explained how to programmatically influence Safari's pop over window:

Using only Automator

Here is a way to get a "Recent downloads" list displayed, which uses only Automator.

  • You needn't use AppleScript here at all. Instead it takes 4 of Automator's modules to run.
  • It will pop-up a nicely framed (Automator-style) browser window.
    (You'll need to place a "Downloads2.html" file, containing your html tags w/o end-tags, inside /Users/[myName]/Library/Safari, though.)
  1. After opening File > New > Service in Automator, double-click:
    AutomatorDo shell script

    Next, paste the following code into the window on the right side:

    # only if needed, place as 1st line: LANG=C; LC_CTYPE=C; LC_ALL=C;
    
    cd /Users/[myName]/Library/Safari;
    cat -su Downloads.plist | sed -n  '{ s/.*Downloads/<p>D`load => / ; ¬
          s/otrkey.*/otrkey/ p; s/.*Trash/<p>Trashed => / ; ¬
          s/.*Movies/<p>Movies =>  /;  s/mp4.*/mp4<p>/ p; }' > Downloads1.html;
    rm Downloads.html;
    cat Downloads2.html Downloads1.html > Downloads.html;
    
  2. Double-click Pause from Automator's list of actions.

    I chose 0.1 / Seconds but had to check the Ignore input from this action button (Options). I found that on my computer Safari would display an empty window if I didn't grant the next action a pause…

  3. Add Get Specified URLs from Safari's action list. Remove any given URLs and choose the [ADD] button. Then write:

    file:///Users/[myName]/Library/Safari/Downloads.html
    
  4. Finally, the last step is to double-click Website-Pop-Up from Safari's. My parameters:

    • Site–size: Custom
    • Values: 600 x 300
    • Position: Centered

    (Safari's focus will remain on the front window, so you can't press "ESC" to close the pop-up.)

  5. You might add: System Preferences → Keyboard → Shortcuts → Services; (e.g.: opt-cmd-d).

(Have a look at the resulting window at "Original Workaround #1" further up, as both examples use identical Html files for their looks!)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .