kmarchand Posted September 2, 2013 Share Posted September 2, 2013 Loads iCloud tabs from all connected devices and lists them as links. Current device is excluded. It works by copying the ~/Library/SyncedPreferences/com.apple.Safari.plist file to a temp location, converting to XML then parsing the result. https://github.com/kmarchand/iCloudTabsAlfredWorkflow Jono 1 Link to comment
staudi Posted September 2, 2013 Share Posted September 2, 2013 Updated version works. Is it possible to open all tabs at once ? Thanks. Link to comment
kmarchand Posted September 3, 2013 Author Share Posted September 3, 2013 I haven't been able to find a way to do that yet but if I do I'll make the change. Link to comment
shadylane Posted September 3, 2013 Share Posted September 3, 2013 Love the workflow, thanks for sharing! Link to comment
dfay Posted September 3, 2013 Share Posted September 3, 2013 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 comment
kmarchand Posted September 4, 2013 Author Share Posted September 4, 2013 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 comment
chandlervdw Posted September 4, 2013 Share Posted September 4, 2013 This workflow is awesome. Thank you. Do you guys have any ideas about how to try and have your Chrome for Mac tabs sync with your Safari Mobile tabs? In my opinion, Chrome for Mac > Safari for Mac but Safari Mobile > Chrome Mobile. Link to comment
kmarchand Posted September 5, 2013 Author Share Posted September 5, 2013 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 jesselperry 1 Link to comment
jesselperry Posted September 6, 2013 Share Posted September 6, 2013 Thanks! Great workflow. Link to comment
dfay Posted September 6, 2013 Share Posted September 6, 2013 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 comment
kmarchand Posted September 6, 2013 Author Share Posted September 6, 2013 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 comment
dfay Posted September 6, 2013 Share Posted September 6, 2013 (edited) 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 September 6, 2013 by dfay Link to comment
jesselperry Posted September 10, 2013 Share Posted September 10, 2013 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 comment
kmarchand Posted September 10, 2013 Author Share Posted September 10, 2013 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 comment
jesselperry Posted September 11, 2013 Share Posted September 11, 2013 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 comment
kmarchand Posted September 11, 2013 Author Share Posted September 11, 2013 Ok that's interesting. I guess the plist is using the computer name and the workflow was using the network host name to check and I forgot they could be different. I've updated it to exclude both the computer name and network host name from the list of devices. The update is posted here; https://github.com/kmarchand/iCloudTabsAlfredWorkflow Link to comment
jesselperry Posted September 12, 2013 Share Posted September 12, 2013 Awesome! Works great. Thanks again. Link to comment
kmarchand Posted October 26, 2013 Author Share Posted October 26, 2013 Updated version works. Is it possible to open all tabs at once ? Thanks. I found a way to open all tabs at once. Updated version here: https://github.com/kmarchand/iCloudTabsAlfredWorkflow The 'tabs' keyword works the same way and the new 'alltabs' keyword will open all links for all devices in the default browser. Link to comment
paulelms Posted October 28, 2013 Share Posted October 28, 2013 Hello, thanks, useful thing. Correct line 67 like this to filter cyrillic current device names: if device_name not in [hostname, computername.decode("utf-8")]: Link to comment
kmarchand Posted October 28, 2013 Author Share Posted October 28, 2013 Hello, thanks, useful thing. Correct line 67 like this to filter cyrillic current device names: if device_name not in [hostname, computername.decode("utf-8")]: Thanks, good suggestion. I made the change. Link to comment
samvlu Posted November 20, 2013 Share Posted November 20, 2013 Great work! I love being able to quickly open all iCloud tabs. Thanks! Link to comment
heyJoeCampbell Posted April 28, 2020 Share Posted April 28, 2020 Excellent Job @kmarchand 😀👍 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now