Kali Linux Desktop PC Initial Setup: Difference between revisions

From WikiMLT
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>

Revision as of 13:02, 17 August 2022

En­able Blue­tooth

In Kali Lin­ux 2022 the Blue­tooth ser­vice is dis­abled by de­fault. In or­der to en­able it run thew fol­low­ing com­mands.

sudo service bluetooth status
sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service

Add Win­dows 10 en­try in­to the Grub menu

sudo nano /etc/default/grub
# SZS: https://wiki.metalevel.tech/wiki/Kali_Linux_Desktop_PC_Initial_Setup
GRUB_DISABLE_OS_PROBER=false
sudo update-grub

In­stall the lat­est Nvidia Dri­ver

Here I'm go­ing to in­stall the Lat­est NVIDIA Dri­ver, rec­om­mend­ed for Quadro T600, which is not pre­sent­ed in the Kali's repos­i­to­ry. The first step is to down­load the lat­est dri­ver: NVIDIA Dri­ver Down­loads > Quadr/​​​RTX T600 > LIN­UX X64 (AMD64/EM64T) DIS­PLAY DRI­VER.

Then Black­list the de­fault Nou­veau dri­ver:

sudo nano /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
sudo update-initramfs -u

Af­ter that re­boot the sys­tem. When the log-in screen come back – don't log-in. Press Ctrl+Alt+F3, and log-in to a TTY, then in­stall the dri­ver.

cd ~/Downloads
chmod +x NVIDIA-Linux-x86_64-515.65.01.run
sudo ./NVIDIA-Linux-x86_64-515.65.01.run

Fi­nal­ly re­boot the sys­tem once again.

Gnome Fa­vorite Ex­ten­sions

Ad­di­tion­al tweaks