Jump to content

iCloudTabs


Recommended Posts

This immediately reverts to a regular Alfred search for "tabs" for me.  When I copied the script into a file and ran it in terminal it throws up the following error:

 

 

Traceback (most recent call last):
  File "./tabs.py", line 44, in <module>
    devicetabs.append([x['value']['DeviceName'], x['value']['Tabs']])
KeyError: 'Tabs'
 
I have three devices with iCloud tabs visible from Safari & can open them from Safari without problems.
Link to post
dfay, it sounds like it isn't finding the 'Tabs' section in the decoded plist file.  That could occur if the file is in a different spot in another version of the OS.  I'm using 10.8.4 (Safari 6.0.5) and the file is here:  ~/Library/SyncedPreferences/com.apple.Safari.plist or more likely, if the file has a different structure for some reason.

 

When I copy that file and then convert it to XML using "plutil -convert xml1 <copied_filename>.plist" then review the XML, mine is structured this way:

 

changecount

initalsync

values

+ unique-id-1

+ + remotevalue

+ + timestamp

+ + value

+ + + DeviceName: device1

+ + + + Tabs

+ + + + + Title: title1

+ + + + + URL: url1

+ + + + + Title: title2

+ + + + + URL: url2

+ unique-id-2

+ + remotevalue

+ + timestamp

+ + value

+ + + DeviceName: device2

+ + + Tabs

+ + + + Title: title3

+ + + + URL: url3

+ + + + Title: title4

+ + + + URL: url4

+ [...] (one unique-id for each device)

versionid

 

All the workflow does, after copying the plist and converting it to XML, is to look for the DeviceName and Tabs tags in that XML but it expects the values -> unique-id -> value structure to be there as well.

 

The error you got suggests it can't find the 'Tabs' key.  If you can copy your plist file and convert it to XML the way I did above, let me know if that is missing or named another way.  I don't have much time to troubleshoot but I'm happy to see what I can do if there's a clear cause.  If you want to email me a copy of your plist file I can see if it's different and try to adjust for the variance in structure (keep in mind that I would see the open links in that file, if you want to do that).  kevin.marchand@gmail.com
Link to post

 

This immediately reverts to a regular Alfred search for "tabs" for me.  When I copied the script into a file and ran it in terminal it throws up the following error:

 

 

Traceback (most recent call last):
  File "./tabs.py", line 44, in <module>
    devicetabs.append([x['value']['DeviceName'], x['value']['Tabs']])
KeyError: 'Tabs'
 
I have three devices with iCloud tabs visible from Safari & can open them from Safari without problems.

 

 

I think I figured out what's going on.  If the plist had multiple devices, but some of the devices in the list didn't have tabs, it caused the script to fail.  I just modified it to try to find the Tabs key but to keep going if it didn't find it and it seems to work for me.  It should now ignore devices that don't have tabs in that list.

 

There's an updated copy here:

 

https://github.com/kmarchand/iCloudTabsAlfredWorkflow

Link to post

Thanks for following up.

 

I checked the plist and it does have some devices without the Tabs key.  I tried the new version and had the same result - Alfred reverts back to a regular search for "tabs".

 

But if I run the new script from Terminal, it runs without an error & produces what looks to me like properly-formed XML output.  And the output validates when pasted here: http://www.w3schools.com/xml/xml_validator.asp .  I'm not sure what would cause Alfred to stop the script when it runs fine in Terminal.  Any thoughts?

Link to post

Weird. Did you make sure the script portion in the new version in Alfred matches the new python file , to make sure it actually got updated? Other than that I can't think of much. If you want to email the XML you're getting from running it manually I can see if there's any reason that wouldn't display (keep in mind I would see your links)

Link to post

Yep.  Tried it on my laptop that I haven't used in 10 days or so and it worked perfectly.  Let me see if it works on the desktop tomorrow - maybe Alfred cached the old version or something.

 

[edited]

 

9 hours later & it works on my home desktop after a (unrelated) reboot.

Edited by dfay
Link to post

Does anyone know if there's a way to have this workflow just show the results for the workflow? On one of my Macs I'm getting files in the list of results that have "tabs" in the title. Not sure if it matters, but they're .js files. Reason I ask, is because using Alfred's "Action all visible results" command is helpful to open up all the tabs at once. But if there are files in the list as well, that doesn't work well.

 

Also with the latest version, it doesn't seem that it's omitting URLs from the current machine I'm on. Not as big of a deal as #1.

 

Just curious. Thanks! Wish I knew Python or I would help out.

Link to post

I'm not sure if it's possible for a workflow to indicate to Alfred to exclude other results that are similar to the keyword...  I noticed that with other workflows as well.  One option is to just rename the keyword to something unlikely to appear in other file names like "ttt" or "ict" or whatever works for you.  You can do that double clicking on the 'script filter' part of the workflow and changing the keyword value at the top.

 

As far as omitting URLs from the current machine, it still works fine for me.  In that same script filter window, in the 'Script' section where it shows the code, if you scroll down to near the bottom the 13th non blank line up should be;  "if device_name != current_device".  If that doesn't appear just above the "for tab in ..." section then it is the older version of the workflow that doesn't exclude the current device.  Otherwise I'm not sure why it wouldn't work.

Link to post

Ahh yes, the obvious just renaming the keyword. Sorry for missing the obvious :)

 

As for the string, indeed it has "if device_name != current_device" but still doesn't omit my current machine's tabs. Could it have something with it thinking my current device name has a dash in it and the Safari tabs file doesn't have that dash? Reason I ask is my machine name is "Jesse rMBP" — but Sharing Prefs Pane gives it a dash: "Jesse-rMBP" — but in the Safari tabs file its "Jesse rMBP" I'm not familiar enough with Python to try to debug what it thinks my current machine's name is, or I would try to see if that was the issue.

 

Either way, not a huge deal :)

 

Thanks!

Link to post
  • 1 month later...
  • 4 weeks later...
  • 6 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...