
{"id":44775,"date":"2023-11-24T13:02:12","date_gmt":"2023-11-24T13:02:12","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=44775"},"modified":"2024-05-05T13:41:18","modified_gmt":"2024-05-05T13:41:18","slug":"shortcut-switch-monitor-input-source-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/11\/shortcut-switch-monitor-input-source-ubuntu\/","title":{"rendered":"Add Shortcut Key to Switch Monitor Input Source in Ubuntu 24.04 | 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-43719\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/monitor-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>Have 2 or more PCs connected to a single external monitor? If you run Ubuntu (or other Linux) on one of the PCs, then here&#8217;s how to add a keyboard shortcut to switch video source on the monitor.<\/p>\n<p>Most external monitors today have more than one video input ports, e.g., HDMI1, HDMI2, DP1, allowing to connect with different computers at the same time.<\/p>\n<p>And, they usually support DDC\/CI protocol to control monitors without hitting physical buttons.<\/p>\n<div id=\"attachment_44776\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-44776\" class=\"size-large wp-image-44776\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-600x290.webp\" alt=\"\" width=\"600\" height=\"290\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-600x290.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-300x145.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-768x371.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-1536x742.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-2048x989.webp 2048w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/my-monitor-input-1320x638.webp 1320w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-44776\" class=\"wp-caption-text\">I have multiple computers connected to the single monitor.<\/p><\/div>\n<p>To save desktop space, I have only one monitor on my desk, and 2 computers connected to this single monitor. One is running Windows 10 for gaming and another with Ubuntu for work.<\/p>\n<p>In Windows, I use <a href=\"http:\/\/www.nirsoft.net\/utils\/control_my_monitor.html\" target=\"_blank\" rel=\"noopener\">ControlMyMonitor<\/a> (<i>it&#8217;s http link, not sure if it works now<\/i>) to modify monitor settings and <a href=\"https:\/\/www.autohotkey.com\/\" target=\"_blank\" rel=\"noopener\">autohotkey<\/a> to setup keyboard shortcuts.<\/p>\n<p>In Ubuntu and most other Linux, it&#8217;s easy to do the job through <code>ddcutil<\/code>. And, here&#8217;s the how to steps one by one.<\/p>\n<p><b>NOTE: This tutorial is tested and works in my case in Ubuntu 22.04 and Ubuntu 24.04, though it should also works in all other Ubuntu releases, such as Ubuntu 20.04.<\/b><\/p>\n<h3>Step 1: Install ddcutil<\/h3>\n<p>For Ubuntu user, simply press <b>Ctrl+Alt+T<\/b> on keyboard to open a terminal window. When it opens, run command to install the command line tool:<\/p>\n<pre>sudo apt install ddcutil<\/pre>\n<p><i>Type user password when it asks for sudo authentication, though there&#8217;s no asterisk feedback.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44077\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil-600x259.webp\" alt=\"\" width=\"600\" height=\"259\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil-600x259.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil-300x130.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil-768x332.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil-1320x570.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/06\/apt-ddcutil.webp 1428w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>For Fedora, RHEL, based systems, run the dnf command below instead:<\/p>\n<pre>sudo dnf install ddcutil<\/pre>\n<p>And, Arch based Linux can install it via command:<\/p>\n<pre>sudo pacman -S ddcutil<\/pre>\n<h3>Step 2: setup permission<\/h3>\n<p>After installing the package above, <code>i2c<\/code> user group is created. You have to add current user to that group by running command:<\/p>\n<pre>sudo gpasswd --add $USER i2c<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43723\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup-600x161.webp\" alt=\"\" width=\"600\" height=\"161\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup-600x161.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup-300x80.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup-768x205.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/add-i2cgroup.webp 770w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Not sure if required, but try to <strong>restart computer<\/strong> if next step does not work for you.<\/p>\n<h3>Step 3: Use Linux command to Switch Monitor Input Source<\/h3>\n<p>1. Now, run command in terminal to report connected monitors, and find out the logical display number:<\/p>\n<pre>ddcutil detect<\/pre>\n<p><i>In my case, it&#8217;s number 1. Usually you can skip this step if only one monitor connected.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44777\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect-600x370.webp\" alt=\"\" width=\"600\" height=\"370\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect-600x370.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect-300x185.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect-768x473.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddc-detect.webp 777w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>2. Next, run command to find out the feature code, as well as its values for input source:<\/p>\n<pre>ddcutil --display 1 capabilities<\/pre>\n<p><i>Replace number 1 to yours according to the last command. And you can just skip for <code>--display 1<\/code><\/i>.<\/p>\n<p>In the terminal output, <b>60<\/b> is the input source feature code for me. And, values include: <b>0f<\/b> and <b>11<\/b> in hex. So, they are <b>0x0f<\/b> and <b>0x11<\/b>.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44778\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode-600x543.webp\" alt=\"\" width=\"600\" height=\"543\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode-600x543.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode-300x272.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode-768x695.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/ddcutil-input-featurecode.webp 867w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>3. After finding out the feature code and its values, <strong>try running command to switch monitor input source:<\/strong><\/p>\n<pre>ddcutil setvcp 60 0x11<\/pre>\n<p><i>In this command, replace <b>60<\/b> to yours feature code. And, replace <b>0x11<\/b> (its HDMI-1 in my case) to your values according which video source to switch to.<\/i><\/p>\n<h3>Step 4: Setup keyboard shortcut to switch input source<\/h3>\n<p>If the <code>ddcutil setvcp<\/code> command works for you, now you may do following steps to set keyboard shortcuts to do the job.<\/p>\n<p><b>For GNOME<\/b> (default desktop in Ubuntu &amp; Fedora), open &#8216;Settings&#8217; and navigate to &#8220;Keyboard -&gt; Keyboard Shortcuts -&gt; View and Customize Shortcuts&#8221;.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38428\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings-600x413.webp\" alt=\"\" width=\"600\" height=\"413\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings-600x413.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings-300x206.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings-768x528.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/keyboard-settings.webp 957w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>In pop-up dialog, select &#8220;Custom Shortcuts&#8221;, then add new shortcut with:<\/p>\n<ul>\n<li>Name: switch monitor input source (or whatever you want).<\/li>\n<li>Command: <code>ddcutil setvcp 60 0x11<\/code> (change code 60 &amp; 0x11 according to yours).<\/li>\n<li>Shortcut: whatever key combination that you want.<\/li>\n<\/ul>\n<p>Also, add another keyboard shortcut to switch back.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor-back.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44779\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor-back.webp\" alt=\"\" width=\"518\" height=\"300\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor-back.webp 518w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor-back-300x174.webp 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44780\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor.webp\" alt=\"\" width=\"518\" height=\"300\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor.webp 518w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/switch-monitor-300x174.webp 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/a><\/p>\n<p><b>For other Desktop Environments<\/b>, try launching &#8220;Keyboard Shortcuts&#8221;, &#8220;Shortcut Keys&#8221;, &#8220;Custom Shortcuts&#8221;, &#8220;Keyboard&#8221;, etc, for the custom keyboard shortcuts settings page.<\/p>","protected":false},"excerpt":{"rendered":"<p>Have 2 or more PCs connected to a single external monitor? If you run Ubuntu (or other Linux) on one of the PCs, then here&#8217;s how to add a keyboard shortcut to switch video source on the monitor. Most external monitors today have more than one video input ports, e.g., HDMI1, HDMI2, DP1, allowing to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":43719,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2091],"class_list":["post-44775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-hardware"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=44775"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/43719"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=44775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=44775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=44775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}