<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>WindowManager &amp;mdash; Bruno&#39;s ramblings</title>
    <link>https://infosec.press/brunomiguel/tag:WindowManager</link>
    <description>A blog where I ramble about... well... stuff.</description>
    <pubDate>Mon, 25 May 2026 00:56:47 +0000</pubDate>
    <item>
      <title>💻 Toggle screen blanking and screensaver on X11 from the terminal</title>
      <link>https://infosec.press/brunomiguel/toggle-screen-blanking-and-screensaver-on-x11-from-the-terminal</link>
      <description>&lt;![CDATA[I&#39;ve been having an issue on i3wm that&#39;s been bugging me: the screen blanking doesn&#39;t get disabled with software like caffeine or stimulator. Both used to work but suddenly stopped, and I have no idea why.&#xA;&#xA;Fortunately, there&#39;s xset to manage the screen blanking and screensaver from the terminal.&#xA;&#xA;I wrote a function for my shell (zsh) to make it more interactive and easier to use. On a window manager, I can attribute keybindings to specific options to toggle the screen blanking and the screensaver or query their statuses, then get a notification about the change or the query.&#xA;!--more--&#xA;The function is:&#xA;&#xA;function XScreenManage {&#xA;&#x9;&#x9;if ! command -v notify-send &amp;  /dev/null; then&#xA;&#x9;&#x9;&#x9;echo -e &#34;Warning: notify-send could not be found. Please install it using\&#xA;your distribution native package manager. On Arch Linux, you can install it\&#xA;with \&#34;sudo pacman -Sy libnotify\&#34;&#34;&#xA;&#x9;&#x9;&#x9;return 1 2  /dev/null&#xA;&#x9;&#x9;fi&#xA;&#xA;&#x9;&#x9;local blanking() {&#xA;&#x9;&#x9;&#x9;&#x9;blankingstatus=$(xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6)&#xA;&#x9;&#x9;&#x9;&#x9;blankingoff=&#34;prefer blanking:  no&#34;&#xA;&#x9;&#x9;&#x9;&#x9;blankingon=&#34;prefer blanking:  yes&#34;&#xA;&#xA;&#x9;&#x9;&#x9;&#x9;if [[ $blankingstatus = $blankingoff ]]; then&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;echo -e &#34;\n\e[0;93mEnabling screen blanking...&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s blank&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;notify-send &#34;Screen blanking enabled&#34;&#xA;&#x9;&#x9;&#x9;&#x9;else&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;echo -e &#34;\n\e[0;93mDisabling screen blanking...&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s noblank&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;notify-send &#34;Screen blanking disabled&#34;&#xA;&#x9;&#x9;&#x9;&#x9;fi&#xA;&#x9;&#x9;}&#xA;&#xA;&#x9;&#x9;local screensaver() {&#xA;&#x9;&#x9;&#x9;&#x9;screensaverstatus=$(xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5)&#xA;&#x9;&#x9;&#x9;&#x9;screensaveroff=&#34;timeout:  0&#34;&#xA;&#x9;&#x9;&#x9;&#x9;screensaveron=&#34;timeout:  600&#34;&#xA;&#xA;&#x9;&#x9;&#x9;&#x9;if [[ $screensaverstatus = $screensaveroff ]]; then&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;echo -e &#34;\n\e[0;93mEnabling screensaver...&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s on&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;notify-send &#34;Screensaver enabled&#34;&#xA;&#x9;&#x9;&#x9;&#x9;else&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;echo -e &#34;\n\e[0;93mDisabling screensaver...&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s off&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;notify-send &#34;Screensaver disabled&#34;&#xA;&#x9;&#x9;&#x9;&#x9;fi&#xA;&#x9;&#x9;}&#xA;&#xA;&#x9;&#x9;local status() {&#xA;&#x9;&#x9;&#x9;&#x9;notify-send &#34;$(xset s q | grep -i blanking | cut -d &#34; &#34; -f2-6)&#34;&#xA;&#x9;&#x9;&#x9;&#x9;notify-send &#34;$(xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5)&#34;&#xA;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i blanking | cut -d &#34; &#34; -f2-6&#xA;&#x9;&#x9;&#x9;&#x9;xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5&#xA;&#x9;&#x9;}&#xA;&#xA;&#x9;&#x9;case &#34;$1&#34; in&#xA;&#x9;&#x9;&#x9;&#x9;-b)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;blanking;;&#xA;&#x9;&#x9;&#x9;&#x9;-s)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;screensaver;;&#xA;&#x9;&#x9;&#x9;&#x9;-q)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;status;;&#xA;&#x9;&#x9;&#x9;&#x9;-h | )&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;echo -e &#34;-b\ttoggle screen blanking\n-s\ttoggle screensaver\n-q\t\&#xA;query screen blanking and screensaver status\n-h\tdisplay help&#34;&#xA;&#x9;&#x9;esac&#xA;}&#xA;&#xA;I only tested them with zsh, as a function in my .zshrc, but it should work with bash and dash. It probably doesn&#39;t work in shells like fish, though. Also, you need notify-send, but the script throws an error and stops if it doesn&#39;t detect it in your $PATH*.&#xA;&#xA;This function is licensed under the CC0 1.0 license.&#xA;&#xA;#Linux #X11 #Xset #WindowManager #i3wm]]&gt;</description>
      <content:encoded><![CDATA[<p>I&#39;ve been having an issue on <em>i3wm</em> that&#39;s been bugging me: the screen blanking doesn&#39;t get disabled with software like <a href="https://launchpad.net/caffeine" rel="nofollow"><em>caffeine</em></a> or <a href="https://flathub.org/apps/io.github.sigmasd.stimulator" rel="nofollow"><em>stimulator</em></a>. Both used to work but suddenly stopped, and I have no idea why.</p>

<p>Fortunately, there&#39;s <em>xset</em> to manage the screen blanking and screensaver from the terminal.</p>

<p>I wrote a function for my shell (<em>zsh</em>) to make it more interactive and easier to use. On a window manager, I can attribute keybindings to specific options to toggle the screen blanking and the screensaver or query their statuses, then get a notification about the change or the query.

The function is:</p>

<pre><code class="language-sh">function XScreenManage {
		if ! command -v notify-send &amp;&gt; /dev/null; then
			echo -e &#34;Warning: notify-send could not be found. Please install it using\
your distribution native package manager. On Arch Linux, you can install it\
with \&#34;sudo pacman -Sy libnotify\&#34;&#34;
			return 1 2&gt;/dev/null
		fi


		local blanking() {
				blanking_status=$(xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6)
				blanking_off=&#34;prefer blanking:  no&#34;
				blanking_on=&#34;prefer blanking:  yes&#34;

				if [[ $blanking_status = $blanking_off ]]; then
					echo -e &#34;\n\e[0;93mEnabling screen blanking...&#34;
					xset s blank
					xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6
					notify-send &#34;Screen blanking enabled&#34;
				else
					echo -e &#34;\n\e[0;93mDisabling screen blanking...&#34;
					xset s noblank
					xset s q | grep -i blanking | cut -d &#34; &#34; -f3-6
					notify-send &#34;Screen blanking disabled&#34;
				fi
		}

		local screensaver() {
				screensaver_status=$(xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5)
				screensaver_off=&#34;timeout:  0&#34;
				screensaver_on=&#34;timeout:  600&#34;

				if [[ $screensaver_status = $screensaver_off ]]; then
					echo -e &#34;\n\e[0;93mEnabling screensaver...&#34;
					xset s on
					xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5
					notify-send &#34;Screensaver enabled&#34;
				else
					echo -e &#34;\n\e[0;93mDisabling screensaver...&#34;
					xset s off
					xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5
					notify-send &#34;Screensaver disabled&#34;
				fi
		}

		local status() {
				notify-send &#34;$(xset s q | grep -i blanking | cut -d &#34; &#34; -f2-6)&#34;
				notify-send &#34;$(xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5)&#34;
				xset s q | grep -i blanking | cut -d &#34; &#34; -f2-6
				xset s q | grep -i timeout | cut -d &#34; &#34; -f3-5
		}

		case &#34;$1&#34; in
				-b)
						blanking;;
				-s)
						screensaver;;
				-q)
						status;;
				-h | *)
						echo -e &#34;-b\ttoggle screen blanking\n-s\ttoggle screensaver\n-q\t\
query screen blanking and screensaver status\n-h\tdisplay help&#34;
		esac
}
</code></pre>

<p>I only tested them with <em>zsh</em>, as a function in my <em>.zshrc</em>, but it should work with <em>bash</em> and <em>dash</em>. It probably doesn&#39;t work in shells like <em>fish</em>, though. Also, you need <em>notify-send</em>, but the script throws an error and stops if it doesn&#39;t detect it in your <em>$PATH</em>.</p>

<p>This function is licensed under the <a href="http://creativecommons.org/publicdomain/zero/1.0" rel="nofollow">CC0 1.0 license</a>.</p>

<p><a href="/brunomiguel/tag:Linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Linux</span></a> <a href="/brunomiguel/tag:X11" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">X11</span></a> <a href="/brunomiguel/tag:Xset" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Xset</span></a> <a href="/brunomiguel/tag:WindowManager" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">WindowManager</span></a> <a href="/brunomiguel/tag:i3wm" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">i3wm</span></a></p>
]]></content:encoded>
      <guid>https://infosec.press/brunomiguel/toggle-screen-blanking-and-screensaver-on-x11-from-the-terminal</guid>
      <pubDate>Mon, 18 Mar 2024 09:27:36 +0000</pubDate>
    </item>
  </channel>
</rss>