๐ช Setting Up Awesome Window Manager in Alpine Linux: Simple Guide
Setting up Awesome window manager makes your desktop super efficient! โก This tutorial shows you how to configure Awesome easily. Donโt worry - itโs simpler than you think! ๐
๐ค What is Awesome Window Manager?
Awesome is like a smart organizer for your desktop windows. It automatically arranges and manages windows efficiently without wasting screen space!
Awesome helps you:
- โก Navigate between windows super fast
- ๐ฏ Use keyboard shortcuts for everything
- ๐ Automatically arrange windows in layouts
- ๐จ Customize your desktop completely
๐ฏ What You Need
Before we start, you need:
- โ Alpine Linux system running
- โ Root or sudo access
- โ Basic understanding of Linux desktop
- โ Internet connection for installing packages
๐ Step 1: Installing Awesome Window Manager
๐ง Setting Up Desktop Environment
Letโs start by installing Awesome and all necessary components. Itโs going to be awesome! ๐
What weโre doing: Installing Awesome window manager with display server and essential tools.
# Update package manager
apk update
# Install X11 display server
apk add xorg-server xf86-video-vesa xf86-input-evdev
# Install Awesome window manager
apk add awesome awesome-doc
# Install essential desktop applications
apk add xterm dmenu feh nitrogen compton
# Install fonts for better display
apk add font-dejavu font-noto font-awesome
# Install audio support
apk add alsa-utils pulseaudio pulseaudio-alsa
# Install network manager
apk add networkmanager networkmanager-wifi
# Install file manager and basic tools
apk add pcmanfm gvfs udisks2
# Check Awesome version
awesome --version
# Enable services
rc-update add dbus default
rc-update add networkmanager default
# Start services
rc-service dbus start
rc-service networkmanager start
What this does: ๐ Installs Awesome window manager with all necessary desktop components.
Expected Output:
awesome v4.3 (Too long)
* Starting D-Bus daemon... [ ok ]
* Starting NetworkManager... [ ok ]
What this means: Your Awesome desktop environment is installed! โ
๐ก Important Tips
Tip: Awesome uses keyboard shortcuts for everything - itโs super efficient! ๐ก
Warning: Learn the basic keybindings before starting, or you might get stuck! โ ๏ธ
๐ ๏ธ Step 2: Basic Awesome Configuration
๐จ Creating Initial Configuration
Now letโs configure Awesome with a user-friendly setup. This is where the magic happens! ๐
What weโre doing: Setting up Awesome configuration files and basic customization.
# Create user for desktop (if not exists)
adduser -D -s /bin/sh awesomeuser
# Switch to user context for configuration
su - awesomeuser
# Create Awesome config directory
mkdir -p ~/.config/awesome
# Copy default configuration
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/
# Create custom configuration
cat > ~/.config/awesome/rc.lua << 'EOF'
-- Awesome Window Manager Configuration
-- Simple and beginner-friendly setup
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
local wibox = require("wibox")
local beautiful = require("beautiful")
local naughty = require("naughty")
local lain = require("lain")
-- {{{ Error handling
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err) })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
-- Default modkey (Windows key)
modkey = "Mod4"
-- Table of layouts
awful.layout.layouts = {
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
}
-- }}}
-- {{{ Menu
myawesomemenu = {
{ "Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
{ "Manual", terminal .. " -e man awesome" },
{ "Edit config", editor_cmd .. " " .. awesome.conffile },
{ "Restart", awesome.restart },
{ "Quit", function() awesome.quit() end },
}
mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
{ "Terminal", terminal },
{ "File Manager", "pcmanfm" },
{ "Web Browser", "firefox" },
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menu = mymainmenu })
-- }}}
-- {{{ Wibar
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
-- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join(
awful.button({ }, 1, function(t) t:view_only() end),
awful.button({ modkey }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, function(t)
if client.focus then
client.focus:toggle_tag(t)
end
end),
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
)
local tasklist_buttons = gears.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
else
c:emit_signal(
"request::activate",
"tasklist",
{raise = true}
)
end
end),
awful.button({ }, 3, function()
awful.menu.client_list({ theme = { width = 250 } })
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
end))
awful.screen.connect_for_each_screen(function(s)
-- Wallpaper
gears.wallpaper.maximized("/usr/share/pixmaps/awesome.png", s, true)
-- Each screen has its own tag table.
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
-- Create a promptbox for each screen
s.mypromptbox = awful.widget.prompt()
-- Create an imagebox widget which will contain an icon indicating which layout we're using.
s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(gears.table.join(
awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(-1) end),
awful.button({ }, 4, function () awful.layout.inc( 1) end),
awful.button({ }, 5, function () awful.layout.inc(-1) end)))
-- Create a taglist widget
s.mytaglist = awful.widget.taglist {
screen = s,
filter = awful.widget.taglist.filter.all,
buttons = taglist_buttons
}
-- Create a tasklist widget
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = tasklist_buttons
}
-- Create the wibox
s.mywibox = awful.wibar({ position = "top", screen = s })
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
wibox.widget.systray(),
mytextclock,
s.mylayoutbox,
},
}
end)
-- }}}
-- {{{ Key bindings
globalkeys = gears.table.join(
-- Show help
awful.key({ modkey, }, "s", hotkeys_popup.show_help,
{description="show help", group="awesome"}),
-- Tag browsing
awful.key({ modkey, }, "Left", awful.tag.viewprev,
{description = "view previous", group = "tag"}),
awful.key({ modkey, }, "Right", awful.tag.viewnext,
{description = "view next", group = "tag"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}),
-- Default client focus
awful.key({ modkey, }, "j",
function ()
awful.client.focus.byidx( 1)
end,
{description = "focus next by index", group = "client"}
),
awful.key({ modkey, }, "k",
function ()
awful.client.focus.byidx(-1)
end,
{description = "focus previous by index", group = "client"}
),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
{description = "swap with next client by index", group = "client"}),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
{description = "swap with previous client by index", group = "client"}),
-- Standard program
awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
{description = "open a terminal", group = "launcher"}),
awful.key({ modkey, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}),
awful.key({ modkey, "Shift" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}),
-- Layout control
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
{description = "increase master width factor", group = "layout"}),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
{description = "decrease master width factor", group = "layout"}),
-- Prompt
awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
{description = "run prompt", group = "launcher"}),
-- Dmenu
awful.key({ modkey }, "p", function () awful.spawn("dmenu_run") end,
{description = "run dmenu", group = "launcher"}),
-- Applications
awful.key({ modkey }, "w", function () awful.spawn("firefox") end,
{description = "run web browser", group = "launcher"}),
awful.key({ modkey }, "f", function () awful.spawn("pcmanfm") end,
{description = "run file manager", group = "launcher"})
)
-- Bind all key numbers to tags.
for i = 1, 9 do
globalkeys = gears.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
tag:view_only()
end
end,
{description = "view tag #"..i, group = "tag"}),
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
awful.tag.viewtoggle(tag)
end
end,
{description = "toggle tag #" .. i, group = "tag"}),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
{description = "move focused client to tag #"..i, group = "tag"}),
-- Toggle tag on focused client.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:toggle_tag(tag)
end
end
end,
{description = "toggle focused client on tag #" .. i, group = "tag"})
)
end
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
},
-- Floating clients.
{ rule_any = {
instance = {
"DTA", -- Firefox addon DownThemAll.
"copyq", -- Includes session name in class.
"pinentry",
},
class = {
"Arandr",
"Blueman-manager",
"Gpick",
"Kruler",
"MessageWin", -- kalarm.
"Sxiv",
"Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
"Wpa_gui",
"veromix",
"xtightvncviewer"},
-- Note that the name property shown in xprop might be set slightly after creation of the client
-- and the name shown there might not match defined rules here.
name = {
"Event Tester", -- xev.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
}
}, properties = { floating = true }},
-- Add titlebars to normal clients and dialogs
{ rule_any = {type = { "normal", "dialog" }
}, properties = { titlebars_enabled = true }
},
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c)
if awesome.startup
and not c.size_hints.user_position
and not c.size_hints.program_position then
awful.placement.no_offscreen(c)
end
end)
-- Add a titlebar if titlebars_enabled is set to true in the rules.
client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar
local buttons = gears.table.join(
awful.button({ }, 1, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.resize(c)
end)
)
awful.titlebar(c) : setup {
{ -- Left
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
layout = wibox.layout.align.horizontal
}
end)
-- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
-- Autostart applications
awful.spawn.with_shell("~/.config/awesome/autostart.sh")
EOF
# Create autostart script
cat > ~/.config/awesome/autostart.sh << 'EOF'
#!/bin/sh
# Network applet
nm-applet &
# Volume control
pulseaudio &
# Compositor for transparency effects
compton &
# Set wallpaper
nitrogen --restore &
# System tray icons
blueman-applet &
# File manager daemon
/usr/lib/gvfs/gvfsd &
echo "๐ Awesome autostart completed"
EOF
chmod +x ~/.config/awesome/autostart.sh
# Create .xinitrc for starting Awesome
cat > ~/.xinitrc << 'EOF'
#!/bin/sh
# Load X resources
xrdb -merge ~/.Xresources 2>/dev/null
# Set keyboard layout
setxkbmap us
# Start Awesome window manager
exec awesome
EOF
chmod +x ~/.xinitrc
# Exit back to root
exit
echo "โ
Awesome configuration created!"
echo ""
echo "๐ To start Awesome desktop:"
echo "1. Login as awesomeuser"
echo "2. Run: startx"
echo "3. Press Mod4+Return to open terminal"
echo "4. Press Mod4+p to open application launcher"
Code explanation:
modkey = "Mod4"
: Sets the Windows key as the main modifierawful.layout.layouts
: Defines available window layoutsglobalkeys
: Sets up keyboard shortcuts for window managementawful.rules.rules
: Defines how different applications should behaveautostart.sh
: Runs essential services when Awesome starts
Expected Output:
โ
Awesome configuration created!
๐ To start Awesome desktop:
1. Login as awesomeuser
2. Run: startx
3. Press Mod4+Return to open terminal
4. Press Mod4+p to open application launcher
What this means: Your Awesome window manager is configured and ready! ๐
๐ฎ Letโs Try It!
Time for hands-on practice! This is the fun part! ๐ฏ
What weโre doing: Creating a complete desktop setup with wallpaper and essential applications.
# Switch to awesome user
su - awesomeuser
# Create wallpaper directory
mkdir -p ~/Pictures/Wallpapers
# Download a nice wallpaper
wget -O ~/Pictures/Wallpapers/mountain.jpg "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1920&h=1080&fit=crop"
# Create X resources file for better fonts
cat > ~/.Xresources << 'EOF'
! X Resources Configuration for Awesome
! Font settings
Xft.dpi: 96
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
! Terminal colors
*background: #1d1f21
*foreground: #c5c8c6
*color0: #1d1f21
*color1: #cc6666
*color2: #b5bd68
*color3: #f0c674
*color4: #81a2be
*color5: #b294bb
*color6: #8abeb7
*color7: #c5c8c6
*color8: #969896
*color9: #cc6666
*color10: #b5bd68
*color11: #f0c674
*color12: #81a2be
*color13: #b294bb
*color14: #8abeb7
*color15: #ffffff
EOF
# Create nitrogen wallpaper config
mkdir -p ~/.config/nitrogen
cat > ~/.config/nitrogen/nitrogen.cfg << 'EOF'
[geometry]
posx=310
posy=253
sizex=700
sizey=500
[nitrogen]
view=icon
recurse=true
sort=alpha
icon_caps=false
dirs=/home/awesomeuser/Pictures/Wallpapers;
EOF
cat > ~/.config/nitrogen/bg-saved.cfg << 'EOF'
[xin_-1]
file=/home/awesomeuser/Pictures/Wallpapers/mountain.jpg
mode=5
bgcolor=#000000
EOF
# Create a custom theme
mkdir -p ~/.config/awesome/themes/custom
cat > ~/.config/awesome/themes/custom/theme.lua << 'EOF'
-- Custom Awesome Theme
local theme_assets = require("beautiful.theme_assets")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
local gfs = require("gears.filesystem")
local themes_path = gfs.get_themes_dir()
local theme = {}
-- Colors
theme.bg_normal = "#1d1f21"
theme.bg_focus = "#373b41"
theme.bg_urgent = "#cc6666"
theme.bg_minimize = "#444444"
theme.bg_systray = theme.bg_normal
theme.fg_normal = "#c5c8c6"
theme.fg_focus = "#ffffff"
theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff"
-- Borders
theme.useless_gap = dpi(3)
theme.border_width = dpi(2)
theme.border_normal = "#373b41"
theme.border_focus = "#81a2be"
theme.border_marked = "#cc6666"
-- Font
theme.font = "DejaVu Sans 10"
-- Menu
theme.menu_submenu_icon = themes_path.."default/submenu.png"
theme.menu_height = dpi(15)
theme.menu_width = dpi(100)
-- Notifications
theme.notification_font = theme.font
theme.notification_bg = theme.bg_focus
theme.notification_fg = theme.fg_focus
-- Tasklist
theme.tasklist_bg_focus = theme.bg_focus
theme.tasklist_fg_focus = theme.fg_focus
-- Titlebar
theme.titlebar_bg_focus = theme.bg_focus
theme.titlebar_bg_normal = theme.bg_normal
-- Generate Awesome icon:
theme.awesome_icon = theme_assets.awesome_icon(
theme.menu_height, theme.bg_focus, theme.fg_focus
)
-- Define the icon theme for application icons
theme.icon_theme = nil
return theme
EOF
# Update Awesome config to use custom theme
sed -i 's|beautiful.init("/usr/share/awesome/themes/default/theme.lua")|beautiful.init(gears.filesystem.get_configuration_dir() .. "themes/custom/theme.lua")|' ~/.config/awesome/rc.lua
# Create desktop applications menu
mkdir -p ~/.config/awesome/widgets
cat > ~/.config/awesome/widgets/app_menu.lua << 'EOF'
-- Application Menu Widget for Awesome
local awful = require("awful")
local beautiful = require("beautiful")
local app_menu = {}
-- Create application menu
app_menu.applications = {
{ "Terminal", "xterm", "/usr/share/pixmaps/xterm.xpm" },
{ "File Manager", "pcmanfm", "/usr/share/pixmaps/pcmanfm.png" },
{ "Text Editor", "xterm -e vi", "/usr/share/pixmaps/vim.png" },
{ "Calculator", "xcalc", "/usr/share/pixmaps/xcalc.xpm" },
{ "System Monitor", "xterm -e top", "/usr/share/pixmaps/htop.png" },
}
app_menu.system = {
{ "Lock Screen", "xscreensaver-command -lock" },
{ "Logout", function() awesome.quit() end },
{ "Reboot", "sudo reboot" },
{ "Shutdown", "sudo poweroff" },
}
app_menu.main = awful.menu({
items = {
{ "Applications", app_menu.applications },
{ "System", app_menu.system },
{ "Awesome", {
{ "Restart", awesome.restart },
{ "Quit", function() awesome.quit() end }
}},
}
})
return app_menu
EOF
# Exit back to root
exit
echo "๐จ Desktop customization completed!"
echo ""
echo "๐ What's configured:"
echo " โ
Custom theme with nice colors"
echo " โ
Wallpaper support with nitrogen"
echo " โ
Better fonts and terminal colors"
echo " โ
Application menu system"
echo " โ
Autostart services"
You should see:
๐จ Desktop customization completed!
๐ What's configured:
โ
Custom theme with nice colors
โ
Wallpaper support with nitrogen
โ
Better fonts and terminal colors
โ
Application menu system
โ
Autostart services
Awesome work! ๐
๐ Quick Summary Table
Component | Purpose | Key Binding | Location |
---|---|---|---|
๐ช Awesome WM | ๐ง Window management | Mod4+s (help) | /usr/bin/awesome |
๐ฅ๏ธ Terminal | ๐ป Command line | Mod4+Return | xterm |
๐ App Launcher | ๐ฑ Run programs | Mod4+p | dmenu |
๐ File Manager | ๐ Browse files | Mod4+f | pcmanfm |
๐ Step 3: Advanced Awesome Customization
๐จ Adding Widgets and Enhancements
Letโs add some cool widgets and make Awesome even more awesome! ๐
What weโre doing: Adding system information widgets and advanced customization.
# Switch to awesome user
su - awesomeuser
# Install lain widget library
apk add awesome-lain
# Create advanced configuration with widgets
cat > ~/.config/awesome/widgets/system_info.lua << 'EOF'
-- System Information Widgets for Awesome
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local system_info = {}
-- CPU Widget
system_info.cpu = wibox.widget {
{
{
text = "CPU",
widget = wibox.widget.textbox,
},
{
id = "cpu_bar",
max_value = 100,
value = 0,
thickness = 3,
start_angle = 0,
bg = beautiful.bg_normal,
paddings = 2,
widget = wibox.container.arcchart,
},
{
id = "cpu_text",
text = "0%",
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.margin,
margins = 2,
}
-- Memory Widget
system_info.memory = wibox.widget {
{
{
text = "MEM",
widget = wibox.widget.textbox,
},
{
id = "mem_bar",
max_value = 100,
value = 0,
thickness = 3,
start_angle = 0,
bg = beautiful.bg_normal,
paddings = 2,
widget = wibox.container.arcchart,
},
{
id = "mem_text",
text = "0%",
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.margin,
margins = 2,
}
-- Network Widget
system_info.network = wibox.widget {
{
text = "NET",
widget = wibox.widget.textbox,
},
{
id = "net_text",
text = "0KB/s",
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal,
}
-- Battery Widget (if available)
system_info.battery = wibox.widget {
{
text = "BAT",
widget = wibox.widget.textbox,
},
{
id = "bat_bar",
max_value = 100,
value = 50,
thickness = 3,
start_angle = 0,
bg = beautiful.bg_normal,
paddings = 2,
widget = wibox.container.arcchart,
},
{
id = "bat_text",
text = "50%",
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal,
}
-- Update functions
local function update_cpu()
awful.spawn.easy_async("sh -c \"grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$3+$4)} END {print int(usage)}'\"", function(stdout)
local cpu_usage = tonumber(stdout) or 0
system_info.cpu:get_children()[1]:get_children()[2]:set_value(cpu_usage)
system_info.cpu:get_children()[1]:get_children()[3]:set_text(cpu_usage .. "%")
end)
end
local function update_memory()
awful.spawn.easy_async("sh -c \"free | grep Mem | awk '{printf \"%.0f\", $3/$2 * 100.0}'\"", function(stdout)
local mem_usage = tonumber(stdout) or 0
system_info.memory:get_children()[1]:get_children()[2]:set_value(mem_usage)
system_info.memory:get_children()[1]:get_children()[3]:set_text(mem_usage .. "%")
end)
end
local function update_network()
awful.spawn.easy_async("sh -c \"cat /proc/net/dev | grep eth0 | awk '{print $2}' | head -1\"", function(stdout)
local bytes = tonumber(stdout) or 0
local kb = math.floor(bytes / 1024)
system_info.network:get_children()[2]:set_text(kb .. "KB/s")
end)
end
local function update_battery()
awful.spawn.easy_async("sh -c \"cat /sys/class/power_supply/BAT*/capacity 2>/dev/null | head -1\"", function(stdout)
local battery = tonumber(stdout)
if battery then
system_info.battery:get_children()[2]:set_value(battery)
system_info.battery:get_children()[3]:set_text(battery .. "%")
end
end)
end
-- Update timers
gears.timer {
timeout = 2,
call_now = true,
autostart = true,
callback = function()
update_cpu()
update_memory()
update_network()
update_battery()
end
}
return system_info
EOF
# Create enhanced Awesome configuration with widgets
cat > ~/.config/awesome/rc.lua << 'EOF'
-- Enhanced Awesome Window Manager Configuration
-- With system information widgets
pcall(require, "luarocks.loader")
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
local wibox = require("wibox")
local beautiful = require("beautiful")
local naughty = require("naughty")
local hotkeys_popup = require("awful.hotkeys_popup")
require("awful.hotkeys_popup.keys")
-- Load custom widgets
local system_info = require("widgets.system_info")
-- Error handling
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err) })
in_error = false
end)
end
-- Variable definitions
beautiful.init(gears.filesystem.get_configuration_dir() .. "themes/custom/theme.lua")
terminal = "xterm"
editor = os.getenv("EDITOR") or "vi"
editor_cmd = terminal .. " -e " .. editor
modkey = "Mod4"
-- Layouts
awful.layout.layouts = {
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
}
-- Menu
myawesomemenu = {
{ "Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
{ "Manual", terminal .. " -e man awesome" },
{ "Edit config", editor_cmd .. " " .. awesome.conffile },
{ "Restart", awesome.restart },
{ "Quit", function() awesome.quit() end },
}
mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
{ "Terminal", terminal },
{ "File Manager", "pcmanfm" },
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menu = mymainmenu })
-- Wibar
mytextclock = wibox.widget.textclock()
local taglist_buttons = gears.table.join(
awful.button({ }, 1, function(t) t:view_only() end),
awful.button({ modkey }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ }, 3, awful.tag.viewtoggle)
)
local tasklist_buttons = gears.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
else
c:emit_signal("request::activate", "tasklist", {raise = true})
end
end),
awful.button({ }, 3, function()
awful.menu.client_list({ theme = { width = 250 } })
end)
)
awful.screen.connect_for_each_screen(function(s)
-- Wallpaper
gears.wallpaper.maximized(gears.filesystem.get_configuration_dir() .. "../Pictures/Wallpapers/mountain.jpg", s, true)
-- Tags
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
-- Widgets
s.mypromptbox = awful.widget.prompt()
s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(gears.table.join(
awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(-1) end)
))
s.mytaglist = awful.widget.taglist {
screen = s,
filter = awful.widget.taglist.filter.all,
buttons = taglist_buttons
}
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = tasklist_buttons
}
-- Wibox
s.mywibox = awful.wibar({ position = "top", screen = s })
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
s.mytasklist,
{
layout = wibox.layout.fixed.horizontal,
system_info.cpu,
system_info.memory,
system_info.network,
system_info.battery,
wibox.widget.systray(),
mytextclock,
s.mylayoutbox,
},
}
end)
-- Key bindings
globalkeys = gears.table.join(
-- Awesome
awful.key({ modkey, }, "s", hotkeys_popup.show_help,
{description="show help", group="awesome"}),
awful.key({ modkey, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}),
awful.key({ modkey, "Shift" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}),
-- Tags
awful.key({ modkey, }, "Left", awful.tag.viewprev,
{description = "view previous", group = "tag"}),
awful.key({ modkey, }, "Right", awful.tag.viewnext,
{description = "view next", group = "tag"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}),
-- Client focus
awful.key({ modkey, }, "j", function () awful.client.focus.byidx( 1) end,
{description = "focus next by index", group = "client"}),
awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) end,
{description = "focus previous by index", group = "client"}),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
{description = "swap with next client by index", group = "client"}),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
{description = "swap with previous client by index", group = "client"}),
-- Standard programs
awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
{description = "open a terminal", group = "launcher"}),
-- Layout control
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
{description = "increase master width factor", group = "layout"}),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
{description = "decrease master width factor", group = "layout"}),
-- Launchers
awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
{description = "run prompt", group = "launcher"}),
awful.key({ modkey }, "p", function () awful.spawn("dmenu_run") end,
{description = "run dmenu", group = "launcher"}),
awful.key({ modkey }, "f", function () awful.spawn("pcmanfm") end,
{description = "run file manager", group = "launcher"}),
-- Screenshots
awful.key({ }, "Print", function () awful.spawn("scrot -e 'mv $f ~/Pictures/'") end,
{description = "take screenshot", group = "screenshot"}),
awful.key({ "Shift" }, "Print", function () awful.spawn("scrot -s -e 'mv $f ~/Pictures/'") end,
{description = "take area screenshot", group = "screenshot"}),
-- Volume control
awful.key({ }, "XF86AudioRaiseVolume", function () awful.spawn("amixer sset Master 5%+") end,
{description = "increase volume", group = "audio"}),
awful.key({ }, "XF86AudioLowerVolume", function () awful.spawn("amixer sset Master 5%-") end,
{description = "decrease volume", group = "audio"}),
awful.key({ }, "XF86AudioMute", function () awful.spawn("amixer sset Master toggle") end,
{description = "toggle mute", group = "audio"})
)
-- Client keys
clientkeys = gears.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen; c:raise() end,
{description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
{description = "close", group = "client"}),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle,
{description = "toggle floating", group = "client"}),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
{description = "move to master", group = "client"}),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
{description = "move to screen", group = "client"}),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
{description = "toggle keep on top", group = "client"}),
awful.key({ modkey, }, "n", function (c) c.minimized = true end,
{description = "minimize", group = "client"}),
awful.key({ modkey, }, "m", function (c) c.maximized = not c.maximized; c:raise() end,
{description = "(un)maximize", group = "client"})
)
-- Bind all key numbers to tags
for i = 1, 9 do
globalkeys = gears.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
tag:view_only()
end
end,
{description = "view tag #"..i, group = "tag"}),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
{description = "move focused client to tag #"..i, group = "tag"})
)
end
clientbuttons = gears.table.join(
awful.button({ }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
end),
awful.button({ modkey }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ modkey }, 3, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.resize(c)
end)
)
-- Set keys
root.keys(globalkeys)
-- Rules
awful.rules.rules = {
{
rule = { },
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
},
{
rule_any = {
instance = { "pinentry" },
class = { "Arandr", "Blueman-manager", "Gpick", "Kruler", "Sxiv", "Wpa_gui" },
name = { "Event Tester" },
role = { "AlarmWindow", "ConfigManager", "pop-up" }
},
properties = { floating = true }
},
{
rule_any = { type = { "normal", "dialog" } },
properties = { titlebars_enabled = true }
},
}
-- Signals
client.connect_signal("manage", function (c)
if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_offscreen(c)
end
end)
client.connect_signal("request::titlebars", function(c)
local buttons = gears.table.join(
awful.button({ }, 1, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.resize(c)
end)
)
awful.titlebar(c) : setup {
{
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{
{
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
layout = wibox.layout.align.horizontal
}
end)
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- Autostart
awful.spawn.with_shell("~/.config/awesome/autostart.sh")
EOF
# Exit back to root
exit
echo "๐จ Advanced Awesome configuration completed!"
echo "๐ New features added:"
echo " โ
System information widgets (CPU, Memory, Network)"
echo " โ
Enhanced keyboard shortcuts"
echo " โ
Volume and screenshot controls"
echo " โ
Better window management"
echo " โ
Custom theme and colors"
What this does: Transforms Awesome into a feature-rich desktop environment! ๐
๐ฎ Practice Time!
Letโs practice what you learned! Try these simple examples:
Example 1: Awesome Keybinding Helper ๐ข
What weโre doing: Creating a cheat sheet for Awesome keyboard shortcuts.
# Create keybinding helper script
cat > /opt/awesome-keys.sh << 'EOF'
#!/bin/sh
echo "๐ช Awesome Window Manager - Key Bindings Cheat Sheet"
echo "=================================================="
echo ""
echo "๐ฏ BASIC NAVIGATION:"
echo " Mod4 + Return Open terminal"
echo " Mod4 + p Open application launcher (dmenu)"
echo " Mod4 + f Open file manager"
echo " Mod4 + s Show help/hotkeys"
echo ""
echo "๐ท๏ธ WORKSPACE MANAGEMENT:"
echo " Mod4 + 1-9 Switch to workspace 1-9"
echo " Mod4 + Shift + 1-9 Move window to workspace 1-9"
echo " Mod4 + Left/Right Previous/Next workspace"
echo ""
echo "๐ช WINDOW MANAGEMENT:"
echo " Mod4 + j/k Focus next/previous window"
echo " Mod4 + Shift + j/k Swap with next/previous window"
echo " Mod4 + h/l Resize master area"
echo " Mod4 + m Maximize window"
echo " Mod4 + f Fullscreen toggle"
echo " Mod4 + Shift + c Close window"
echo ""
echo "๐๏ธ LAYOUT CONTROL:"
echo " Mod4 + Space Next layout"
echo " Mod4 + Shift + Space Previous layout"
echo " Mod4 + Ctrl + Space Toggle floating"
echo ""
echo "๐ง SYSTEM CONTROLS:"
echo " Mod4 + Ctrl + r Restart Awesome"
echo " Mod4 + Shift + q Quit Awesome"
echo " Print Take screenshot"
echo " Shift + Print Take area screenshot"
echo ""
echo "๐ AUDIO CONTROLS:"
echo " XF86AudioRaiseVolume Volume up"
echo " XF86AudioLowerVolume Volume down"
echo " XF86AudioMute Toggle mute"
echo ""
echo "๐ก TIPS:"
echo " - Mod4 is usually the Windows key"
echo " - Right-click on desktop for menu"
echo " - Middle-click on titlebar to close window"
echo " - Awesome automatically tiles windows"
echo ""
echo "๐ For more help: Mod4 + s or 'man awesome'"
EOF
chmod +x /opt/awesome-keys.sh
echo "๐๏ธ Keybinding cheat sheet created!"
echo "Usage: /opt/awesome-keys.sh"
What this does: Creates a handy reference for all Awesome shortcuts! ๐
Example 2: Desktop Environment Switcher ๐ก
What weโre doing: Creating a script to switch between different desktop environments.
# Create desktop switcher script
cat > /opt/desktop-switcher.sh << 'EOF'
#!/bin/sh
echo "๐ฅ๏ธ Desktop Environment Switcher"
echo "==============================="
echo ""
USER_HOME="/home/awesomeuser"
echo "Available desktop environments:"
echo "1) Awesome Window Manager (tiling)"
echo "2) Basic X11 session (minimal)"
echo "3) Console only (no GUI)"
echo ""
read -p "Choose desktop environment (1-3): " choice
case $choice in
1)
echo "๐ช Setting up Awesome Window Manager..."
cat > "$USER_HOME/.xinitrc" << 'XINIT'
#!/bin/sh
xrdb -merge ~/.Xresources 2>/dev/null
setxkbmap us
exec awesome
XINIT
echo "โ
Awesome configured"
echo " Start with: startx (as awesomeuser)"
;;
2)
echo "๐ฅ๏ธ Setting up basic X11 session..."
cat > "$USER_HOME/.xinitrc" << 'XINIT'
#!/bin/sh
xrdb -merge ~/.Xresources 2>/dev/null
setxkbmap us
xterm &
exec xterm
XINIT
echo "โ
Basic X11 configured"
echo " Start with: startx (as awesomeuser)"
;;
3)
echo "๐ป Setting up console-only mode..."
echo " No .xinitrc needed for console mode"
echo "โ
Console mode ready"
echo " Login normally without startx"
;;
*)
echo "โ Invalid choice. Please run script again."
exit 1
;;
esac
echo ""
echo "๐ Desktop configuration updated!"
echo ""
echo "๐ To switch:"
echo " 1. Login as awesomeuser"
echo " 2. Run 'startx' (for GUI modes)"
echo " 3. Or just use console (for console mode)"
echo ""
echo "๐ก Tip: You can run this script anytime to switch"
EOF
chmod +x /opt/desktop-switcher.sh
echo "๐ฅ๏ธ Desktop switcher created!"
echo "Usage: /opt/desktop-switcher.sh"
What this does: Lets you easily switch between different desktop setups! ๐
๐จ Fix Common Problems
Problem 1: Awesome wonโt start โ
What happened: X11 fails to start Awesome window manager. How to fix it: Check configuration and display setup!
# Check X11 logs
tail -20 /var/log/Xorg.0.log
# Test Awesome configuration
su - awesomeuser -c "awesome -k"
# Check if user can access X11
su - awesomeuser -c "xauth list"
# Reset Awesome configuration to default
su - awesomeuser -c "cp /etc/xdg/awesome/rc.lua ~/.config/awesome/"
# Start X11 in debug mode
su - awesomeuser -c "startx -- -verbose"
Problem 2: No audio or graphics โ
What happened: Desktop starts but audio/graphics donโt work. How to fix it: Check drivers and services!
# Check audio system
rc-service pulseaudio status
alsamixer
# Check graphics drivers
lsmod | grep -i video
dmesg | grep -i drm
# Install additional drivers if needed
apk add mesa-dri-gallium
apk add alsa-plugins-pulse
# Restart services
rc-service alsa restart
Donโt worry! Desktop issues are usually configuration or driver problems that are easy to fix! ๐ช
๐ก Simple Tips
- Learn shortcuts ๐ - Awesome is all about keyboard efficiency
- Customize gradually ๐ฑ - Start simple, add features as you learn
- Backup configs ๐ค - Save working configurations before major changes
- Join community ๐ช - Awesome has great documentation and forums
โ Check Everything Works
Letโs make sure your Awesome desktop is working perfectly:
# Test Awesome configuration
su - awesomeuser -c "awesome -k" && echo "โ
Awesome config valid"
# Check X11 setup
ls -la /usr/bin/startx && echo "โ
X11 available"
# Check desktop user
id awesomeuser && echo "โ
Desktop user exists"
# Check essential applications
which dmenu && echo "โ
Application launcher available"
which pcmanfm && echo "โ
File manager available"
# Check configuration files
su - awesomeuser -c "ls -la ~/.config/awesome/rc.lua" && echo "โ
Awesome config exists"
echo "๐ช Awesome Window Manager is ready! โ
"
Good output:
โ
Awesome config valid
โ
X11 available
โ
Desktop user exists
โ
Application launcher available
โ
File manager available
โ
Awesome config exists
๐ช Awesome Window Manager is ready! โ
๐ What You Learned
Great job! Now you can:
- โ Install and configure Awesome window manager on Alpine Linux
- โ Set up a complete desktop environment with applications
- โ Customize themes, widgets, and keyboard shortcuts
- โ Manage windows efficiently with tiling layouts
๐ฏ Whatโs Next?
Now you can try:
- ๐ Learning advanced Awesome configuration and scripting
- ๐ ๏ธ Setting up development environments in Awesome
- ๐ค Exploring other window managers like i3 or bspwm
- ๐ Creating custom widgets and desktop automation!
Remember: Window managers make you super productive! Youโre building an efficient workspace! ๐
Keep practicing and youโll become a desktop power user too! ๐ซ