awesome

From ParabolaWiki
Jump to: navigation, search

From the awesome website:

"awesome is a highly configurable, next generation framework window manager for X. It is very fast, extensible and licensed under the GNU GPLv2 license.

It is primarly 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."

1 Installation

Install awesome from the community respository.

2 Run awesome

2.1 Without login manager

To run awesome without a login manager, simply add exec awesome to the startup script of your choice (e.g. ~/.xinitrc.)

See xinitrc for details, such as preserving the logind session.

You can also start awesome as preferred user without even logging in. See Start X at Login.

2.2 With login manager

To start awesome from a login manager, see this article.

2.2.1 GDM, LightDM, others using /usr/share/xsessions/

Awesome automatically installs a config file for these display managers. You don't need to do anything special to see awesome offered at login.

2.2.2 KDM

Create as root:

/usr/share/apps/kdm/sessions/awesome.desktop
[Desktop Entry]
Name=Awesome
Comment=Tiling Window Manager
Type=Application
Exec=/usr/bin/awesome
TryExec=/usr/bin/awesome

3 Configuration

Awesome includes some good default settings right out of the box, but sooner or later you'll want to change something. The lua based configuration file is at ~/.config/awesome/rc.lua.

3.1 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 syntax of the configuration often changes when awesome updates. So, remember to repeat the command above when you get something strange with awesome, or you'd like to modify the configuration.

For more information about configuring awesome, check out the configuration page at awesome wiki

3.2 More configuration resources

Note: The syntax of 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:

3.3 Debugging rc.lua

3.3.1 Using Xephyr

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 config 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 apps and losing work. Once you are happy with the new configuration, copy rc.lua.new to rc.lua and restart awesome.

3.4 Changing Keyboard Layout

If it were necessary for someone to need a different keyboard layout [qwerty -> dvorak] there are methods for such listed here on the awesome wiki.

4 Themes

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 and change theme_path in rc.lua.

beautiful.init(awful.util.getdir("config") .. "/themes/default/theme.lua")

More details here

A few sample themes

4.1 Setting up your 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.

4.1.1 version <3.5 (out of date)

If you take a look at the default theme file you'll see a wallpaper_cmd key, the given command is executed when beautiful.init("path_to_theme_file") is run. You can put here you own command or remove/comment the key if you do not want Beautiful to interfere with your wallpaper business.

For instance, if you use awsetbg to set your wallpaper, you can write in the theme.lua page that you just selected:

theme.wallpaper_cmd = { "awsetbg -f .config/awesome/themes/awesome-wallpaper.png" }
Note: For awsetbg to work you need to have a program that can manage desktop backgrounds installed. For example Feh.

4.1.2 version >= 3.5

With version 3.5 Awesome no longer provides a awsetbg command, instead it has a gears module. You can set your wallpaper inside theme.lua with

theme.wallpaper = "~/.config/awesome/themes/awesome-wallpaper.png" 

To load the wallpaper, make sure your rc.lua contains

beautiful.init("~/.config/awesome/themes/default/theme.lua")
for s = 1, screen.count() do
	gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end

4.1.3 Random Background Image

add this to your rc.lua(for awesome >= 3.5 ):

-- configuration - edit to your liking
wp_index = 1
wp_timeout  = 10
wp_path = "/path/to/wallpapers/"
wp_files = { "01.jpg", "02.jpg", "03.jpg" }
 
-- setup the timer
wp_timer = timer { timeout = wp_timeout }
wp_timer:connect_signal("timeout", function()
 
  -- set wallpaper to current index for all screens
  for s = 1, screen.count() do
    gears.wallpaper.maximized(wp_path .. wp_files[wp_index], s, true)
  end
 
  -- stop the timer (we don't need multiple instances running at the same time)
  wp_timer:stop()
 
  -- get next random index
  wp_index = math.random( 1, #wp_files)
 
  --restart the timer
  wp_timer.timeout = wp_timeout
  wp_timer:start()
end)
 
-- initial start when rc.lua is first run
wp_timer:start()

to automatically fetch images from a given directory you might want instead to add this to your rc.lua(for awesome >= 3.5 ):

-- {{{ Function definitions

-- scan directory, and optionally filter outputs
function scandir(directory, filter)
    local i, t, popen = 0, {}, io.popen
    if not filter then
        filter = function(s) return true end
    end
    print(filter)
    for filename in popen('ls -a "'..directory..'"'):lines() do
        if filter(filename) then
            i = i + 1
            t[i] = filename
        end
    end
    return t
end

-- }}}

-- configuration - edit to your liking
wp_index = 1
wp_timeout  = 10
wp_path = "/path/to/wallpapers/"
wp_filter = function(s) return string.match(s,"%.png$") or string.match(s,"%.jpg$") end
wp_files = scandir(wp_path, wp_filter)
 
-- setup the timer
wp_timer = timer { timeout = wp_timeout }
wp_timer:connect_signal("timeout", function()
 
  -- set wallpaper to current index for all screens
  for s = 1, screen.count() do
    gears.wallpaper.maximized(wp_path .. wp_files[wp_index], s, true)
  end
 
  -- stop the timer (we don't need multiple instances running at the same time)
  wp_timer:stop()
 
  -- get next random index
  wp_index = math.random( 1, #wp_files)
 
  --restart the timer
  wp_timer.timeout = wp_timeout
  wp_timer:start()
end)
 
-- initial start when rc.lua is first run
wp_timer:start()

To rotate the wallpapers randomly, just comment the wallpaper_cmd line above, and add a script into your .xinitrc with the codes below(for awesome <= 3.4 ):

while true;
do
  awsetbg -r <path/to/the/directory/of/your/wallpapers>
  sleep 15m
done &

5 Tips & Tricks

Feel free to add any tips or tricks that you would like to pass on to other awesome users.

5.1 Expose effect like compiz

This article or section is out of date.
Please help improve the wiki by updating the article and correcting mistakes.

Revelation brings up a view of all your open clients; left-clicking a client pops to the first tag that client is visible on and raises/focuses the client. In addition, the Enter key pops to the currently focused client, and Escape aborts.

http://awesome.naquadah.org/wiki/Revelation

5.2 Hide / show wibox in awesome 3

To map Modkey-b to hide/show default statusbar on active screen (as default in awesome 2.3), add to your globalkeys in rc.lua:

awful.key({ modkey }, "b", function ()
    mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
end),

5.3 Enable printscreens

To enable printscreens in awesome through the PrtScr button you need to have a screen capturing program, e.g. scrot. See Taking a Screenshot for more options.

Next of we need to get the key name for PrtScr, most often this is named "Print" but one can never be too sure.

So we can run xev (found in xorg-xev) to find out:

# xev

And press the PrtScr button, the output should be something like:

 KeyPress event ....
     root 0x25c, subw 0x0, ...
     state 0x0, keycode 107 (keysym 0xff61, Print), same_screen YES,
     ....

In my case as you see, the keyname is Print.

Now to the configuration of awesome!

Somewhere in your globalkeys array (doesn't matter where) type:

Lua code:

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

Also, this function saves screenshots inside ~/screenshots/, edit this to fit your needs.

5.4 Dynamic tagging

Eminent is a small lua library that monkey-patches awful to provide you with effortless and quick wmii-style dynamic tagging. Unlike shifty, eminent does not aim to provide a comprehensive tagging system, but tries to make dynamic tagging as simple as possible. In fact, besides importing the eminent library, you do not have to change your rc.lua at all, eminent does all the work for you.

Shifty is an Awesome 3 extension that implements dynamic tagging. It also implements fine client matching configuration allowing YOU to be the master of YOUR desktop only by setting two simple config variables and some keybindings!

5.5 Naughty for popup notification

See the awesome wiki page on naughty.

5.6 Popup Menus

There's a simple menu by default in awesome3, and customed menus seem very easy now. However, if you're using 2.x awesome, have a look at awful.menu.

If you want a freedesktop.org menu, you could take a look at awesome-freedesktop .

An example for awesome3:

myawesomemenu = {
   { "lock", "xscreensaver-command -activate" },
   { "manual", terminal .. " -e man awesome" },
   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
   { "restart", awesome.restart },
   { "quit", awesome.quit }
}

mycommons = {
   { "pidgin", "pidgin" },
   { "OpenOffice", "soffice-dev" },
   { "Graphic", "gimp" }
}

mymainmenu = awful.menu.new({ items = { 
                                        { "terminal", terminal },
                                        { "icecat", "icecat" },
                                        { "Editor", "gvim" },
                                        { "File Manager", "pcmanfm" },
                                        { "VirtualBox", "VirtualBox" },
                                        { "Common App", mycommons, beautiful.awesome_icon },
                                        { "awesome", myawesomemenu, beautiful.awesome_icon }
                                       }
                             })

5.7 More Widgets in awesome

Widgets in awesome are objects that you can add to any widget-box (statusbars and titlebars), they can provide various information about your system, and are useful for having access to this information, right from your window manager. Widgets are simple to use and offer a great deal of flexibility. -- Source Awesome Wiki: Widgets.

There's a widely used widget library called Wicked (compatible with awesome versions prior to 3.4), that provides more widgets, like MPD widget, CPU usage, memory usage, etc. For more details see the Wicked page.

As a replacement for Wicked in awesome v3.4 check Vicious, Obvious and Bashets. If you pick vicious, you should also take a good look at vicious documentation.

5.8 Transparency

Awesome has support for true transparency through a compositing manager such as xcompmgr,(compton) or cairo-compmgr.

This article or section is out of date.
Please help improve the wiki by updating the article and correcting mistakes.

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

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

If you got error messages about add_signal, use connect_signal instead.

Note that if you are 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.

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

bg_normal = #000000AA

where "AA" is the transparency value.

To change transparency for the actual selected window by pressing Modkey + PageUp/PageDown you can also use tansset-df available through the community package repository and the following modification to your rc.lua:

globalkeys = awful.util.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
    [...]
)

5.8.1 ImageMagick

You may have problems if you set your wallpaper with imagemagick's display command, it doesn't work well with xcompmgr. Please note that awsetbg may be using display if it doesn't 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).

5.9 Autorun programs

See also the Autostart page on the Awesome wiki.

awesome doesn't run programs set to autostart by the Freedesktop specification like GNOME or KDE. However, awesome does provide a few functions for starting programs (in addition to the Lua standard library function os.execute).

If you just want to set up a list of apps for awesome to launch at startup, you can create a table of all the commands you want to spawn and loop through it:

do
  local cmds = 
  { 
    "swiftfox",
    "mutt",
    "consonance",
    "linux-fetion",
    "weechat-curses",
    --and so on...
  }

  for _,i in pairs(cmds) do
    awful.util.spawn(i)
  end
end

(You could also run calls to os.execute with commands ending in '&', but it's probably a better idea to stick to the proper spawn function.)

To run a program only if it is not currently running, you can spawn it with a shell command that runs the program only if pgrep doesn't find a running process with the same name:

function run_once(prg)
  awful.util.spawn_with_shell("pgrep -u $USER -x " .. prg .. " || (" .. prg .. ")")
end

So, for example, to run parcellite only if there is not a parcellite process already running:

run_once("parcellite")

5.10 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

Don't forget to add the widget to your wibox.

5.11 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. Just install xfce4-panel by issuing:

sudo pacman -S xfce4-panel

Of course any other panel will do as well. Then add it to autorun section of your rc.lua (how to do that is written elsewhere on this wiki). You can also comment out the section which creates wiboxes for each screen (starting from "mywibox[s] = awful.wibox({ position = "top", screen = s })" ) but it isn't necessary. Any way do not forget to check your rc.lua for errors by typing

awesome -k rc.lua

Also you should change your "modkey+R" keybinding, in order to start some other application launcher instead of built in awesome. Xfrun4, bashrun, etc. Don't forget to add

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

to your rc.lua.

5.12 Fix Java (GUI appears gray only)

Guide taken from [1].

  1. Install wmname from community
  2. Run the following command or add it to your .xinitrc:
    wmname LG3D
Note:

If you use a non-reparenting window manager and Java 6, you should uncomment the corresponding line in /etc/profile.d/openjdk6.sh

If you use a non-reparenting window manager and Java 7, you should uncomment the corresponding line in /etc/profile.d/jre.sh

Note:

As of Java 1.7 and Awesome 3.5 (as installed by the awesome-git package) the fixes described above may cause undesirable behaviour related to menus not receiving proper focus. Awesome is now, apparently, a reparenting window manager as of this commit.

If you are experiencing problems having applied the 'wmname' and '_JAVA_AWT_WM_NONREPARENTING' fixes against a recent Java and Awesome, try removing both fixes.

5.13 Prevent Nautilus from displaying the desktop (Gnome3)

Run dconf-editor. Navigate to org->gnome->desktop->background and uncheck "draw-background" as well as "show-desktop-icons" for good measure. That's it!

Another option is moving /usr/bin/nautilus to a new location and replacing it with a script that runs 'nautilus --no-desktop' passing any arguments it receives along.

#!/bin/sh
/usr/bin/nautilus-real --no-desktop $@

5.14 Prevent the mouse scroll wheel from changing tags

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

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

5.15 Application directories in menubar

The awesome package in [community] includes menubar (by default, pressing modkey+p will open a dmenu-like applications menu at the top of the screen). However, it only searches for .desktop files in /usr/share/applications and /usr/local/share/applications (the latter of which may not exist on most Arch users' systems). To change this, add the following line to rc.lua (ideally, under the "Menubar configuration" section):

app_folders = { "/usr/share/applications/", "~/.local/share/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 via rc.lua by removing local menubar = require("menubar") and other references to the menubar variable.

5.16 Applications menu

If you prefer to see a more traditional 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

6 Troubleshooting

6.1 Grey Java GUIs

Some Java Applications may render just grey, empty windows. This is related to nonreparenting.

A fix might be uncommenting the last line in /etc/profile.d/jre.sh or set this manually.

export _JAVA_AWT_WM_NONREPARENTING=1

other Methods could be found here: http://awesome.naquadah.org/wiki/Problems_with_Java

6.2 LibreOffice

If you encounter UI problems with libreoffice install libreoffice-gnome.

6.3 Mod4 key

The Mod4 is by default the Win key. If it's not mapped by default, for some reason, you can check the keycode of your Mod4 key with

$ xev

It should be 115 for the left one. Then add this to your ~/.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.

6.3.1 Mod4 key vs. IBM ThinkPad users

IBM ThinkPads, IBM Model M's and Chromebooks do not come equipped with a Window key (although Lenovo have changed this tradition on their ThinkPads). As of writing, the Alt key is not used in command combinations by the default rc.lua (refer to the Awesome wiki for a table of commands), which allows it be used as a replacement for the Super/Mod4/Win key. To do this, edit your rc.lua and replace:

modkey = "Mod4"

by:

modkey = "Mod1"

Note: Awesome does a have a few commands that make use of Mod4 plus a single letter. Changing Mod4 to Mod1/Alt could cause overlaps for some key combinations. The small amount of instances where this happens can be changed in the rc.lua file.

If you have a Chromebook or do not like to change the Awesome standards, you might like to remap a key. For instance the caps lock key is rather useless (for me) adding the following contents to ~/.Xmodmap

clear lock 
add mod4 = Caps_Lock

and run xmodmap ~/.Xmodmap to (re)load the file. This will change the caps lock key into the mod4 key and works nicely with the standard awesome settings. In addition, if needed, it provides the mod4 key to other X-programs as well.

Recent updates of xorg related packages break mentioned remapping the second line can be replaced by (tested on a DasKeyboard and IBM Model M and xorg-server 1.14.5-2):

keysym Caps_Lock = Super_L Caps_Lock

6.4 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.

Note: workbench.xml can be found in: <eclipse_workspace>/.metadata/.plugins/org.eclipse.ui.workbench/ and the line to edit is <window height="xx" maximized="true" width="xx" x="xx" y="xx">.

6.5 YouTube: fullscreen appears in background

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

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

With Chromium add

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

6.6 Redirecting console output to a file

Some GUI application are very verbose when launched from a terminal. As a consequence, when started from Awesome, they output everything to the TTY from where Awesome was started, which tend to get messy. To remove the garbage output, you have to redirect it. However, the awful.util.spawn function does not handle pipes and redirections very well as stated in the official FAQ.

As example, let's redirect Luakit output to a temporary file:

awful.key({ modkey, }, "w", function () awful.util.spawn_with_shell("luakit 2>>/tmp/luakit.log") end),

Also from the official FAQ, here's an easy way to redirect AwesomeWMs own output:

exec /usr/bin/awesome >> ~/.cache/awesome/stdout 2>> ~/.cache/awesome/stderr

7 External Links