{"id":1935,"date":"2021-08-18T10:05:13","date_gmt":"2021-08-18T15:05:13","guid":{"rendered":"http:\/\/jimlund.org\/blog\/?p=1935"},"modified":"2021-08-18T10:06:45","modified_gmt":"2021-08-18T15:06:45","slug":"using-cron-to-mute-sound-in-ubuntu-20-04","status":"publish","type":"post","link":"http:\/\/jimlund.org\/blog\/?p=1935","title":{"rendered":"Using cron  to mute sound in Ubuntu 20.04"},"content":{"rendered":"\n<p>I wanted to turn off audio at night automatically using cron.<br><br>I saw suggestions to use amixer:<br>export DISPLAY=:0 &amp;&amp; \/usr\/bin\/amixer -D pulse  sset Master,0 0% <br>but this gave an error:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused<br>amixer: Mixer attach pulse error: Connection refused<br><\/pre>\n\n\n\n<p>This works, add this line to \/etc\/crontab:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* 23&lt;tab>* * *&lt;tab>jiml&lt;tab>DISPLAY=:0.0 pactl --server unix:\/run\/user\/1000\/pulse\/native set-sink-mute @DEFAULT_SINK@ true<\/pre>\n\n\n\n<p>and restart cron:<br>service cron restart<br><br>jiml is the user with the open desktop.<br>&#8216;1000&#8217; is the uid of user &#8216;jiml&#8217;, this can be found by:<br><br>ls \/run\/user <br>or<br>id -u jiml<br><br><\/p>\n\n\n\n<p>and restart cron:<br>\nservice cron restart<\/p>\n\n\n\n<p><br>jiml is the user with the open desktop.<br>&#8216;1000&#8217; is the uid of user &#8216;jiml&#8217;, this can be found by:<br><br>ls \/run\/user <br>or<br>id -u jiml<br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to turn off audio at night automatically using cron. I saw suggestions to use amixer:export DISPLAY=:0 &amp;&amp; \/usr\/bin\/amixer -D pulse sset Master,0 0% but this gave an error: ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refusedamixer: Mixer attach pulse error: Connection refused This works, add this line to \/etc\/crontab: * 23&lt;tab>* * [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,8,23],"tags":[],"class_list":["post-1935","post","type-post","status-publish","format-standard","hentry","category-computers","category-howto","category-linux"],"_links":{"self":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1935"}],"version-history":[{"count":2,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1935\/revisions"}],"predecessor-version":[{"id":1937,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1935\/revisions\/1937"}],"wp:attachment":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}