awesome

From ArchWiki
(Redirected from Awesome (Italiano))

From the awesome website:

awesome is a highly configurable, next generation framework window manager for Xorg. It is very fast and extensible [..]. It is primarily targeted at power users, developers and any people dealing with every day computing tasks and who want to have fine-grained control on its graphical environment.

Installation

Install the awesome package. The development version is awesome-gitAUR, which is considered unstable and may have a different configuration API.

Starting

Run awesome with xinit. To use the included xsession file, see Display manager.

With GNOME

You can set up GNOME to use awesome as the visual interface, but have GNOME work in the background. See awesome-gnomeAUR.

XFCE

See Xfce#Use a different window manager.

Configuration

The lua based configuration file is at ~/.config/awesome/rc.lua.

Creating the configuration file

First, run the following to create the directory needed in the next step:

$ mkdir -p ~/.config/awesome/

Whenever compiled, awesome will attempt to use whatever custom settings are contained in ~/.config/awesome/rc.lua. This file is not created by default, so we must copy the template file first:

$ cp /etc/xdg/awesome/rc.lua ~/.config/awesome/

The API for the configuration often changes when awesome updates. So, remember to repeat the command above when you get something strange with awesome, or you want to modify the configuration.

For more information about configuring awesome, check out the configuration section at awesome docs

Examples

Note: The API for awesome configuration changes regularly, so you will likely have to modify any file you download.

Some good examples of rc.lua would be as follows:

Extensions

Several extensions are available for awesome:

Extension Functionality Version
Bring up a view of all opened clients Awesome 3.5+
Dynamic tagging Awesome 3.5
Pop-up notifications Awesome 3.5+
Additional widgets Awesome 3.5

Autostart

To implement the XDG Autostart specification, install xorg-xrdb and dex and add the following lines to ~/.config/awesome/rc.lua:

~/.config/awesome/rc.lua
awful.spawn.with_shell(
    'if (xrdb -query | grep -q "^awesome\\.started:\\s*true$"); then exit; fi;' ..
    'xrdb -merge <<< "awesome.started:true";' ..
    'dex --environment Awesome --autostart --search-paths "${XDG_CONFIG_HOME:-$HOME/.config}/autostart:${XDG_CONFIG_DIRS:-/etc/xdg}/autostart";'
    )

Especially for daemons without tray icon, systemd user units using an autostart target are an interesting alternative as they can be configured to be kept running, that is, monitored and restarted after an unexpected halt.

Finally, one can also create autorun.sh and insert the following:

~/.config/awesome/autorun.sh
#!/bin/sh

run() {
  if ! pgrep -f "$1" ;
  then
    "$@"&
  fi
}

Then, make it executable.

To add programs to autostart, simply append run "program [some arguments]" to autorun.sh. The run function checks whether there already is an instance of program with the same arguments and only runs program if there is none. You can check your autorun.sh by running it:

$ ~/.config/awesome/autorun.sh

If everything is fine, add the following line to your rc.lua:

~/.config/awesome/rc.lua
awful.spawn.with_shell("~/.config/awesome/autorun.sh")

Changing keyboard layout

There are multiple ways to configure keyboard layers.

setxkbmap Keyboard Layout Method

The default configuration of awesome already has the layout widget activated.

To set multiple layers temporary, run

$ setxkbmap -layout "us,de"

Clicking on the widget should toggle the layout. If you want a keycombo to change the layout, you may append -option "grp:alt_shift_toggle". This for example will let you change the layout by pressing Shift+Alt. So the complete command would be:

$ setxkbmap -layout "us,de" -option "grp:alt_shift_toggle"

To setup EN and RU layouts with phonetic variant:

$ setxkbmap -model pc105 -option "grp:shifts_toggle,compose:sclk" "us,ru(phonetic_YAZHERTY)"

where

  • Compose key is set to "Scroll Lock" and language toggle is set to Left Shift + Right Shift.
  • keyboard is 105 key

If using LightDM to start session, then add the command above into .xprofile file.

rc.lua Keyboard Layout Method (from v.4)

You can use awesome itself to switch (from v.4). To change the layout by pressing Shift+Alt, add these two lines to globalkeys:

~/.config/awesome/rc.lua
-- {{{ Key bindings
globalkeys = gears.table.join(
    -- ...
    awful.key({ "Shift" }, "Alt_L", function () mykeyboardlayout.next_layout(); end),
    awful.key({ "Mod1" }, "Shift_L", function () mykeyboardlayout.next_layout(); end)
)

This requires you to set up the keyboard layouts you want to be able to switch between either by the setxkbmap command or in X configuration files.

Once you have found the appropriate command to setup your layouts, add it to #Autostart.

Xorg Method

Alternatively, see Keyboard configuration in Xorg.

Theming

Beautiful is a Lua library that allows you to theme awesome using an external file, it becomes very easy to dynamically change your whole awesome colours and wallpaper without changing your rc.lua.

The default theme is at /usr/share/awesome/themes/default. Copy it to ~/.config/awesome/themes/default (optionally copy them all) and change rc.lua:

-- beautiful.init(gears.filesystem.get_configuration_dir() .. "/themes/default/theme.lua")
local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), "default")
beautiful.init(theme_path)

If you also copied the other themes you can replace "default" with e.g. "sky", "gtk", "zenburn" etc to change themes easily and the local copy of the themes can be studied, modified and used for testing. See also [1] for additional theming options. To add a useless gap for example, add

beautiful.useless_gap = 5

At the bottom of the theming section in your rc.lua.

Wallpaper

Beautiful can handle your wallpaper, thus you do not need to set it up in your .xinitrc or .xsession files. This allows you to have a specific wallpaper for each theme.

There are two ways to specify the wallpaper:

  • in your theme.lua:
    -- absolute path
    theme.wallpaper = "/path/to/wallpaper.png"
    
    -- relative to your themes directory
    theme.wallpaper = theme_path .. "path/to/wallpaper.png"
    
  • or in rc.lua, somewhere between beautiful.init and local function set_wallpaper:
    -- absolute path
    beautiful.wallpaper = "/path/to/wallpaper.png"
    
    -- relative to the configuration directory
    beautiful.wallpaper = awful.util.get_configuration_dir() .. "path/to/wallpaper.png"
    

For a random background image, add [2] to rc.lua (v3.5+). To automatically fetch images from a given directory, use [3] instead.

Tips and tricks

Hide / show wibox

For awesome 4.0:

awful.key({ modkey }, "b",
          function ()
              myscreen = awful.screen.focused()
              myscreen.mywibox.visible = not myscreen.mywibox.visible
          end,
          {description = "toggle statusbar"}
),

To show the wibox (or perform other actions) only while the ModKey is pressed is not possible from within awesome, but there is a python script that does that: autohidewibox.

Screenshot

See Keyboard input to ensure the PrtSc button is assigned correctly. Then install a screen capturing program such as scrot

Add to the globalkeys array:

 awful.key({ }, "Print", function () awful.util.spawn("scrot -e 'mv $f ~/screenshots/ 2>/dev/null'", false) end),

This function saves screenshots inside ~/screenshots/, edit as needed.

Removing window gaps

As of awesome 3.4, it is possible to remove the small gaps between windows; in the awful.rules.rules table there is a properties section, add to it

 size_hints_honor = false

Transparency

See composite manager.

In awesome 3.5, window transparency can be set dynamically using signals. For example, rc.lua could contain the following:

client.connect_signal("focus", function(c)
                              c.border_color = beautiful.border_focus
                              c.opacity = 1
                           end)
client.connect_signal("unfocus", function(c)
                                c.border_color = beautiful.border_normal
                                c.opacity = 0.7
                             end)

Conky

This article or section is a candidate for merging with Conky.

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Awesome)

If using conky, you must set it to create its own window instead of using the desktop. To do so, edit ~/.conkyrc to contain

own_window yes
own_window_transparent yes
own_window_type desktop

Otherwise strange behavior may be observed, such as all windows becoming fully transparent. Note also that since conky will be creating a transparent window on your desktop, any actions defined in awesome's rc.lua for the desktop will not work where conky is.

wiboxes

There is built-in pseudo-transparency for wiboxes. To enable it, append 2 hexadecimal digits to the colors in your theme file (e.g. ~/.config/awesome/themes/default/theme.lua, which is usually a copy of /usr/share/awesome/themes/default/theme.lua), like shown here:

theme.bg_normal = "#000000AA"

where "AA" is the transparency value.

To change transparency for the actual selected window by pressing Modkey + PgUp/PgDown you can also use transset-dfAUR and the following modification to your rc.lua:

globalkeys = gears.table.join(
    -- your keybindings
    [...]
    awful.key({ modkey }, "Next", function (c)
        awful.util.spawn("transset-df --actual --inc 0.1")
    end),
    awful.key({ modkey }, "Prior", function (c)
        awful.util.spawn("transset-df --actual --dec 0.1")
    end),
    -- Your other key bindings
    [...]
)

Widget spacing

The default rc.lua places widgets including keyboard layout and clock in a wibox with little spacing. It is possible to add extra spacing between widgets using the spacing property:

       { -- Right widgets
       layout = wibox.layout.fixed.horizontal,
       spacing = 10,
       mykeyboardlayout,
       ...

ImageMagick

This article or section is a candidate for merging with Composite manager.

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Awesome)

You may have problems if you set your wallpaper with imagemagick's display command. It does not work well with xcompmgr. Please note that awsetbg may be using display if it does not have any other options. Installing habak, feh, hsetroot or whatever should fix the problem (grep -A 1 wpsetters /usr/bin/awsetbg to see your options).

Passing content to widgets with awesome-client

You can easily send text to an awesome widget. Just create a new widget:

mywidget = widget({ type = "textbox", name = "mywidget" })
mywidget.text = "initial text"

To update the text from an external source, use awesome-client:

echo -e 'mywidget.text = "new text"' | awesome-client

Do not forget to add the widget to your wibox.

Using a different panel with awesome

If you like awesome's lightweightness and functionality but do not like the way its default panel looks, you can install a different panel, for example xfce4-panel.

Then add it to the autorun section of your rc.lua. You may also comment out the section which creates wiboxes for each screen (starting from mywibox[s] = awful.wibox({ position = "top", screen = s })) but it is not necessary. Do not forget to check your rc.lua for errors by typing:

$ awesome -k rc.lua

You should also change your modkey+R keybinding, in order to start some other application launcher instead of built in awesome. See List of applications/Other#Application launchers for examples. Do not forget to add:

      properties = { floating = true } },
    { rule = { instance = "$yourapplicationlauncher" },

to your rc.lua.

Application directories in menubar

awesome includes menubar. By default, pressing Mod+p will open a dmenu-like applications menu at the top of the screen. This menu searches for .desktop files in $XDG_DATA_DIRS/applications/ and $XDG_DATA_HOME/applications/.

You can extend or replace these directories by modifying menubar.menu_gen.all_menu_dirs:

~/.config/awesome/rc.lua
table.insert(menubar.menu_gen.all_menu_dirs, "/path/to/custom/applications/")

Note that the .desktop files are re-read each time awesome starts, thereby slowing down the startup. If you prefer other means of launching programs, the menubar can be disabled in rc.lua by removing local menubar = require("menubar") and other references to the menubar variable.

Pop-up menus

There is a simple menu by default since awesome 3, simplifying custom menus. [4] If you want a freedesktop.org menu, you could take a look at awesome-freedesktop.

If you prefer to use an external applications menu when you click on the Awesome icon, or right-click on an empty area of the desktop, you can follow the instructions in Xdg-menu#Awesome. However this menu is not updated when you add or remove programs. So, be sure to run the command to update your menu. It may look something like:

$ xdg_menu --format awesome --root-menu /etc/xdg/menus/arch-applications.menu >~/.config/awesome/archmenu.lua

Titlebars

It is easy to enable titlebars in awesome by simply setting the variable titlebars_enabled to true in the configuration file. (in rules area)

   { rule_any = {type = { "normal", "dialog" }
     }, properties = { titlebars_enabled = true }
   },

However, you may want to be able to toggle the titlebar on or off. You can do this by simply adding something like this to your key bindings: (in clientkeys of Key bindings. And do not put the code to the end of the clientkeys area)

   -- working toggle titlebar
   awful.key({ modkey, "Control" }, "t", function (c) awful.titlebar.toggle(c)         end,
             {description = "Show/Hide Titlebars", group="client"}),

Then you may want to initially hide the titlebars. To do that just add this immediately after the title bar is created (inside the "manage" signal handler):

awful.titlebar.hide(c)

Battery notification

See this blog post for a simple battery notification to add to rc.lua. Note that it needs naughty for the notifications (installed by default in version 3.5). Other examples are available at awesome wiki.

Media Controls

It is possible to control both volume and media playback via a combination of amixer (available via the alsa-utils package) and playerctl. The following can be added to the relevant key binding section of your rc.lua configuration file:

   -- Volume Keys
   awful.key({}, "XF86AudioLowerVolume", function ()
     awful.util.spawn("amixer -q -D pulse sset Master 5%-", false) end),
   awful.key({}, "XF86AudioRaiseVolume", function ()
     awful.util.spawn("amixer -q -D pulse sset Master 5%+", false) end),
   awful.key({}, "XF86AudioMute", function ()
     awful.util.spawn("amixer -D pulse set Master 1+ toggle", false) end),
   -- Media Keys
   awful.key({}, "XF86AudioPlay", function()
     awful.util.spawn("playerctl play-pause", false) end),
   awful.key({}, "XF86AudioNext", function()
     awful.util.spawn("playerctl next", false) end),
   awful.key({}, "XF86AudioPrev", function()
     awful.util.spawn("playerctl previous", false) end),

Steam Keyboard

The on screen Steam Keyboard that can be activated by the Steam Controller appears to freeze after trying to type one character. This is because the client that is supposed to receive the input has to be focused to receive it and the keyboard will wait until this input is successfully send. Manually focusing another client will send the input to this client and unfreeze the keyboard again until the next character is entered.

The trick to getting the keyboard to work correctly is to prevent it ever receiving focus. Add the following signal to your configuration (or merge with an existing client focus signal):

client.connect_signal("focus", function(c)
    if awful.rules.match(c, { name = "^Steam Keyboard$" }) then
        awful.client.focus.history.previous()
    end
end)

This will return the focus to the last client whenever the keyboard receives focus. As the input to the keyboard is handled by the Steam client and as such does not need focus, inputting text will now work correctly.

Troubleshooting

Debugging rc.lua

Xephyr allows you to run X nested in another X's client window. This allows you to debug rc.lua without breaking your current desktop. Start by copying rc.lua into a new file (e.g. rc.lua.new), and modify it as needed. Then run new instance of awesome in Xephyr, supplying rc.lua.new as a configuration file like this:

$ Xephyr :1 -ac -br -noreset -screen 1152x720 &
$ DISPLAY=:1.0 awesome -c ~/.config/awesome/rc.lua.new

The advantage of this approach is that if you introduce bugs you do not break your current awesome desktop, potentially crashing X applications and losing work. Once you are happy with the new configuration, copy rc.lua.new to rc.lua and restart awesome.

Automatic reload

In addition to the method above, you can use inotify-tools in order to automatically reload the Awesome instance inside Xephyr when updating any configuration file inside the ~/.config/awesome directory:

#!/usr/bin/env bash

Xephyr :1 -ac -br -noreset -screen 1920x1080 -dpi 96 &
sleep 1
DISPLAY=:1.0 awesome -c ~/.config/awesome/rc.lua.new &
instance=$!

while inotifywait -r -e close_write ~/.config/awesome; do
	kill -s SIGHUP $instance
done

awmtt

awmttAUR (Awesome WM Testing Tool) is an easy to use wrapper script around Xephyr. By default, it will use ~/.config/awesome/rc.lua.test. If it cannot find that test file, it will use your actual rc.lua. You can also specify the location of the configuration file you want to test:

$ awmtt start -C ~/.config/awesome/rc.lua.new

When you are done testing, close the window with:

$ awmtt stop

Or immediately see the changes you are doing to the configuration file by issuing:

$ awmtt restart

aawmtt

aawmttAUR (Another Awesome WM Testing Tool) is an alternative implementation of awmttAUR, which includes Live-Reload by default. It is similar to awmtt-ng, but includes some fixes for the XOrg Display detection which does not work on some machines with awmtt-ng. It differs from awmtt in that it does not try to run a test file first, but just runs the default config.

To simply open a Xephyr window with awesome loaded, run:

$ aawmtt

The output of awesome will now be printed to your terminal and upon changing any files in your configuration folder, awesomewm will be reloaded.

In case you want to modify the directory that is watched for file changes, or the location of your configuration file, simply run:

$ aawmtt --config "location_of_config_file" --watch "directory_to_watch_for_changes"

The directory that is watched for changes defaults to the parent directory of your config file, so by default it would be "~/.config/awesome".

Log Files

If you are using LightDM, awesome will log errors to `$HOME/.xsession-errors`. If you use .xinitrc to start awesome, the entry "Where are logs, error messages or something?" in the FAQ may be a helpful resource.

Mod4 key

This article or section is a candidate for merging with Configuring_keyboard_layouts_in_X.

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Awesome)

Awesome recommends to remap mod4, which by default should be the Super or "Windows" key. If for some reason it is not mapped to mod4, use xmodmap to find out what is. To change the mapping, use xev to find the keycode and name of the key to be mapped. Then add something like the following to ~/.xinitrc

xmodmap -e "keycode 115 = Super_L" -e "add mod4 = Super_L"
exec awesome

The problem in this case is that some xorg installations recognize keycode 115, but incorrectly as the 'Select' key. The above command explictly remaps keycode 115 to the correct 'Super_L' key.

To remap mod4 with setxkbmap (conflict with xmodmap) see:

tail -50 /usr/share/X11/xkb/rules/evdev

To set the caps lock key as mod4 add the following to ~/.xinitrc:

setxkbmap -option caps:hyper

Fix Java (GUI appears gray only)

See Java#Gray window, applications not resizing with WM, menus immediately closing and [5].

Eclipse: cannot resize/move main window

If you get stuck and cannot move or resize the main window (using mod4 + left/right mouse button) edit the workbench.xml and set fullscreen/maximized to false (if set) and reduce the width and height to numbers smaller than your single screen desktop area.

workbench.xml can be found in eclipse_workspace/.metadata/.plugins/org.eclipse.ui.workbench/. Edit the line:

<window height="xx" maximized="true" width="xx" x="xx" y="xx"

Netbeans: code-prediction appears on wrong screen

If you have two displays and use code-prediction (Ctrl + Space) in Netbeans, the code-predictions might appear on the wrong screen. This fixed it for me:

.config/awesome/rc.lua
awful.rules.rules = {
        ...
	{
		rule_matches = { -- Fix Netbeans
			class = {
				"sun-awt-X11-XWindowPeer", "NetBeans IDE 8.2"
			},
			name = {
				"win1"
			}
		}, properties = { screen = 1 } -- even with screen 1 here, this still works on the seccond screen, too (do not know why).
	},
        ...

}

IntelliJ: menus appear on incorrect position, some windows do not open

This article or section is out of date.

Reason: This issue is closed, please retest and remove this section if it is no longer needed. (Discuss in Talk:Awesome)

See GitHub issue #2204.

This fixed it for me:

.config/awesome/rc.lua
clientbuttons_jetbrains = gears.table.join(
    awful.button({ modkey }, 1, awful.mouse.client.move),
    awful.button({ modkey }, 3, awful.mouse.client.resize)
)

...

awful.rules.rules = {
        ...
	{
            rule = {
                class = "jetbrains-.*",
            }, properties = { focus = true, buttons = clientbuttons_jetbrains }
        },
        {
            rule = {
                class = "jetbrains-.*",
                name = "win.*"
            }, properties = { titlebars_enabled = false, focusable = false, focus = true, floating = true, placement = awful.placement.restore }
        },
        ...
}

scrot: Cannot take a mouse selected screenshot with keyboard shortcuts

When using scrot, you may have problems at assigning a keyboard shortcut to the mouse selection option (formally scrot -s). To fix it, add the following line to your rc.lua:

awful.key( { modkey,	 }, <shortcut>, nil, function () awful.spawn("scrot -s") end)

Note that nil is passed to the press argument of awful.key. Instead, the callback function is passed as fourth argument, which is the argument named release.

YouTube: fullscreen appears in background

If YouTube videos appear underneath your web browser when in fullscreen mode, or underneath the panel with controls hidden, add this to rc.lua

{ rule = { instance = "plugin-container" },
  properties = { floating = true } },

With Chromium add

{ rule = { instance = "exe" },
  properties = { floating = true } },

or:

{ rule = { role = "_NET_WM_STATE_FULLSCREEN" },
  properties = { floating = true } },

See [6].

Prevent the mouse scroll wheel from changing tags

In your rc.lua, change the Mouse Bindings section to the following:

-- {{{ Mouse bindings
root.buttons(gears.table.join(
    awful.button({ }, 3, function () mymainmenu:toggle() end)
))
-- }}}

Duplicate menu-entries generated by Xdg-menu

Xdg-menu will generate duplicate entries if you copy desktop-files from /usr/share/applications to ~/.local/share/applications even though it might be preferable to simply override the originals, for example using a different theme for a specific application. One solution to the problem is to filter the generated output trough awk to remove entries with a name identical to the previous entry.

 xdg_menu --format awesome --root-menu /etc/xdg/menus/arch-applications.menu | awk -F, '{if (a!=$1) print $a; a=$1}' >~/.config/awesome/archmenu.lua

Some Shortcuts not Working in Xfce4 overlapping Keys

Check your

$ xfce4-keyboard-settings

for Overlapping keys like "Super L" or Key Combinations which should be run by Awesome

Memory leaks

Some users experience memory leaks even without activity. When using a lot of widgets leaks can occur at a rate up to 5 MB/min. To mitigate this you can enforce more frequent garbage collection by adding this to your ~/.config/awesome/rc.lua:

-- Run garbage collector regularly to prevent memory leaks
gears.timer {
       timeout = 30,
       autostart = true,
       callback = function() collectgarbage() end
}

See also