The Mouseless Window Manager i3

栏目: IT技术 · 发布时间: 4年前

内容简介:You thought that having icons everywhere on your desktop with a beautiful start menu was the better and only way to interact with your computer?Many Linux distributions, and many Operating Systems (OS) in general, like Windows or macOS, have their own desk
The Mouseless Window Manager i3

You thought that having icons everywhere on your desktop with a beautiful start menu was the better and only way to interact with your computer?

Many Linux distributions, and many Operating Systems (OS) in general, like Windows or macOS, have their own desktop environment. It’s basically a set of icons, windows, toolbars, widgets, wallpaper and other functionalities which give to the users “easy” ways to do what they want.

These desktops are meant to be used by everybody. However, everybody has different needs and aspirations when using a computer, and it’s even more true for us, developers.

If you use the terminal pretty often (and you should), a desktop environment might be useless for you, even if you don’t even realize it. Indeed, thanks to the terminal, a developer have already access to everything without the need of a full-blown desktop.

I will present you today an alternative to a desktop environment: a window manager. More precisely, I will show you how i3 windows manager (i3wm) works. It will give you an amazing flexibility and a total control on your system, without even using the mouse!

“But I love my mouse!” you might think, while sadness assault your heart. Trust me, if your fingers don’t have to leave your keyboard, your happiness will go through the roof. You just need to try for enough time to be convinced.

In this article, we will:

  • Learn how to install i3.
  • Learn why using i3 can be very efficient.
  • Learn how work i3.
  • Configure and try i3 together.

Ready? Let’s go!

The Mouseless Window Manager i3
Final result (low resolution)

Installing i3

First things first: i3 is only available for Linux. Sorry, fellow Mac users.

If you already have a Linux distribution installed and you want to try i3, you might be able to do it on top of your actual desktop. Depending on your distribution, it will be more or less easy.

Using Lubuntu with i3, for example, is pretty straightforward: the option to log in with i3 will be given automatically after install. If you use another distribution, you might have to do some minor configuration.

I personally use i3 on Arch Linux and I would recommend using a Linux distribution you know before trying i3. It will be easier for you to focus on i3 itself, instead of struggling with a new Linux distribution.

You can use as well virtual machines to install Linux and try i3 on top of Windows, macOS or whatever other OS you have. The free VMWare Player is the best option if you want to take this path. Tested and approved!

To install i3 itself, simply use your package manager. For example:

sudo apt-get install i3
sudo pacman -S i3

After installing and launching i3, a popup will ask you if you would like to create a configuration automatically. Answer with a big “yes”. We will directly modify this configuration below.

The talkative i3 might ask you as well if mod4 is the modifier you want. Again, answer “yes”. We will come back to this modifier later.

Why Using i3?

Light But Powerful

The first advantage using a Windows Manager (WM) instead of a full desktop environment is its lightness. i3 doesn’t use much resource, which let you spare memory and CPU for everything else. In short, it doesn’t get in your way.

My experience show me that we never have enough resource, especially if you’re used to run 23098832 docker containers at the same time. Many desktop environment (Unity?) are very heavy and buggy nowadays.

The simplicity of i3 will procure to your mind the peace it deserves to focus on more important problems. You know, your code for example.

Minimalist

A desktop environment has many functionalities we don’t necessarily use. The funny thing is: I didn’t know it was a problem before trying something as light as i3.

My experience with i3 is very similar to my experience with Vim: IDE and desktop environments come with a full package of software and options you didn’t choose by yourself. In the contrary, Vim, tmux or i3 come with a pretty blank state you need to personalize.

Instead of trying to shut off cumbersome functionalities (which is not always possible), you just add the functionalities you truly need.

A Windows Manager like i3 showed me that a status bar and an application launcher are enough. Thankfully, i3 comes with both.

Flexible

Another annoyance with regular desktop environments: the windows positioning, especially when you open a new window .

It always felt random to me, which means that you always need to position your windows manually after opening them with the sacrosanct mouse. We’re all used to do this, of course; it doesn’t mean that there are no better, more efficient and comfortable ways to manage windows .

The great i3 will always position windows following a specific layout. No surprise, windows positioning become highly consistent.

Even better, you can change this layout easily with specific keystrokes. It might look constraining at first glance, but at the end it makes the system way simpler than traditional desktop environments. It’s faster, too.

This is one of the greatest strength of i3. Stop spending your time moving windows and get important things done!

Finally, as many tools I use on a daily basis, you can configure easily i3 to answer your own personal needs. As stated above, you can change any keystroke you want, launch specific application at startup, always launch specific applications on specific virtual desktop (called workspaces ) and configure everything you need.

This article will show a possible configuration for i3 while explaining each step, for you to be able to personalize it afterward.

The Mouse Is Not Your Best Friend

Long time reader of my blog won’t be surprised to see that i3 can be entirely used without a mouse. Having your hand constantly on your keyboard is a comfort you can’t give away after tasting it for enough time.

To be honest with you, this is one of the most profound discovery I made regarding my programming workflow for the last decade.

With i3, it’s quick to launch applications, move windows through workspaces , resizing them, and do many other actions using a couple of keystrokes.

How To Use i3?

Writing Your Own Cheatsheet

Writing i3’s keystrokes somewhere as you learn and modify them is helpful. Not only for i3, but for any application using keystrokes extensively such asVim ortmux.

In order to do so, I personally use Joplin , a free, open source, and powerful note taking application, similar to evernote, to write every keystroke I need. It serves as my reference when I forget what keystroke do what action.

General organisation

Like tmux, i3 store its information in a tree data structure. Let’s see what each node can represent.

The Mouseless Window Manager i3

Workspaces

At the top of the tree data structure, you’ll find the workspace . It’s simply the equivalent of a virtual desktop . You can have as many workspaces as you want.

Creating a workspace is simple: you just need to switch to it and create containers in it to make it persistent. More on that below.

Containers

A container contains one or multiple windows . Its windows will be positioned depending on the container ’s layout.

There are three different layouts possible:

  • Split - Each window share the container space and are split horizontally ( splith ) or vertically ( splitv ). This is the default layout.
  • Stacked - The focused window is visible and the other ones are stacked behind. You can change the window ’s focus via keystrokes easily. You have access to the list of windows open too, at the top of the container itself.
  • Tabbed - This layout is similar as the stacked layout, except that the windows ’ list is vertically split, and not horizontally.

Note that a container can contain other containers as well; however, in practice, you won’t often think about containers but more about windows .

Windows

A window , where an application is running, can be created in a container . It will automatically position itself and be in focus, depending on the container ’s layout. You can move them around or even change the layout of the container using keystrokes.

There are two different sorts of windows : fixed windows (by default) and floating windows . You can precise which application should use a floating window . In that case, the window will act like any other window in any other desktop environment: you can focus on them and move them with your mouse.

Note that a floating window is not affected by a container ’s layout.

Floating windows are useful for applications which don’t need a fullscreen window , like pop ups or color grabbers, for example.

The Default Shortcuts

Like tmux or Vim, i3 use a special key for (almost) every keystroke. This key is called a modifier . By default, it’s the windows or cmd key. On most keyboard, it has a Windows sign on it.

You can change this modifier in the configuration. Personally, I like to use the windows key.

In this article, the modifier key will be designed as $mod for every keystroke using it.

Enough mumbling, let’s practice. I strongly advise you now to have i3 open to follow along with me, and to try the modifications we do by yourself.

Let’s create a new terminal by typing $mod + Enter . You know what? Let’s create another one! Hit $mod + Enter again. As you can see, the default layout of your container will automatically fit the two windows running two terminals on your workspace .

Now, try to focus on the second windows by using $mod + arrow key . Simple, isn’t it?

You can now move the windows around and see how they resize themselves automatically: hit $mod + shift + arrow key .

You might think at that point that this system is totally dumb. Don’t lie! I was pretty disappointed the first time I tried it, since I was very much used to move my windows around with my mouse. Now, it’s difficult for me to use something else than a window manager like i3!

Let’s try to change the layout of your container . You can use:

  • $mod + e - Switch to split layout (splith or splitv depending on your screen)
  • $mod + s - Switch to stacked layout
  • $mod + w - Switch to tabbed layout

You can try to create and move windows using each layout to see the differences.

Finally, let’s see other useful keystrokes which will be essential to write and try our new i3 configuration:

$mod + shift + r
$mod + shift + e

Configuring i3

Configuration Files

Different config files will be loaded by i3 in a precise order, overriding each other:

  1. ~/.config/i3/config (or $XDG_CONFIG_HOME/i3/config if set)
  2. ~/.i3/config
  3. /etc/xdg/i3/config (or $XDG_CONFIG_DIRS/i3/config if set)
  4. /etc/i3/config

If you choose to generate your config file when you run i3 for the first time, you’ll need to modify the file ~/.i3/config .

Default Configuration

Let’s dive a bit more into i3’s config, for you to understand its possibilities. First, open your configuration file with whatever editor you want.

We’ll review in this subsection the beginning of the configuration file.

If you want a good and complete documentation of i3, it’s just here . This article is a quick overview of i3 for you to understand why it can be useful for you. After that, the documentation should be your reference for everything else.

The first line of the config will define your modifier key ( $mod ), as I explained above. You can modify it if you like here.

You can see that you can define variable in i3’s configuration using the keyword set followed by the variable name ( $mod here) and its value ( Mod4 ). It’s very practical not to have to modify every single keystroke each time you change your modifier.

To see every possible value for i3’s modifier key, you can run in your terminal xmodmap .

Below in the file, you’ll see the line bindsym $mod+Return exec i3-sensible-terminal . bindsym allows you to bind a symbol to a command. Internally, a symbol is mapped to a keycode (a key on your keyboard). To see this mapping, you can run in your terminal xmodmap -pke | less .

Here, the symbol Return is used. If you prefer using directly a keycode instead of a symbol, you can use the command bindcode instead of bindsym .

This keystroke will execute (using the command exec ) i3-sensible-terminal , a wrapper script which will try to find and open an instance of your terminal.

Let’s continue our exploration. Below you’ll find the line bindsym $mod+Shift+q kill , which allows you to kill a window . Depending on the application running in that window , some operation might be done before closing. For example, Firefox will save the current session.

Program Launcher

With i3, there is no start menu where you can find the applications installed on your system. Instead, you can launch your favorite software using a program launcher.

The line bindsym $mod+d exec dmenu_run define a keystroke to launch dmenu , a simple and powerful application to create menus. We will use it again below.

To launch the program launcher, simply hit $mod+d . You’ll see at the top of your screen a discrete bar appearing. From there, you can search an application and launch it by searching it and hitting Enter .

If you don’t like this way of launching software, you can add your own launcher or even a start menu if you want later.

Focusing and Moving Windows

You can focus or move the different windows in your current workspace using $mod+jkl; or $mod+shift+jkl; . However, since I use Vim pretty extensively, I like to use hjkl to move around. Don’t forget that many other CLI uses these keys as well!

We will now modify i3’s default configuration. Don’t forget to hit $mod + shift + r to apply the changes.

Let’s modify the binding for focusing windows as following:

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

Below in the file, you’ll find the keystrokes to move windows . You can change them as well:

bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

That’s all! Now, you can use Vim keys to change focus or move your windows .

Splitting Containers

The Mouseless Window Manager i3
Two windows in a container split horizontally

Sometimes, you’ll want to open new windows on the side or below the windows already open. By default, to open a windows horizontally, we would need to hit $mod+h . However, we use this keystroke to focus windows .

Let reconfigure the splits as following:

# split in horizontal orientation
bindsym $mod+Ctrl+h split v

# split in vertical orientation
bindsym $mod+Ctrl+v split h

Note that changing orientation will create a new container. You can see its delimitation by changing its layout. I personally like to have only one container (it’s easier to manage). Therefore, I never use these keystrokes.

We can now continue to modify our config: let’s go into the workspace configuration.

Workspaces

Defining Workspaces

You can open and switch to workspaces with the same keystrokes. Here’s the default configuration you’ll normally find in your current configuration file:

# Define names for default *workspaces* for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10

What does it mean?

  • The first part defines the variables for each workspace . You have 10 of them by default.
  • The second part define keystrokes to switch to these workspaces .
  • The third part define keystrokes to move windows to specific workspace .

From there, you can configure your workspaces as you wish. Here’s my own configuration as an example:

set $terms "1: terms"
set $web "2: web"
set $db "3: db"
set $file_manager "4: files"
set $mail "5: mails"
set $documents "6: documents"
set $mindmap "7: mindmap"

# switch to workspace
bindsym $mod+1 workspace $terms
bindsym $mod+2 workspace $web
bindsym $mod+3 workspace $db
bindsym $mod+4 workspace $file_manager
bindsym $mod+5 workspace $mail
bindsym $mod+6 workspace $documents
bindsym $mod+7 workspace $mindmap
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $terms
bindsym $mod+Shift+2 move container to workspace $web
bindsym $mod+Shift+3 move container to workspace $db
bindsym $mod+Shift+4 move container to workspace $file_manager
bindsym $mod+Shift+5 move container to workspace $mail
bindsym $mod+Shift+6 move container to workspace $documents
bindsym $mod+Shift+7 move container to workspace $mindmap
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

If you have Font Awesome installed, you can even add some fancy icons.

Another functionality I find practical: the possibility to come back to your last workspace with the same keystroke. For example, if you are on the workspace 1 and you hit $mod+2 , you’ll switch to workspace 2 .

Then, if you hit $mod+2 again, you’ll go back to your previous workspace , workspace 1 .

To enable this functionality, you need to add to your configuration:

workspace_auto_back_and_forth yes`

Opening Applications in a Specific Workspace

You have as well the possibility to always assign precise application to defined workspaces . Let’s say that you always want to open Firefox in the workspace 2 , $web , from the example just above. You can add in your configuration:

assign [class="firefox" instance="Navigator"] → $web

You can assign the application using its class (its general identifier), its instance (an identifier which is specific to some windows ), or both.

To get the class name and the instance name of a precise application’ window , you need to run the application itself, open a terminal and run the following:

xprop | grep WM_CLASS

Then, click on the window where the application is running. Something similar to the following line will appear in your terminal:

WM_CLASS(STRING) = "Navigator", "firefox"

The first element is always the instance , the second always the class . Be careful: the case matters.

Resizing Windows

If you continue to go through the configuration, you’ll find keystrokes for fullscreen and diverse ways to reload i3’s config.

Let’s delete the line:

Below, you’ll find keystrokes to resize windows . Let’s modify them, again to match the Vim key bindings hjlk .

bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt

You’ll notice that your first need to go in mode resize before being able to resize. It means that you first need to hit $mod+r (you’ll see the word resize appearing at the bottom of the screen), then you can use $mod + hjkl .

We can as well set focus_follows_mouse to no . Otherwise, each time you’ll hover on a windows , it will be automatically focused. Pretty annoying to me.

Locking Screen

To lock your screen for your coworkers not sending embarrassing messages on Slack on your behalf, you’ll need the software i3lock . You can try to launch it to see if it’s installed; if it’s not, simply install it.

By default, the lock screen is a boring white screen which will destroy your eyes. If you don’t care, you can let it as it is.

Otherwise, you can configure it to display a wonderful wallpaper as follow:

set $i3lockwall i3lock -i /path/to/my-wonderful-image.png -t

It’s important to note that you can only use png files with i3lock . No jpeg supported!

My own wallpaper is a bit more complex. I use a script to take a screenshot of the current screen, automatically “pixelize” it, save it, and use it as a lock screen. With a lock screen that good, every coworker will pray your skills and your swag. Expect a big salary increase, too.

To run the script, you’ll need to install imagemagick and scrot . Here it is:

img=/tmp/i3lock.png

scrot $img
convert $img -scale 10% -scale 1000% $img

i3lock -u -i $img

Simply save this script somewhere (I like to have a script subdirectory in `~/.config/i3) and create a new variable in the i3’s configuration file:

set $i3lockwall sh ~/.config/i3/scripts/lock.sh

Finally, add a keystroke to lock your screen:

bindsym $mod+Ctrl+Shift+l exec --no-startup-id $i3lockwall

We’ll see that it’s possible to lock your screen using dmenu as well (you know, the software we use already for our application launcher). More on that below.

Last but certainly not least: to unlock your computer, type your user’s password and press Enter .

Lock, Shutdown and Reboot Menu

Let’s find and delete the following line:

bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

This allows you to log out of i3. However, we’ll now implement a better way to do so.

Let’s create a menu with dmenu to have a nice and discrete way to lock your screen, log out i3, suspend your computer, hibernate, reboot, shutdown everything, or conquering the world.

Simply add the following to your configuration:

# shutdown / restart / suspend...
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Ctrl+s) shutdown

mode "$mode_system" {
    bindsym l exec --no-startup-id $i3lockwall, mode "default"
    bindsym e exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $i3lockwall && systemctl suspend, mode "default"
    bindsym h exec --no-startup-id $i3lockwall && systemctl hibernate, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym Ctrl+s exec --no-startup-id systemctl poweroff -i, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+BackSpace mode "$mode_system"

Now, after reloading the config, if you hit $mod+BackSpace , you’ll see on the bottom of your screen a message which precise what you can do. You can hit l , e , s , h , r or Ctrl+s depending on what you want to do.

If you want to just close the menu, hit Escape or Return .

Wallpaper

When you switch to a workspace which doesn’t have any window yet, it’s nice to have a wonderful wallpaper. The easiest solution: using feh , a simple software which can display images.

First, You need to install it.

Then, you can add to your configuration:

exec --no-startup-id feh --no-fehbg --bg-fill '/path/to/your-favorite-holiday-picture.jpg'

Floating windows

Some applications are easier to use with floating windows . In short, it’s a window you can move with your mouse.

For example, pop-up and task dialog should be floating. To do so, add these two lines in your configuration file:

# floating pop up automatically
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable

You can specify what application should be open with a floating window automatically, using the class and instance of the application, as explained above (see the workspace section).

For example:

for_window [class="Keepassx"] floating enable

Thanks to this line, the application Keepassx will automatically be opened in a floating window .

Colors and Style

You can configure colors and style for i3 directly in the configuration file. If you have your terminal colors defined in the Xresources file (typically ~/.Xresources ), you can reuse them directly with i3 if you use the set_from_resource directive.

For example, set_from_resource $foreground foreground #C6C6C6 will define a variable $foreground which will use the foreground color defined in Xresources or, if it’s not defined, the fallback color #C6C6C6 .

You can then use the variable $foreground everywhere you need it in the configuration. Here’s an example of my own configuration:

# get color from XResource configuration - variable_name XResource fallback

# special
set_from_resource $foreground foreground #C6C6C6
set_from_resource $background background #1C1C1C
set_from_resource $cursorColor cursorColor #C6C6C6

# black
set_from_resource $black1 color0 #303030
set_from_resource $black2 color8 #444444
set $trueblack #000000

# red
set_from_resource $red1 color1 #d75f5f
set_from_resource $red2 color9 #d75f5f

# green
set_from_resource $green1 color2 #87AF87
set_from_resource $green2 color10 #87AF87

# yellow
set_from_resource $yellow1 color3 #ffd75f
set_from_resource $yellow2 color11 #ffd75f

# blue
set_from_resource $blue1 color4 #87afd7
set_from_resource $blue2 color12 #87afd7

# magenta
set_from_resource $cyan1 color5 #afafd7
set_from_resource $cyan2 color13 #afafd7

# cyan
set_from_resource $cyan1 color6 #afd7ff
set_from_resource $cyan2 color14 #afd7ff

# white
set_from_resource $white1 color7 #4E4E4E
set_from_resource $white2 color15 #ffffff

Instead of set_from_resource , you can of course define your own variables, such as set $black #000000 .

Configuration of the i3 Bar

You can configure the status bar at the bottom of the screen too of course, using a different configuration file. You’ll find below an example you can copy in a new file, for example ~/.config/i3/i3status.conf . Feel free to modify it, of course.

You can customize the data displayed in the bar using shell scripts, too.

# i3status configuration file.
# see "man i3status" for documentation.

# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!

general {
    interval = 1
    colors = true
    color_good="#FFFFFF"
    color_degraded="#ffd75f"
    color_bad="#d75f5f"
}

order += "volume master"
order += "battery 0"
order += "disk /"
order += "disk /home"
order += "cpu_usage"
order += "load"
order += "tztime local"

tztime local {
        format = " %Y-%m-%d %H:%M:%S "
}

disk "/home" {
     format = " %avail "
}

disk "/" {
     format = " %avail "
}

cpu_usage {
    format = " %usage "
}

load {
    format = " %5min 5min "
}

volume master {
    format = " %volume "
    format_muted = " %volume "
    device = "default"
    mixer = "Master"
    mixer_idx = 0
}

battery 0 {
    format = "%status %percentage "
    format_down = " DOWN "
    status_chr = " CHARGING "
    status_bat = " BATTERY "
    status_unk = " UNKNOWN "
    #last_full_capacity = true
    status_full = " FULL "
    path = "/sys/class/power_supply/BAT%d/uevent"
}

To use this status bar, you need to specify the file path in i3’s configuration file. Normally, the block bar { is already there, you just need to modify it according to your needs.

For example:

bar {
    status_command i3status --config ~/.i3/i3status.conf
    # Disable all tray icons
    tray_output none
    colors {
        background $black2
        statusline $white2
        separator $white2 

        #                  border background text
        focused_workspace  $background $background $red1
        active_workspace   $black2 $black1 $white2
        inactive_workspace $black1 $black2 $foreground
        urgent_workspace   $red1 $red1 $white2
        binding_mode       $background $red2 $white2
    }
}

You can notice that we use the color variables defined above, to make the bar even prettier! Wonderful.

Managing Your Screen

If you have two, three or 389 screens, you might notice that you have no way to configure them.

Installing arandr can help you in that regard. You need to install it.

Then, let’s make its window floating:

for_window [class="Arandr"] floating enable

You can now run it (using your application launcher, remember?) and configure your screen orientation and placement as you wish.

This is nice and all, but this configuration is not persistent. Here’s a way to fix that:

  1. Configure arandr as you wish
  2. Save the layout from arandr . This will create a script similar to the following:

    xrandr --output VGA-1 --off --output eDP-1 --primary --mode 1600x900 --pos 0x0 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off

I then use dmenu to create a menu to manage my different screen configurations. For example, you can add in the i3’s config:

set $mode_display Config monitor resolution - My first config (d) - My second config (t)

mode "$mode_display" {
    bindsym d exec --no-startup-id xrandr --output VGA-1 --off --output eDP-1 --primary --mode 1600x900 --pos 0x0 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off && ~/.fehbg, mode "default"
    bindsym t exec --no-startup-id xrandr --output eDP-1 --primary --mode 1600x900 --pos 0x809 --rotate normal --output VGA-1 --mode 1920x1080 --pos 2800x420 --rotate normal --output DP-1 --off --output HDMI-1 --mode 1920x1200 --pos 1600x0 --rotate left --output DP-2 --off --output HDMI-2 --off

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+x mode "$mode_display"
  1. First, we set a variable $mode_display which will display the menu we want.
  2. Then, we bind d and t to the content of the script created before.

With this method, you can create many screen configurations and switch from one to another easily.

The Mouseless Window Manager i3
Final result (high resolution)

Will You Stick With i3?

That’s all folks! With this first overview of i3, you should be able to do whatever you want without having a cumbersome desktop environment going in your way.

In this article, we learnt:

  • i3 is a very light and minimalist windows manager, yet powerful and flexible.
  • What are workspaces , containers , fixed and floating windows .
  • How to configure i3.
  • How to configure the lock screen i3lock .
  • How to create a shutdown menu.
  • How to personalize the status bar.
  • How to manage your screen configurations with arandr .

There’s much more to discover about i3 and I invite you again to go through its very complete documentation.


以上所述就是小编给大家介绍的《The Mouseless Window Manager i3》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

打造Facebook

打造Facebook

王淮、祝文让 / 印刷工业出版社 / 2013-2-1 / 39.80元

《打造Facebook》新书发布会,王淮与读者面对面,活动链接:http://www.douban.com/event/18166913/ 这本书的书名——《打造Facebook:亲历Facebook爆发的5年》很嚣张,谁有资格可以说这句话呢,当然,扎克伯格最有资格,但他不会亲自来告诉你,至少从目前的情况来看,近几年都不大可能。而且,这不是一个人的公司。里面的每一人,尤其是工程师,既是公司文......一起来看看 《打造Facebook》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具