|
|
Line 52: |
Line 52: |
| * [https://extensions.gnome.org/extension/1160/dash-to-panel/ Dash to Panel] | | * [https://extensions.gnome.org/extension/1160/dash-to-panel/ Dash to Panel] |
|
| |
|
| == Create a Custom Display Switch Option by Xrandr and Pactl == | | == Additional tweaks == |
| The Gnome's built-in monitor switch option - <kbd>Supper</kbd>+<kbd>P</kbd> - is too limited and also doesn't allow you to switch the audio output. So here is short manual how to implement a '''Custom Display Switch Option by Xrandr and Pactl'''.
| | * [[Create a Custom Display Switch Option by Xrandr and Pactl]] |
| | | * [[Visual Studio Code on Linux]] |
| Note <code>xrandr</code> is not available for Wayland, also some distributions as the latest PopOS! doesn't support Pulseaudio (pactl). This setup perfectly works with Kali Linux 2022 and Ubuntu 22.04 with Xorg.
| |
| | |
| {{Media
| |
| | n = 1
| |
| | img = NVIDIA Settings - X Server Display Configuration.png
| |
| | label = f
| |
| }}
| |
| === Generate Display Profiles ===
| |
| | |
| You can use <code>xrandr</code> to switch the display settings via the command line while X11/Xorg is in use. Also there is a tool named <code>autorandr</code>, that allows you to easily save and restore the <code>xrandr</code>'s profiles - I would prefer to use it with a combination of NVIDIA Settings...
| |
| | |
| To install the latest version of <code>autorandr</code> use the command:
| |
| | |
| <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| sudo pip install autorandr
| |
| </syntaxhighlight>Then use NVIDIA Settings control panel to adjust the different display profiles and save them, one by one - see {{Media-cite|f|1}}, by the following command.
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| autorandr --save LGUW_ACER_LGTV
| |
| </syntaxhighlight>In addition you can set a default profile by the command:
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| autorandr --default LGUW
| |
| </syntaxhighlight>
| |
| You can enforce the above by creating the following file. <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| nano ~/.xprofile
| |
| </syntaxhighlight><syntaxhighlight lang="bash" line="1">
| |
| /usr/local/bin/autorandr LGUW
| |
| </syntaxhighlight>
| |
| | |
| === Generate Audio Profiles ===
| |
| Follow the guide [https://askubuntu.com/q/1011806/566421 How do I switch the audio outputs of an audio device from CLI?] and compose the command-lines that you need to switch your audio outputs. In my case I'm having two displays with built-in audio connected to my NVIDIA Quadro T600 and the commands to switch these two outputs are the following.<syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-shell-gray">
| |
| pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo-extra2
| |
| </syntaxhighlight>
| |
| | |
| === Create a script to toggle the displays ===
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| nano ~/bin/toggle-displays.sh && chmod +x ~/bin/toggle-displays.sh
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="bash" class="mlw-pre-max-height-320">
| |
| #!/bin/bash
| |
| | |
| # autorandr profiles: LGUW, LGTV, LGUW_LGTV, LGUW_LGTV_ACER, LGUW_ACER_LGTV, LGUW_ACER
| |
| | |
| STATE="/tmp/toggle-displays.sh.state"
| |
| CURRENT=$(cat "$STATE")
| |
| [[ -z ${CURRENT} ]] && CURRENT=0
| |
| | |
| if [[ CURRENT -eq 1 ]]; then
| |
| /usr/local/bin/autorandr LGUW_LGTV
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo
| |
| echo $((CURRENT+=1)) > "$STATE"
| |
| elif [[ CURRENT -eq 2 ]]; then
| |
| /usr/local/bin/autorandr LGUW_LGTV
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo-extra2
| |
| echo $((CURRENT+=1)) > "$STATE"
| |
| elif [[ CURRENT -eq 3 ]]; then
| |
| /usr/local/bin/autorandr LGTV
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo-extra2
| |
| echo $((CURRENT+=1)) > "$STATE"
| |
| elif [[ CURRENT -eq 4 ]]; then
| |
| /usr/local/bin/autorandr LGUW_LGTV_ACER
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo-extra2
| |
| echo $((CURRENT+=1)) > "$STATE"
| |
| elif [[ CURRENT -eq 5 ]]; then
| |
| /usr/local/bin/autorandr LGUW_ACER_LGTV
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo-extra2
| |
| echo $((CURRENT+=1)) > "$STATE"
| |
| else
| |
| /usr/local/bin/autorandr LGUW
| |
| /usr/bin/pactl set-card-profile alsa_card.pci-0000_09_00.1 output:hdmi-stereo
| |
| echo 1 > "$STATE"
| |
| fi
| |
| </syntaxhighlight>
| |
| | |
| * Note you need to tweak the script according your environment!
| |
| * Test the script within the command line.
| |
| | |
| {{Media
| |
| | n = 2
| |
| | img = Gnome Settings - Keyboard - Custom Shortcuts.png
| |
| | label = f
| |
| }}
| |
| === Create Custom Keyboard Shortcut ===
| |
| | |
| First disable the Gnome's (3.26+) built-in <kbd>Supper</kbd>+<kbd>P</kbd> shortcut. You can do it by searching for <code>switch-monitor</code> within <code>Dconf Editor</code> tool, or via the command line by the following command.
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-continue">
| |
| gsettings set org.gnome.mutter.keybindings switch-monitor "[]"
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="shell" line="1" class="mlw-shell-gray">
| |
| gsettings set org.gnome.mutter.keybindings switch-monitor "['<Super>p', 'XF86Display']" # Restore
| |
| </syntaxhighlight>
| |
| | |
| Then create your Custom Shortcut as it is shown at {{Media-cite|f|2}}.
| |
| | |
| === References ===
| |
| | |
| * GitHub: [https://github.com/phillipberndt/autorandr/ Autorandr]
| |
| * Ask Ubuntu: [https://askubuntu.com/q/754231/566421 How do I save my new resolution setting with xrandr?]
| |
| * Ubuntu Wiki: [https://wiki.ubuntu.com/X/Config/Resolution#Setting_xrandr_changes_persistently Resolution > Setting xrandr changes persistently] | |
| * Ask Ubuntu: [https://askubuntu.com/q/1011806/566421 How do I switch the audio outputs of an audio device from CLI?]
| |
| * Ask Ubuntu: [https://askubuntu.com/q/68463/566421 How to disable global <Super>P shortcut?]
| |
|
| |
|
| <noinclude> | | <noinclude> |