dave Posted March 14, 2013 Share Posted March 14, 2013 (edited) I created a small workflow displaying the system's uptime in a notification. Download This is also useful as an example for integrating scripts in your workflow. Enjoy. - David EDIT: corrected the download link to a private hosting provider, wikisend appears to be dubious. Sorry for any inconvenience. Edited March 28, 2013 by dave Domenic 1 Link to comment
Domenic Posted March 24, 2013 Share Posted March 24, 2013 Wrong link? I´d be interested. Link to comment
hzlzh Posted March 24, 2013 Share Posted March 24, 2013 The workflow files is 12MB via the link? Link to comment
DJay Posted March 24, 2013 Share Posted March 24, 2013 I was wondering about the 12MB file too. "small workflow"?? And didn't install it. by the way I was wondering.. not talking about anyone here but can fraudulent people do strange things with alfred workflows when they distribute them here? Link to comment
rice.shawn Posted March 25, 2013 Share Posted March 25, 2013 @DJay — There is the possibility. Since the workflows allow for pretty much any script to be run, then malicious code is easy to install (even if it is just to use curl to download something else). Currently, there isn't any mechanism to automatically flag a workflow as having malicious code. Any user can reply to a forum post declaring malicious code and report the post that has it, but those are the only mechanisms that exist currently. With the Extras page for the Alfred2 website, there will be some featured workflows that will be safe and vetted (I'm sure). With Olivier's repo, currently each workflow and theme needs to be approved, but I'm not sure how much checking will be involved in there because I'm sure that there will be many submissions, and it would take quite a lot of volunteer time to sort through them all. Anything posted here can be vetted only by the community. I have faith that 99% of the users here will post great workflows, and users who have posted many workflows before can easily be trusted, but there is always the possibility that someone can upload a malicious workflow. Be diligent? Link to comment
DJay Posted March 25, 2013 Share Posted March 25, 2013 (edited) @rice.shawn — Thanks a lot for these information and your thoughts. I really appreciate the community here. swapping ideas and great workflows. And of course I think as you mentioned the most girls and boys here are honest. Edited March 28, 2013 by DJay Link to comment
dave Posted March 28, 2013 Author Share Posted March 28, 2013 Oh, wait. That was not supposed to happen. Let me check. Maybe wikisend wasn't that good an idea for hosting the file. Link to comment
dave Posted March 28, 2013 Author Share Posted March 28, 2013 That'll teach me to use the first best upload provider. Here's the corrected link, hosted at my own provider. Sorry for the hassle and thanks for the notification. Link to comment
DJay Posted March 31, 2013 Share Posted March 31, 2013 @Dave Thanks for the workflow and sharing. Sometimes I check the uptime so thats an easy way. Danke auch für das Nusseckenrezept. Link to comment
dave Posted April 1, 2013 Author Share Posted April 1, 2013 @Dave Thanks for the workflow and sharing. Sometimes I check the uptime so thats an easy way. Danke auch für das Nusseckenrezept. You're welcome. :-) Link to comment
Guest Posted April 3, 2013 Share Posted April 3, 2013 And if you just want to know the days, hours and minutes since last reboot, you can use the following term: uptime | sed -e 's/,.[0-9]*.user.*//' -e 's/^.*up *//' this would f.e. result in 2 days, 7:28 Link to comment
dave Posted April 3, 2013 Author Share Posted April 3, 2013 Thanks for the improvement, it's integrated in the updated version available from the same URL. I added an icon as well. Enjoy. Link to comment
DJay Posted April 3, 2013 Share Posted April 3, 2013 Thanks. Maybe you consider implementing Alleyoop for your updates next time. Would be great an easy. http://www.alfredforum.com/topic/1582-alleyoop-update-alfred-workflows/?hl=alleyoop Link to comment
dave Posted April 3, 2013 Author Share Posted April 3, 2013 Version 0.3 integrates alleyoop. Hope this helps with the next update. Link to comment
dave Posted April 4, 2013 Author Share Posted April 4, 2013 Version 0.4 fixes the alleyoop integration; missed that it takes two json files: Link to comment
RodgerWW Posted April 8, 2013 Share Posted April 8, 2013 Just in case anyone would be interested: Another method of formatting the uptime output: uptime | awk '{sub(/[0-9]|user,|users,|load/, "", $6); sub(/mins,|min,/, " minutes", $6); sub(",", " minutes", $5); sub(":", " hours ", $5); sub(/hrs,|hr,/, " hours", $4); sub("h ", " hours ", $4); sub(/days,/, " days ", $4); sub(":", " hours ", $3); sub(",", " minutes", $3); print "" $3 $4 $5 $6}' | sed -e 's/ 1 days/ 1 day/g' -e 's/ 1 hours/ 1 hour/g' -e 's/1 minutes/1 minute/g' -e 's/usermin//g' This will output, in my case: "19 days 17 hours 45 minutes" It's just a tad more human readable, although I find the length of the awk to be a bit ironic Link to comment
DJay Posted April 8, 2013 Share Posted April 8, 2013 (edited) Nice RodgerWW.. Thanks. But looks a bit strange here. Would great to have "0 days, 8 hours, 28 minutes". Whats the 1user minutes? Edited April 8, 2013 by DJay Link to comment
dave Posted April 8, 2013 Author Share Posted April 8, 2013 I would prefer to have the script distinguish between day/days, hour/hours and minute/minutes if moving from the current really plain approach to a more sophisticated implementation. No need for a cryptic perl/sed/awk script, though. Simple, understandable php, python or shell is fine. Anyone? Link to comment
RodgerWW Posted April 9, 2013 Share Posted April 9, 2013 (edited) Nice RodgerWW.. Thanks. But looks a bit strange here. Would great to have "0 days, 8 hours, 28 minutes". Whats the 1user minutes? OK, in lieu of using "uptime" I personally found "system_profiler SPSoftwareDataType | grep 'Time since boot'" to be a bit easier to parse with only one return, as I am very new to awk and grep. So, the initial command "system_profiler SPSoftwareDataType | grep 'Time since boot'" will return: Time since boot: 20 days 11:19 NEW code: system_profiler SPSoftwareDataType| grep 'Time since boot' | awk '{sub(/Time since boot:/, ""); sub(":", " hours ", $3); sub("", "minutes", $4);print "" $0}'| sed -e 's/ 1 days/ 1 day/g' -e 's/ 1 hours/ 1 hour/g' -e 's/00 minutes/0 minutes/g' -e 's/01 minutes/1 minute/g' -e 's/02 minutes/2 minutes/g' -e 's/03 minutes/3 minutes/g' -e 's/04 minutes/4 minutes/g' -e 's/05 minutes/5 minutes/g' -e 's/06 minutes/6 minutes/g' -e 's/07 minutes/7 minutes/g' -e 's/08 minutes/8 minutes/g' -e 's/09 minutes/9 minutes/g' Will return: 20 days 11 hours 19 minutes I'm using awk to to remove "Time since boot:", the time separator, and also to add the hours and minutes. I'm using sed to modify the plural form of days/hours/minutes, and also to remove leading zeros. I'm not sure how the singular days are displayed with 'Time since boot" (as I'm currently on 20 days and have no real reason to reboot my system currently), so I left out that sed formatting, but it can be added easily. Edited April 9, 2013 by RodgerWW Link to comment
RodgerWW Posted April 9, 2013 Share Posted April 9, 2013 (edited) I would prefer to have the script distinguish between day/days, hour/hours and minute/minutes if moving from the current really plain approach to a more sophisticated implementation. No need for a cryptic perl/sed/awk script, though. Simple, understandable php, python or shell is fine. Anyone? I would agree 100% on this ... I WISH I knew how to do this myself ... Would be awesome to start at the epoch time, remove current time, and scriptually only show singular for year/month/day/week/hour/min ... seconds might be going a little too far though, lol. Oh, and also remove leading zeros. So the perfect output: " 1 year 35 days 12 hours 1 minute " Edited April 9, 2013 by RodgerWW Link to comment
mlevison Posted August 17, 2021 Share Posted August 17, 2021 8 yrs later - I run the Script in the current version of Alfred on MacOS 11.5.1 and I don't see a system notification. When I use the debug logs I see: [11:46:42.690] Logging Started... [11:47:10.253] Uptime[Keyword] Processing complete [11:47:10.257] Uptime[Keyword] Passing output '' to Run Script [11:47:10.264] Uptime[Run Script] Processing complete [11:47:10.264] Uptime[Run Script] Passing output '6 days, 23:20 ' to Post Notification -- Something is happening with the notification. Perhaps I need to set a permission for Alfred to display notifications? ... FroZen_X 1 Link to comment
FroZen_X Posted August 17, 2021 Share Posted August 17, 2021 3 minutes ago, mlevison said: Something is happening with the notification. Perhaps I need to set a permission for Alfred to display notifications? Must say thanks for necroing this thread as I from time to time want to check this, but have been too lazy. I downloaded the workflow and tested it directly without any issues. Could it be that you deactivated notifications, maybe through "do not disturb"? Otherwise I think you need to give Alfred permission via "Accessibility", to be able to post notification. Link to comment
mlevison Posted August 17, 2021 Share Posted August 17, 2021 @FroZen_XIt was the Do Not Disturb. I knew it was a simple permissions/config issue - I just couldn't guess which one - Danke - Mark 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