{"action":"created","issue":{"url":"https://api.github.com/repos/x74353/Amphetamine/issues/27","repository_url":"https://api.github.com/repos/x74353/Amphetamine","labels_url":"https://api.github.com/repos/x74353/Amphetamine/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/x74353/Amphetamine/issues/27/comments","events_url":"https://api.github.com/repos/x74353/Amphetamine/issues/27/events","html_url":"https://github.com/x74353/Amphetamine/issues/27","id":267182278,"number":27,"title":"Alfred 3 workflow doesn't turn on when manually turned off","user":{"login":"vidavidorra","id":12871315,"avatar_url":"https://avatars1.githubusercontent.com/u/12871315?v=4","gravatar_id":"","url":"https://api.github.com/users/vidavidorra","html_url":"https://github.com/vidavidorra","followers_url":"https://api.github.com/users/vidavidorra/followers","following_url":"https://api.github.com/users/vidavidorra/following{/other_user}","gists_url":"https://api.github.com/users/vidavidorra/gists{/gist_id}","starred_url":"https://api.github.com/users/vidavidorra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidavidorra/subscriptions","organizations_url":"https://api.github.com/users/vidavidorra/orgs","repos_url":"https://api.github.com/users/vidavidorra/repos","events_url":"https://api.github.com/users/vidavidorra/events{/privacy}","received_events_url":"https://api.github.com/users/vidavidorra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-20T13:49:47Z","updated_at":"2017-11-06T10:44:05Z","closed_at":null,"author_association":"NONE","body":"Alfred 3 workflow doesn't turn on when manually turned off. If I'd turn on Amphetamine using `amp on 1h` in alfred (I've changed the default `amphetamine` to `amp` in the workflow) and manually turn it off, running `amp on 1h` for the second time does not work.\r\nIn order to get it working again, I'd need to do `amp off` and then the on command works again.\r\nI'm using this (http://www.packal.org/workflow/amphetamine-control) workflow with some adjustments for running on (from #17) and some adjustments to get the time correctly. Code is below.\r\n\r\nAny idea whether this is a problem in the workflow or the application, and ideas on how to fix this?\r\nRunning latest versions of Amphetamine and Alfred 3 on macOS High Sierra.\r\n\r\n\r\n```applescript\r\non alfred_script(q)\r\n    tell application \"Amphetamine\"\r\n        if (q is not in {\"\", null}) then\r\n            -- Start/activate the app   \r\n            activate\r\n            \r\n            set hoursOnly to no\r\n            \r\n            if (q contains \"h\") and (q does not contain \"m\") then\r\n                set hoursOnly to yes\r\n            end if\r\n            \r\n            -- Remove text from argument\r\n            set q to (do shell script \"echo \" & q & \" | sed 's/hours//g'\")\r\n            set q to (do shell script \"echo \" & q & \" | sed 's/hour//g'\")\r\n            set q to (do shell script \"echo \" & q & \" | sed 's/minutes//g'\")\r\n            set q to (do shell script \"echo \" & q & \" | sed 's/h//g'\")\r\n            set q to (do shell script \"echo \" & q & \" | sed 's/m//g'\")\r\n            \r\n            set someHours to 0\r\n            set someMinutes to 0\r\n            \r\n            if q contains \" \" then\r\n                -- Separate hours and minutes\r\n                set AppleScript's text item delimiters to \" \"\r\n                set someHours to text item 1 of q as number\r\n                set someMinutes to text item 2 of q as number\r\n                set AppleScript's text item delimiters to \"\"\r\n                \r\n                -- Multiply & add to get total seconds\r\n                set someHours to someHours * 60 * 60\r\n                set someMinutes to someMinutes * 60\r\n                \r\n                set q to someHours + someMinutes\r\n            else -- No space, assume only minutes\r\n                if hoursOnly is yes then\r\n                -- set q to q * 60 * 60\r\n                    set q to q * 60\r\n                -- else\r\n                --    set q to q * 60\r\n                end if\r\n            end if\r\n            turn on for q\r\n        else\r\n            turn on\r\n        end if\r\n    end tell\r\nend alfred_script\r\n```"},"comment":{"url":"https://api.github.com/repos/x74353/Amphetamine/issues/comments/342111538","html_url":"https://github.com/x74353/Amphetamine/issues/27#issuecomment-342111538","issue_url":"https://api.github.com/repos/x74353/Amphetamine/issues/27","id":342111538,"user":{"login":"BerniWittmann","id":17594215,"avatar_url":"https://avatars1.githubusercontent.com/u/17594215?v=4","gravatar_id":"","url":"https://api.github.com/users/BerniWittmann","html_url":"https://github.com/BerniWittmann","followers_url":"https://api.github.com/users/BerniWittmann/followers","following_url":"https://api.github.com/users/BerniWittmann/following{/other_user}","gists_url":"https://api.github.com/users/BerniWittmann/gists{/gist_id}","starred_url":"https://api.github.com/users/BerniWittmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BerniWittmann/subscriptions","organizations_url":"https://api.github.com/users/BerniWittmann/orgs","repos_url":"https://api.github.com/users/BerniWittmann/repos","events_url":"https://api.github.com/users/BerniWittmann/events{/privacy}","received_events_url":"https://api.github.com/users/BerniWittmann/received_events","type":"User","site_admin":false},"created_at":"2017-11-06T10:44:04Z","updated_at":"2017-11-06T10:44:04Z","author_association":"NONE","body":"@vidavidorra I found a workaround for this:\r\nThe general idea is to always run `amp off` before. I added a AppleScript to the `on Workflow` which is similar to the one turning it off..\r\n\r\n<img width=\"562\" alt=\"bildschirmfoto 2017-11-06 um 11 42 00\" src=\"https://user-images.githubusercontent.com/17594215/32437428-9d27802c-c2e7-11e7-9ee7-1f5b6e56c081.png\">\r\n\r\nIt's just important to pass the parameter, so the highlighted AppleScript looks like this:\r\n\r\n```\r\non alfred_script(q)\r\n\tset res to q\r\n\ttell application \"Amphetamine\"\r\n\t\tturn off\r\n\tend tell\r\n\treturn res\r\nend alfred_script\r\n```\r\n\r\nBut a less hacky solution is appreciated"}}
{"actor":{"display_login":"BerniWittmann"}}