My acquaintance with WM Awesome. Part 1

We’ll talk about my first meeting with a window manager like Awesome. For a long time I used Gnome2, then I tried Gnome3, I decided to try kde, but none of this satisfied me. Yes, by the way, I have Gentoo. Yes, the article is aimed at newcomers like me - in order to simplify life.

In the official portage branch, version 3.4.15 is stable, but I decided to put the last available version - 3.5.2-r1, with the USE flag “dbus”. As the login manager, I chose SLiM. After assembling all the necessary packages, open /etc/conf.d/xdm and install SLiM as the default manager:

DISPLAYMANAGER="slim"

Next, you need to make a small change to /etc/slim.conf

# login_cmd exec /bin/sh - ~/.xinitrc %session
login_cmd exec /bin/bash -login ~/.xinitrc %session
# login_cmd exec /bin/bash -login /usr/share/slim/Xsession %session

In this config you can also select your favorite theme, which are in / usr / share / slim / themes. I manage default. There are also a couple of interesting parameters, but I did not touch them - there is no need.

The terminal I decided to use urxvt. I have it assembled:

rxvt USE="xgetdefaults"
rxvt-unicode USE="256-color focused-urgency font-styles mousewheel perl startup-notification vanilla xft"

In order for our wm to start, you need to incorporate the changes into the ~ / .xinitrc file (if it is not there, then create it)

urxvtd --quiet --opendisplay --fork &
pulseaudio --start &
exec ck-launch-session dbus-launch awesome

; in the second, we start pulseaudio clearly, and in the last, we start awesome itself. It is worth noting that if you have systemd, not consolekit, then your awesome call seems to be different, but I do not use systemd, so I can’t pretend to say so.

Launch
sudo /etc/init.d/xdm start

xdm : Log in and watch this picture:


I climbed various forums for a long time in search of beautiful themes, configs, widgets for awesome. I came across such an unligic user (he has a lot of articles and interesting things on github)



And a newer version of his theme:



I was very impressed with this and I decided to put myself on his topic - but it was unsuccessful. The theme just didn't work. When correcting one error, a new one appeared, etc. Later I saw his post, the content was something like this: “I don’t advise putting a beginner, since there are a lot of crutches, spend a lot of time and not the fact that it will work”. Actually, it happened. Then I decided to write the config myself. I did not have knowledge in Lua at all, but Google always helps.

The configuration file is in /etc/xdg/awesome/rc.lua - but I do not recommend touching it, just copy it
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/rc.lua
(Someone may not have a .config directory, do not be alarmed - just create it.
mkdir ~/.config
mkdir ~/.config/awesome

Let's start the configuration. (Yes, I used many articles to simply rewrite it)

Here we list all the connected libraries
---------------------------------------------
--- Стандартные библиотеки ---
---------------------------------------------
local gears = require("gears")
local awful = require("awful")
local vicious = require("vicious")
awful.rules = require("awful.rules")
require("awful.autofocus")
local wibox = require("wibox")
local beautiful = require("beautiful")
local naughty = require("naughty")
local menubar = require("menubar")
local dbus = require("dbus")



Everything seems to be clear :)
---------------------------------------------------------
--- Устанавливаем системную локаль ---
---------------------------------------------------------
os.setlocale("ru_RU.UTF-8")



We leave this part unchanged - this is an error handler
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
    naughty.notify({ preset = naughty.config.presets.critical,
                     title = "Oops, there were errors during startup!",
                     text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
    local in_error = false
    awesome.connect_signal("debug::error", function (err)
        -- Make sure we don't go into an endless error loop
        if in_error then return end
        in_error = true
        naughty.notify({ preset = naughty.config.presets.critical,
                         title = "Oops, an error happened!",
                         text = err })
        in_error = false
    end)
end
-- }}}



I took the zenburn theme as a basis (lies in / usr / share / awesome / themes / zenburn). And I decided to change it a bit for myself (almost not significantly, for now)
-------------------------------------
--- Устанавливаем тему ---
-------------------------------------
beautiful.init("/home/worm2fed/.config/awesome/themes/worm2fed/theme.lua")



The -nw option in the last line allows emacs to run in the terminal
----------------------------------------------------------------------
--- Устанавливаем приложения по умолчанию ---
----------------------------------------------------------------------
terminal         = "urxvtc" -- Терминал по умолчанию
browser         = "google-chrome-stable" -- Браузер по умолчанию
editor              = os.getenv("EDITOR") or "emacs" -- Редактор по умолчанию
editor_cmd    = terminal .. " -nw" .. editor -- Команда запуска консольного редактора



The indentation horribly moved out, but in the editor it is all beautiful. The modifier key - it is also called super, the key with the logo of the windows. Most often it is Mod4, but it may differ. And then the codes of the mouse buttons and the keys needed in the config. To check the mouse codes:
xev | grep 'button'

For the modifier key and other keys:
xev | grep 'keycode'

Button and Key Codes
-----------------------------------------
--- Клавиша-модификатор ---
-----------------------------------------
modkey             = "Mod4"
---------------------------
--- Кнопки мыши ---
---------------------------
left_button                  = 1
wheel_button            = 2
right_button               = 3
plus_button               = 4 
minus_button           = 5
wheel_left_button    = 6
wheel_write_button = 7
-----------------------------------
--- Скан-коды клавиш ---
-----------------------------------
key_V              = "#55"
key_Z              = "#52"
key_Y               = "#29"
key_J                = "#44"
key_K               = "#45"
key_N               = "#57"
key_M               = "#58"
key_F                = "#41"
key_R               = "#27"
key_L                = "#46"
key_C               = "#54"
key_W               = "#25"
key_X                = "#53"
key_Q                = "#24"
key_H                = "#43"
key_Tab             = "#23"
key_Tilda           = "#49"
key_U                  = "#30"
key_E                  = "#26"
key_T                   = "#28"
key_P                   = "#33"
key_O                   = "#32"
key_Return          = "#36"
key_Left               = "#113"
key_Right            = "#114"
key_Esc               = "#9"
key_Print              = "#107"
key_Alt_R             = "#108"
key_Alt_L              = "#64"
key_Space           = "#65"
key_Ctrl_R           = "#105"
key_Ctrl_L            = "#37"
key_Home            = "#110"
key_F1                   = "#67"
key_Mute               = "#121"
key_Vol_Down     = "#122"
key_Vol_Up          = "#123"



Here I selected the window layouts I need
------------------------------------------------------------------------------
--- Layouts - способы расположения окон на экране ---
-----------------------------------------------------------------------------
local layouts =
{
    awful.layout.suit.floating,          -- 1  
    awful.layout.suit.tile,                  -- 2 Главное окно слева, справа второстепенные (мелкие)
    --awful.layout.suit.tile.left,         -- * Слева второстепенные окна
    awful.layout.suit.tile.bottom,    -- 3 Внизу второстепенные окна
    --awful.layout.suit.tile.top,         -- * Второстепенные окна вверху
    awful.layout.suit.fair,                  -- 4
    --awful.layout.suit.fair.horizontal,
    --awful.layout.suit.spiral,
    awful.layout.suit.spiral.dwindle,    -- 5
    awful.layout.suit.max,                      -- 6
    --awful.layout.suit.max.fullscreen,
    awful.layout.suit.magnifier             -- 7
}



Everything is clear here.
--------------------------------------
--- Обои рабочего стола ---
--------------------------------------
-- Если в теме заданы обои
if beautiful.wallpaper then
  -- Перебираем все экраны
  for s = 1, screen.count() do
    -- На каждый экран кладем обои (можно в принципе на каждый экран свои)
    gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  end
end



Tag names can be absolutely anything - I chose the Greek letters - as on the unlogic screen. I assign my own layout to each individual tag, which we defined above.
Tags
---------------------------------------------------------
--- Тэги - виртуальные рабочие столы ---
---------------------------------------------------------
-- Список тэгов
tags = {
   -- Имена тэгов
   names  = { "  α  ", "  β  ", "  ζ  ", "  Θ  ", "  Ξ  ", "  ς  ", "  ψ  "},
   -- Макеты тэгов
   layout = { layouts[1], layouts[2], layouts[3], layouts[4], layouts[5],
              layouts[6],  layouts[7]
}}
-- Перебираем все экраны
for s = 1, screen.count() do
   -- На каждом создаем список тэгов, устанавливая макет отображения окон
   tags[s] = awful.tag(tags.names, s, tags.layout)
end



We collect the menu (I do not know why it is needed, I never used it)
------------------------------
--- Главное меню ---
------------------------------
--- Интернет-приложения
internet_menu =
{
    -- Формат описания пункта меню
    -- {<Назавание пункта меню>, <Команда запуска>, <Иконка>}
    {" Firefox", "firefox-bin", beautiful.firefox_icon},
    {" Chrome", "google-chrome-stable", beautiful.chrome_icon},
    {" Pidgin", "pidgin"}
}
--- 
editors_menu =
{
  {" Eclipse", "eclipse-bin-4.2"},
  {" Emacs", "emacs"}
}
--- 
office_menu = {
  {" Word", "libreoffice --writer"},
  {" Exel", "libreoffice --calc"}
}
main_menu = awful.menu({
  -- Таблица пунктов главного меню
  items = {
      {" Интернет", internet_menu},
      {" Редакторы", editors_menu},
      {" LibreOffice", office_menu},
      {" "},
      {" Перезагрузка", "reboot", beautiful.reboot_icon},
      {" Выключение", "halt", beautiful.poweroff_icon},
      {" Выход", awesome.quit, beautiful.logout_icon}
  }
})
------------------------------------------------------------------
--- Лаунчер - та кнопка что на панели слева --- 
------------------------------------------------------------------
launcher = awful.widget.launcher({ image = beautiful.gentoo_icon, menu = main_menu })



But I didn’t understand why.
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}



The article came out very large, so I had to break it into pieces, continued here

Also popular now: