Skip to content

eccanto/linux-env

Repository files navigation

Overview

Configuration of my Linux environment.

themes

Table of contents

Get started

Installation

bash install.sh

to install a particular tool (e.g. ranger):

bash install.sh -t ranger

get available tools:

$ bash install.sh -l

24 available tools:
  - vscode
  - conky
  - i3lock
  - alacritty
  - picom
  - bat
  - polybar
  - rofi
  - ranger
  - tmux
  - i3
  - fzf
  - neovim
  - dunst
  - btop
  - lsd
  - nerd_font
  - zsh
  - lazydocker
  - speedtest
  - firefox
  - bsnotifier
  - lazygit
  - w3m

to install a wallpaper:

bash install.sh -w

Tools

I3

i3 is a tiling window manager:

i3 tiling window manager

shortcut description
Win + u hide borders
Win + y restore borders
Win + n change to "normal" border mode (show window title)
Win + Shift + q kill focused window
Win + Enter open Alacritty terminal emulator
Win + d open Rofi - Application and executable explorer
Win + i open Rofi - Application GUIs explorer
Win + Escape open Rofi - System menu: poweroff, sleep, etc.
Win + Print open flameshot - screenshot capturer
Win + l lock screen session
Win + Left focus left window
Win + Right focus right window
Win + Down focus down window
Win + Up focus up window
Win + Shift + Left move the focused window to left (also delete stacked layouts)
Win + Shift + Right move the focused window to right
Win + Shift + Down move the focused window to down
Win + Shift + Up move the focused window to up
Win + Ctrl + Shift + Left move the focused workspace to left
Win + Ctrl + Shift + Right move the focused workspace to right
Win + Ctrl + Shift + Down move the focused workspace to down
Win + Ctrl + Shift + Up move the focused workspace to up
Win + b workspace back and forth
Win + Shift + b move window to workspace back_and_forth
Win + h change split mode to "horizontal"
Win + v change split mode to "vertical"
Win + f toggle fullscreen mode for the focused window
Win + s change layout mode to "stacking"
Win + w change layout mode to "tabbed"
Win + e change layout mode to "toggle split"
Win + Shift + Space toggle tiling / floating
Win + Space change focus between tiling / floating windows
Win + Shift + s Sticky floating windows, even if you switch to another workspace
Win + a focus the parent window
Win + Shift + Minus move the currently focused window to the scratchpad
Win + Shift show the next scratchpad window or hide the focused scratchpad window.
Win + Ctrl + Left focus left workspace
Win + Ctrl + Right focus right workspace
Win + Shift + c reload the configuration file
Win + Shift + r restart i3 inplace
Win + Shift + e exit i3
Win + 0 Set shut down, restart and locking features
Win + r enable resize windows mode
Win + Shift + g enable gap mode

I3Lock

A modern version of i3lock with color functionality and other features (github).

i3lock command

shortcut description
Win + l lock screen session borders

Rofi

A window switcher, Application launcher and dmenu replacement (github).

Rofi executables explorer

Rofi Executables

shortcut description
Win + d open Rofi executables explorer

Rofi applications explorer

Rofi Applications

shortcut description
Win + i open Rofi applications explorer

Rofi System menu

Rofi Applications

shortcut description
Win + Escape open Rofi applications explorer

VSCode

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.

VSCode

shortcut description
Alt + s [navigation] Find and jump to word
Alt + b [navigation] Breadcrumb keyboard navigation
Alt + f [navigation] Find file
Alt + g [navigation] Find string
Alt + \ [navigation] Bracket matching
Alt + d [navigation] Go to definition
Alt + , [navigation] Go to back
Alt + . [navigation] Go to forward
Ctrl + g [navigation] Go to line/column
Ctrl + n [terminal] Create new terminal
Ctrl + s [terminal] Split terminal
Ctrl + q [terminal] Kill terminal
Ctrl + j [terminal] Focus previous terminal
Ctrl + k [terminal] Focus next terminal
Ctrl + r [editor] Rename
Ctrl + $ [editor] Move to end and select
Alt + $ [editor] Move to end
Ctrl + _ [editor] Move to home and select
Alt + _ [editor] Move to home
Shift + Del [editor] Delete line
Ctrl + Shift + m [editor] Display problems panel
Ctrl + Shift + Space [editor] Display problem diagnostic hover
Ctrl + Space [editor] Display suggestions
Ctrl + 0 [editor] Select sidebar
Ctrl + b [editor] If the editor is focused: toggle sidebar explorer view
Ctrl + b [editor] If the terminal is focused: focus previous editor group
Ctrl + shift + b [editor] Toggle and focus sidebar explorer view
Alt + Shift + [Up,Down] [editor] Mark select multi-line [Up,Down]
Ctrl + Shift + [Up,Down] [editor] Move lines [Up,Down]
Ctrl + [Up,Down] [editor] Scroll to [Up,Down]
Alt + [Left,Right,Up,Down] [split] Focus [Left,Right,Up,Down] group and side bar (circularly)
Alt + Up [split] If the terminal is focused: focus previous group
Ctrl + Alt + [Left,Right,Up,Down] [split] Move to [Left,Right,Up,Down] group
Ctrl + Alt + Shift + [Left,Right,Up,Down] [split] Resize group view width
Ctrl + Alt + f [split] Full screen selected group
Ctrl + m [preview] Open markdown preview on the Side
Ctrl + Enter [explorer] Open file in split view

Neovim

My Neovim configuration: github

Neovim

Tmux

tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached. (github).

Tmux

shortcut description
tmux start new
tmux new -s [NAME] start new with session name
tmux a attach
tmux a -t [NAME] attach to named
tmux ls list sessions
tmux kill-session -t [NAME] kill session
tmux kill-server kill server (restart configurations)
Alt + c enable copy/scroll mode (exit: "q")
[Ctrl + b] + Ctrl + s save tmux state (tmux-resurrect)
[Ctrl + b] + Ctrl + r restore tmux state (tmux-resurrect)
[Ctrl + b] + I fetch plugins - update plugins
Alt + n create window
Alt + Tab next window
Alt + Left select left pane
Alt + Right select right pane
Alt + Up select up pane
Alt + Down select down pane
Alt + Shift + Left split left pane
Alt + Shift + Right split right pane
Alt + Shift + Up split up pane
Alt + Shift + Down split down pane
Alt + z Zoom current pane
Alt + 4 resize pane to left
Alt + 6 resize pane to right
Alt + 8 resize pane to up
Alt + 2 resize pane to down
[Ctrl + b] s list sessions
[Ctrl + b] c create window
[Ctrl + b] w list windows
[Ctrl + b] n next window
[Ctrl + b] p previous window
[Ctrl + b] f find window
[Ctrl + b] , rename window
[Ctrl + b] & kill window
[Ctrl + b] % vertical split
[Ctrl + b] " horizontal split
[Ctrl + b] o swap panes
[Ctrl + b] q show pane numbers
[Ctrl + b] x kill pane
[Ctrl + b] d detach tmux

fzf

fzf is a general-purpose command-line fuzzy finder (github).

fzf command

shortcut description
Ctrl + r find in history from terminal
Ctrl + t find path from terminal

Ranger

A VIM-inspired file manager for the console (github).

Ranger

shortcut description
Win + e open ranger as explorer
f find file (using fzf)
e open file/folder with an external application
i display file (preview)
yp copy path of the selected file/folder
Shift + s open shell on current directory
F2 rename selected file/directory
yy copy selected file/directory
pp paste selected file/directory
dD delete selected file/directory
Alt + j scroll preview down
Alt + k scroll preview up
Ctrl + r reset
Shift + w display logs
g + n create new tab
g + c close tab
:mkdir create directory
:touch create file

tty-clock

Open digital clock in terminal.

tty-clock -ct -f "%H:%M, %d %b %Y"

tty-clock command

Peek

Simple screen recorder with an easy to use interface (github):

peek

Peek

Flameshot

Powerful yet simple to use screenshot software (github).

Flameshot

nVLC

VLC command-line.

shortcut description
h,H Show/Hide help box
P Show/Hide playlist box
B Show/Hide filebrowser
q, Q, Esc Quit
s Stop
Pause/Play
n, p Next/Previous playlist item
, Seek -/+ 1%
a, z Volume Up/Down
m Mute

Useful

Change keyboard layout

# change to Español latam
setxkbmap -layout latam

# change to English US
setxkbmap -layout us

# chante to English US and select compose key
setxkbmap -layout us -option compose:ralt

To make this configuration permanent you can add "setxkbmap -layout latam" to ~/.config/i3/config or use another autostart configuration file.

# Autostart applications
exec_always --no-startup-id setxkbmap -layout latam

Search icons in system fonts

sudo apt install gucharmap

gucharmap

Generate monitor profile

arandr

Relocate the monitors and save the profile "Layout -> Save as" (bash file). You can generate multiple profiles for different situations (home, office, etc.).

Reconfigure powerlevel10k

p10k configure

Disable underlining of the powerlevel10k zsh-syntax-highlighting plugin

Add the following to your .zshrc:

(( ${+ZSH_HIGHLIGHT_STYLES} )) || typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[path]=none
ZSH_HIGHLIGHT_STYLES[path_prefix]=none

Show exit code in powerlevel10k

To show fail exit code change value to true in ~/.p10k.zsh file.

typeset -g POWERLEVEL9K_STATUS_ERROR=true

To show success exit code change value to true in ~/.p10k.zsh file.

typeset -g POWERLEVEL9K_STATUS_OK=true

Fix polybar brightness module on amd card

  1. get card name:

    $ ls -1 /sys/class/backlight/
    amdgpu_bl0
  2. update polybar configuration file:

    # file: ~/.config/polybar/config
    # card = intel_backlight
    card = amdgpu_bl0
  3. restart polybar

    pkill polybar && polybar i3wmthemer_bar &
  4. [optional] if permission denied

    sudo chmod a+rw /sys/class/backlight/$(ls /sys/class/backlight/ | head -n 1)/brightness

Set polybar on multiple screens

  1. Create a polybar launcher script:

    # launch_polybar.sh
    
    if type "xrandr"; then
        for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
            MONITOR=$m polybar --reload i3wmthemer_bar &
        done
    else
        polybar --reload i3wmthemer_bar &
    fi
  2. Edit the polybar config file (~/.config/polybar/config):

    [bar/i3wmthemer_bar]
    monitor = ${env:MONITOR:}
    ...
    
  3. Kill current polybar:

    sudo pkill polybar
    
  4. Run script:

    bash launch_polybar.sh
    

Remove absolute path from current working directory

Edit ~/.p10k.zsh, search for POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER and change its value to first:

  typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=first

p10k

Change permissions on sys brightness permanently using udev

  1. Add your user to video group:

    sudo usermod -a -G video <YOUR_USERNAME>
  2. Get your video system kernel (YOUR_KERNEL) running this command:

    # get <YOUR_KERNEL>
    ls /sys/class/backlight/ | head -n 1
  3. Create/edit /etc/udev/rules.d/backlight.rules file:

    ACTION=="change", SUBSYSTEM=="backlight", KERNEL=="<YOUR_KERNEL>", RUN+="/usr/bin/chgrp video /sys/class/backlight/%k/brightness"
    ACTION=="change", SUBSYSTEM=="backlight", KERNEL=="<YOUR_KERNEL>", RUN+="/usr/bin/chmod g+w /sys/class/backlight/%k/brightness"
  4. restart your system.

Enter SSH passphrase once

  1. Install dependencies:

    sudo apt install keychain
  2. Configure git, create/edit ~/.ssh/config file (YOUR_REMOTE_HOST example: "github.com", and YOUR_SSH_KEY example: "~/.ssh/id_rsa"):

    Host <YOUR_REMOTE_HOST>
        IgnoreUnknown UseKeychain
        UseKeychain yes
        AddKeysToAgent yes
        IdentityFile <YOUR_SSH_KEY>
    

    Example with multiple hosts:

    IgnoreUnknown UseKeychain
    
    host *
        Usekeychain yes
        Addkeystoagent yes
    
    Host github.com
        IdentityFile ~/.ssh/github
    
    Host <COMPANY_HOST>
        IdentityFile ~/.ssh/git_company
        Port <COMPANY_PORT>
    
  3. Change git config file mode:

    chmod 644 ~/.ssh/config
  4. Add keychain to profile file (example: ~/.zshrc, ~/.bashrc, etc.)

    ...
    
    eval $(keychain -q --noask --eval id_rsa)

Bluetooth - a2dp-sink profile connect failed

When I try to connect to any headphone, blueman throws:

blueman.bluez.errors.DBusFailedError: Protocol not available.

In logs there are pretty similar errors:

... bluetoothd[000]: a2dp-sink profile connect failed for 00:00:00:00:00

To solve it, follow these steps:

  1. Run the following commands:

    sudo apt-get install pulseaudio-module-bluetooth
  2. Adding the module-bluez5-discover at the end of the pulseaudio /etc/pulse/default.pa config:

    load-module module-bluez5-discover
    
  3. Run the following commands:

    sudo killall pulseaudio
    pulseaudio --start
    sudo systemctl restart bluetooth

Changing i3 workspace monitors

To set workspace 1 on the HDMI-2 monitor add this line to ~/.config/i3/config:

workspace 1 output HDMI-2

To set workspace 2 on the DP-1 monitor add this line to ~/.config/i3/config:

workspace 2 output DP-1

Developers

Static code analysis tools

These are the linters that will help us to follow good practices and style guides of our source code. We will be using the following static analysis tools, which will be executed when generating a new commit in the repository (git hooks).

Install development requirements

pip install -r requirements_dev.txt
sudo apt install shellcheck

Set up the Git hooks custom directory

After cloning the repository run the following command in the repository root:

git config core.hooksPath .githooks

Python Static Checkers

Tools used:

  • brunette: A best practice Python code formatter.

  • isort: Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

  • prospector: Prospector is a tool to analyze Python code and output information about errors, potential problems, convention violations and complexity.

    Tools executed by Prospector:

    • pylint: Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.
    • bandit: Bandit is a tool designed to find common security issues.
    • dodgy: It is a series of simple regular expressions designed to detect things such as accidental SCM diff checkins, or passwords or secret keys hard coded into files.
    • mccabe: Complexity checker.
    • mypy: Mypy is an optional static type checker for Python.
    • pydocstyle: pydocstyle is a static analysis tool for checking compliance with Python PEP 257.
    • pycodestyle: pycodestyle is a tool to check your Python code against some of the style conventions in PEP 8.
    • pyflakes: Pyflakes analyzes programs and detects various errors.
    • pyroma: Pyroma is a product aimed at giving a rating of how well a Python project complies with the best practices of the Python packaging ecosystem, primarily PyPI, pip, Distribute etc, as well as a list of issues that could be improved.

Compatibility

  • Only tested on Ubuntu 23.04

Disclaimer

I am not responsible for any harm done to your PC by anything in the repository. Use everything with caution!

License

MIT

About

configuration of my Linux environment

Resources

Stars

Watchers

Forks

Packages

No packages published