{"action":"created","issue":{"url":"https://api.github.com/repos/katernet/darkmode/issues/6","repository_url":"https://api.github.com/repos/katernet/darkmode","labels_url":"https://api.github.com/repos/katernet/darkmode/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/katernet/darkmode/issues/6/comments","events_url":"https://api.github.com/repos/katernet/darkmode/issues/6/events","html_url":"https://github.com/katernet/darkmode/issues/6","id":363395701,"node_id":"MDU6SXNzdWUzNjMzOTU3MDE=","number":6,"title":"Ability to provide specific light/dark schedule","user":{"login":"IdanAdar","id":7255583,"node_id":"MDQ6VXNlcjcyNTU1ODM=","avatar_url":"https://avatars0.githubusercontent.com/u/7255583?v=4","gravatar_id":"","url":"https://api.github.com/users/IdanAdar","html_url":"https://github.com/IdanAdar","followers_url":"https://api.github.com/users/IdanAdar/followers","following_url":"https://api.github.com/users/IdanAdar/following{/other_user}","gists_url":"https://api.github.com/users/IdanAdar/gists{/gist_id}","starred_url":"https://api.github.com/users/IdanAdar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IdanAdar/subscriptions","organizations_url":"https://api.github.com/users/IdanAdar/orgs","repos_url":"https://api.github.com/users/IdanAdar/repos","events_url":"https://api.github.com/users/IdanAdar/events{/privacy}","received_events_url":"https://api.github.com/users/IdanAdar/received_events","type":"User","site_admin":false},"labels":[{"id":859072556,"node_id":"MDU6TGFiZWw4NTkwNzI1NTY=","url":"https://api.github.com/repos/katernet/darkmode/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-09-25T03:23:43Z","updated_at":"2018-09-26T12:20:53Z","closed_at":null,"author_association":"NONE","body":"That is, I'd like Light Mode to start at, for example, 06:00am and Dark Mode to start at, for example, 19:00pm.\r\n\r\nIf I could supply these values as arguments to the script and this will override the default behavior (change to Dark Mode on sunset) it'd be great!"},"comment":{"url":"https://api.github.com/repos/katernet/darkmode/issues/comments/424694556","html_url":"https://github.com/katernet/darkmode/issues/6#issuecomment-424694556","issue_url":"https://api.github.com/repos/katernet/darkmode/issues/6","id":424694556,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDY5NDU1Ng==","user":{"login":"katernet","id":37143923,"node_id":"MDQ6VXNlcjM3MTQzOTIz","avatar_url":"https://avatars2.githubusercontent.com/u/37143923?v=4","gravatar_id":"","url":"https://api.github.com/users/katernet","html_url":"https://github.com/katernet","followers_url":"https://api.github.com/users/katernet/followers","following_url":"https://api.github.com/users/katernet/following{/other_user}","gists_url":"https://api.github.com/users/katernet/gists{/gist_id}","starred_url":"https://api.github.com/users/katernet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katernet/subscriptions","organizations_url":"https://api.github.com/users/katernet/orgs","repos_url":"https://api.github.com/users/katernet/repos","events_url":"https://api.github.com/users/katernet/events{/privacy}","received_events_url":"https://api.github.com/users/katernet/received_events","type":"User","site_admin":false},"created_at":"2018-09-26T12:20:53Z","updated_at":"2018-09-26T12:20:53Z","author_association":"OWNER","body":"What do you guys think of this framework so far? Can you see any optimizations?\r\n\r\n```\r\n#!/bin/bash\r\n\r\ndarkdir=~/desktop/darkmode\r\nplistR=~/desktop/local.test.sunrise.plist\r\nplistS=~/desktop/local.test.sunset.plist\r\n\r\n#set -x\r\n\r\ndarkMode() {\r\n\tcase $1 in\r\n\t\toff) \r\n\t\t\t# Dark Mode OFF\r\n\t\t\t\r\n\t\t\tif [[ $2 = static ]]; then\r\n\t\t\t\teditPlist add $3 0 \"$plistS\"\r\n\t\t\tfi\r\n\t\t\t;;\r\n\t\ton)\r\n\t\t\t# Dark Mode ON\r\n\t\t\t\r\n\t\t\tif [[ $2 = static ]]; then\r\n\t\t\t\teditPlist add $4 0 \"$plistR\"\r\n\t\t\tfi\r\n\t\t\t;;\r\n\tesac\r\n}\r\n\r\nsolar() {\r\n\t#mkdir \"$darkdir\" 2> /dev/null\r\n\tif [[ $1 = static ]]; then\r\n\t\triseT24=$2\r\n\t\tsetT24=$3\r\n\t\tgetTime static $riseT24 $setT24\r\n\tfi\r\n\tif [ $# -eq 0 ]; then\r\n\t\t# Vanilla script\r\n\t\t:\r\n\tfi\r\n}\r\n\r\nlaunch() {\r\n\t/usr/libexec/PlistBuddy -c \"Add :Label string io.github.katernet.darkmode.sunrise\" \"$plistR\" 1> /dev/null\r\n\t/usr/libexec/PlistBuddy -c \"Add :Program string ${darkdir}/darkmode.sh\" \"$plistR\" \r\n\t/usr/libexec/PlistBuddy -c \"Add :RunAtLoad bool true\" \"$plistR\" \r\n\t/usr/libexec/PlistBuddy -c \"Add :Label string io.github.katernet.darkmode.sunset\" \"$plistS\" 1> /dev/null\r\n\t/usr/libexec/PlistBuddy -c \"Add :Program string ${darkdir}/darkmode.sh\" \"$plistS\"\r\n}\r\n\r\neditPlist() {\r\n\tcase $1 in\r\n\t\tadd)\r\n\t\t\t/usr/libexec/PlistBuddy -c \"Add :StartCalendarInterval:Hour integer $2\" \"$4\"\r\n\t\t\t/usr/libexec/PlistBuddy -c \"Add :StartCalendarInterval:Minute integer $3\" \"$4\"\r\n\t\t\t;;\r\n\t\tupdate)\r\n\t\t\t# Vanilla script\r\n\t\t\t;;\r\n\tesac\r\n}\r\n\r\ngetTime() {\r\n\tif [ $# -eq 0 ]; then\r\n\t\t# Vanilla script\r\n\t\t:\r\n\telse\r\n\t\triseH=$2\r\n\t\triseM=0\r\n\t\tsetH=$3\r\n\t\tsetM=0\r\n\tfi\r\n\ttimeH=$(date +\"%H\" | sed 's/^0//')\r\n\ttimeM=$(date +\"%M\" | sed 's/^0//')\r\n}\r\n\r\n# ---- config ----\r\n\r\nif (( $1 >= 0 && $1 <= 24 )) && (( $2 >= 0 && $2 <= 24 )); then\r\n\tsolar static $1 $2\r\nelif (( $1 < 0 && $1 > 24 )) || (( $2 < 0 && $2 > 24 )); then\r\n\texit 1\r\nelse\r\n\tsolar\r\nfi\r\n\r\nif [ ! -f \"$plistR\" ] || [ ! -f \"$plistS\" ]; then\r\n\tlaunch\r\nfi\r\n\r\n# ---- code -----\r\n\r\necho $1\r\necho $2\r\n\r\nif [[ \"$timeH\" -ge \"$riseH\" && \"$timeH\" -lt \"$setH\" ]]; then\r\n\tif [[ \"$timeH\" -ge $((riseH+1)) || \"$timeM\" -ge \"$riseM\" ]]; then\r\n\t\tif [ $# -eq 0 ]; then\r\n\t\t\tdarkMode off # Vanilla script\r\n\t\telse \r\n\t\t\tdarkMode off static $1 $2\r\n\t\tfi\r\n\telif [[ \"$timeH\" -ge \"$setH\" && \"$timeM\" -ge \"$setM\" ]] || [[ \"$timeH\" -le \"$riseH\" && \"$timeM\" -lt \"$riseM\" ]]; then \r\n\t\tif [ $# -eq 0 ]; then\r\n\t\t\tdarkMode on # Vanilla script\r\n\t\telse \r\n\t\t\tdarkMode on static $1 $2\r\n\t\tfi\r\n\tfi\r\nelif [[ \"$timeH\" -ge 0 && \"$timeH\" -lt \"$riseH\" ]]; then\r\n\tif [ $# -eq 0 ]; then\r\n\t\tdarkMode on # Vanilla script\r\n\telse \r\n\t\tdarkMode on static $1 $2\r\n\tfi\r\nelif [[ \"$timeH\" -eq \"$setH\" && \"$timeM\" -lt \"$setM\" ]]; then\r\n\tif [ $# -eq 0 ]; then\r\n\t\tdarkMode on # Vanilla script\r\n\telse \r\n\t\tdarkMode on static $1 $2\r\n\tfi\r\nelse\r\n\tif [ $# -eq 0 ]; then\r\n\t\tdarkMode on # Vanilla script\r\n\telse \r\n\t\tdarkMode on static $1 $2\r\n\tfi\r\nfi\r\n\r\n```"}}
{"actor":{"display_login":"katernet"}}