{"id":815,"date":"2024-05-16T12:15:20","date_gmt":"2024-05-16T16:15:20","guid":{"rendered":"https:\/\/www.mbeckler.org\/blog\/?p=815"},"modified":"2024-05-16T12:15:20","modified_gmt":"2024-05-16T16:15:20","slug":"linux-script-to-update-rgb-led-with-busy-status","status":"publish","type":"post","link":"https:\/\/www.mbeckler.org\/blog\/?p=815","title":{"rendered":"Linux script to update RGB LED with busy status"},"content":{"rendered":"\n<p>At my dayjob I often listen to music while working, and sometimes I&#8217;m doing video calls with my team. To help avoid disruption, I put an RGB LED on top of my cubicle wall and wrote a script to update the color based on my activity. Red indicates the camera is active, amber indicates I&#8217;ve got music going, otherwise green.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#\n# Monitor the camera and audio to set LED color\n# if camera active --> RED\n# else if audio active --> YELLOW\n# else --> GREEN\n\nexec 2> \/dev\/null\n\nCOLOR_OLD=\"#ABCDEF\"\nwhile :\ndo\n  COLOR=\"#00FF00\"\n  if lsof \/dev\/video0 > \/dev\/null ; then\n    COLOR=\"#FF0000\"\n  else\n    AUDIO=`pacmd list-sink-inputs | grep -c 'state: RUNNING'`\n    if &#91; \"$AUDIO\" == \"1\" ]; then\n      COLOR=\"#FFAA00\"\n    fi\n  fi\n\n  # Only update blink1 if the color has changed\n  #echo \"\\\"$COLOR\\\" vs \\\"$COLOR_OLD\\\"\"\n  if &#91; $COLOR != $COLOR_OLD ]; then\n    echo \"Color: $COLOR\"\n    blink1-tool --rgb \"$COLOR\" > \/dev\/null\n    COLOR_OLD=$COLOR\n  fi\n\n  sleep 0.1\n\ndone\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>At my dayjob I often listen to music while working, and sometimes I&#8217;m doing video calls with my team. To help avoid disruption, I put an RGB LED on top of my cubicle wall and wrote a script to update the color based on my activity. Red indicates the camera is active, amber indicates I&#8217;ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[52,10,9],"class_list":["post-815","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash","tag-linux","tag-software"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2BznB-d9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=815"}],"version-history":[{"count":1,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":816,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions\/816"}],"wp:attachment":[{"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mbeckler.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}