/r/awesomewm

Photograph via snooOG

Subreddit dedicated to the Awesome Window Manager (AwesomeWM)

This subreddit is dedicated to the awesome window manager framework

Post awesome news, rc.lua hacks and other awesome posts

/r/awesomewm

11,382 Subscribers

1

Struggling to center a svg inside a box

hi everyone, im just starting my journey with awesome wm, but i have stumbled across not being about to center a svg inside a box. here is what i have tried so far but there is been many attempts.

 local wibox = require("wibox")
local gears = require("gears")

local function create_svg_box()
    local svg_widget = wibox.widget {
        widget = wibox.widget.imagebox,
        image = "/home/stage3/Downloads/test.svg",
        resize = true,
    }

    svg_widget.forced_width = 15
    svg_widget.forced_height = 15

    local svg_box = wibox.widget {
        svg_widget,
        widget = wibox.container.margin,
        --margins = 8,
    }

    local corner_radius = 4

    local svg_with_bg = wibox.widget {
        svg_box,
        widget = wibox.container.background,
        bg = "#1a1c1d",
        shape = function(cr, width, height)
            gears.shape.rounded_rect(cr, width, height, corner_radius)
        end,
        forced_width = 80,
        forced_height = 25,
    }

    local svg_with_margin = wibox.widget {
        svg_with_bg,
        widget = wibox.container.margin,
        right = 10,
    }

    local centered_svg = wibox.widget {
        svg_with_margin,
        widget = wibox.container.place,
        halign = "center",
        valign = "center",
    }

    return centered_svg
end

return create_svg_box

which looks like this:

https://preview.redd.it/mkmdrrgkey3e1.png?width=179&format=png&auto=webp&s=9bdf7dea76a0f44beb30f0d3c041dde153300e45

2 Comments
2024/11/30
02:56 UTC

2

Could not get Nvidia's Gsync to work

I tried to play some games using Lutris and Steam. Nvidia's gsync couldn't be enabled( The indicator show "Normal" and not "Gsync").
My system is running Arch with awesome 4.3-4 and nvidia-565.57.
I have disabled any compositor and switched back to default configuration, but the problem still presists. But it only happens on awesome though, I tried the same on dwm and i3, and both works just fine.

Have anybody encountered the same problem and is there a fix for it?

4 Comments
2024/11/29
14:48 UTC

0

How do I change the time from 24 hours to 12 pm/am?

Not particularly fond of the 24 hour clock tbh

3 Comments
2024/11/25
01:59 UTC

0

I need a bit of help with the awesome API

I figured it out, Couldn't edit the title.
|

Am trying to automate awesome app launching in specific coordinate "a lot of time i need to launch multiple apps in specific layout", Am a noob in the api I just need 2 things tho:

Setting a Workspace to Tiling Mode via script, I managed to create a new workspace named 6 and set it to tiletop
But its actually workspace 10 lol i couldn't do that

I want to launch applications and place them exactly where I want (e.g., specific position or specific tag/workspace), I don't wanna use rules because i want to be bale to launch the application in default placement, so only when i execute the script i get that custom result,

I already managed to launch x application from an awesome-client script to open in workspace 6 but i want to know how i can specify what order it is in like workspace 6 last window or first window does that make sense ?

Please correct me if am wrong about rules and appreciate your help guys.

10 Comments
2024/11/24
09:36 UTC

0

Unique keyboard layout per client

I've made this fully working code that imitates 'Share the same input method among all applications = disabled' behaviour of IBus. I.e. on unfocus of the client my keyboard layout is being remembered and when I focus back to that client, that keyboard layout is restored:

 client.connect_signal("unfocus", function(c)
	awful.spawn.easy_async_with_shell("xkb-switch", function(stdout)
		if c.valid then -- To avoid 'Invalid Object' error
			c.keyboard_layout = stdout
		end
	end)
end)

client.connect_signal("focus", function(c)
	if c.keyboard_layout == nil then
		c.keyboard_layout = "us(altgr-intl)"
	end
	awful.spawn.easy_async_with_shell("xkb-switch -s "..c.keyboard_layout, function(stdout)
		awful.spawn("xkb-switch -s "..c.keyboard_layout, false) -- `false` to prevent cursor being stuck in 'loading' state
	end)
end)

In the focus part, my only concern is the awful.spawn.easy_async_with_shell workaround, that part really does nothing, the stdout argument is empty and only the inner awful.spawn does the layout changing. BUT, if I have only awful.spawn then the layout is being changed incorrectly. Is there some race hazard?

Here is showcase of this weird behavour. The notification popup is showing the intended language, but for some reason the switched language is wrong *(if I don't have the outer awful.spawn.easy_async_with_shell: https://youtu.be/juarLneLBAo

0 Comments
2024/11/23
07:54 UTC

2

Keybinding for new slave client

Is it possible to have a keybinding to spawn a new client as slave? More like a hybrid WM. For example 'super + alt + enter' to spawn new terminal client as slave whereas 'super + enter' spawns as master.
Or is that actually the whole point between hybrid and dynamic WM? It just would make no sense to me tho why you would have to have to different product catagories if the use of this keybinding is the only difference.

3 Comments
2024/11/20
17:35 UTC

0

Start Calendar on Saturday

I'm using awesome wm and lcpz/awesome-copycats for my theming. I use powerarrow-dark with, of course, some modification. There is a calendar widget which displays a calendar, but the week starts with a Monday. I'd like my week to start on Saturday. How might I do this?

3 Comments
2024/11/16
18:51 UTC

7

Setting up AwesomeWM with basics from a distro

Hey peeps! Happy Friyay!

I'm looking to set up AwesomeWM with my own config. I've got to a point where it's working and I'm happy with the basics. I need to sort a few other things out, but I would like to set it up on a distro that is bare - as in, no window manager installed. Would like to keep it like, and for shits and giggles, I'd like to creat my own "flavour" of a distro for personal educational purposes.

I was looking at Debian, in a similar way to BunsonLabs, but with AwesomeWM - obvs.

Has anyone done that before, should I start with Debian server version and add on to it, should I sacrifice a goat first, and, do I need a sanity test - these are the first questions I can think of...

My aim is to just install my "distro", pull in my dot files and go... Thoughts/advice is very much welcome.

Cheers

5 Comments
2024/11/15
11:57 UTC

2

no awful.autofocus

lua: rc.lua:2: module 'awful.autofocus' not found:No LuaRocks module found for awful.autofocus

`no field package.preload['awful.autofocus']`

`no file '/usr/local/share/lua/5.3/awful/autofocus.lua'`

`no file '/usr/local/share/lua/5.3/awful/autofocus/init.lua'`

`no file '/usr/local/lib/lua/5.3/awful/autofocus.lua'`

`no file '/usr/local/lib/lua/5.3/awful/autofocus/init.lua'`

`no file '/usr/share/lua/5.3/awful/autofocus.lua'`

`no file '/usr/share/lua/5.3/awful/autofocus/init.lua'`

`no file './awful/autofocus.lua'`

`no file './awful/autofocus/init.lua'`

`no file '/home/an-develpment/.luarocks/share/lua/5.3/awful/autofocus.lua'`

`no file '/home/an-develpment/.luarocks/share/lua/5.3/awful/autofocus/init.lua'`

`no file '/usr/local/lib/lua/5.3/awful/autofocus.so'`

`no file '/usr/lib/x86_64-linux-gnu/lua/5.3/awful/autofocus.so'`

`no file '/usr/lib/lua/5.3/awful/autofocus.so'`

`no file '/usr/local/lib/lua/5.3/loadall.so'`

`no file './awful/autofocus.so'`

`no file '/home/an-develpment/.luarocks/lib/lua/5.3/awful/autofocus.so'`

`no file '/usr/local/lib/lua/5.3/awful.so'`

`no file '/usr/lib/x86_64-linux-gnu/lua/5.3/awful.so'`

`no file '/usr/lib/lua/5.3/awful.so'`

`no file '/usr/local/lib/lua/5.3/loadall.so'`

`no file './awful.so'`

`no file '/home/an-develpment/.luarocks/lib/lua/5.3/awful.so'`
2 Comments
2024/11/15
00:26 UTC

1

How can I edit the order and arrangement of the items in the debian.Menu ?

... Have tried the KDE Menu Editor and that doesn't seem to work. Thanks.

3 Comments
2024/11/10
04:12 UTC

3

Is there any way to focus on a screen by index from cli?

I'm running a script in python that checks where im looking at, (left, middle or right) also the position of my 3 monitors, is there any way to make it change the focus to a different screen once the program determines where im looking at?

2 Comments
2024/11/10
01:24 UTC

0

Question: Systray Items; How to reopen a running, but hidden application?

I have an issue where many applications should show a systray icon once run, but they don't. This includes thunderbird, teamspeak3 and more.

A systray exists in my config, but the only 2 things I have seen showing up where steam and ksnip.

So, I have several questions:

  1. Why do some applications not show up?

  2. How to make them show up?

  3. How to work around? How can I for example open an already running application without having a systray icon? Usually, if an icon exists, I can just click it, but how to do this otherwise? Open thunderbird when all clients are closed, yet reopening the still running process in the background (and there is a background process, I checked)?

1 Comment
2024/11/07
14:31 UTC

2

Awesome tag switching takes significant amount of time

I have had this issue for while where over time switching between tags takes longer and longer over time, in alot of cases, reloading awesome immediately fixes this issue, but its often too late and just doing anything at all with awesome takes upwards of 15 minutes.

This issue is fully independent of resource usage, i could have everything maxed out and switching would still work fine, or i could have close to nothing open and it still takes really REALLY long to switch.

This has only seemed to happen recently, or more specifically, after i decided to fix alot of issues in my setup, which included alot of things in my awesome config.

10 Comments
2024/11/07
06:47 UTC

5

Trying to add seconds to my clock...

Solved: Solution at bottom and in messages

So, someone posted this in another subreddit but never got their answer. Basically, I'm wanting to add seconds to my clock.

Looking at my theme.lua in the textclock section, there is nothing there for seconds display. Here is that section of code.

local markup = lain.util.markup

-- Textclock
os.setlocale(os.getenv("LANG")) -- to localize the clock
local clockicon = wibox.widget.imagebox(theme.widget_clock)
local mytextclock = wibox.widget.textclock(markup("#7788af", "%A %d %B %r %S ") .. markup("#535f7a", ">") .. markup("#de5e1e", " %H:%M:%S "))
mytextclock.font = theme.font

-- Calendar
--local cal = wibox.widget.calendar.month(
--    os.date('*t'), 'sans 8')
theme.cal = lain.widget.cal({
  attach_to = { mytextclock },
--local cal = wibox.widget.calendar.month(os.date('*t'))
    notification_preset = {
        font = "Noto Sans Mono Medium 12",
        fg   = theme.fg_normal,
        bg   = theme.bg_normal
    }
})

I added Calendar section just so you can see everything I have in my textclock section.

So, I've added the :%S there after %H:%M and it does display the seconds. Like if I login at 3:05:27, it will display 03:05:27 but that's it. When it changes to 03:06 it will display 3:06:00 until the next minute rolls around 60 seconds later. Then it will show 03:07:00 and so on.

So I'm looking here and I see I need to somehow add refresh in there somewhere. But I can't for the life of me figure out where to put that. My guess is refresh needs to be set to 01 so the seconds will change every second but where and how do I tell it to do that?

Any help would be appreciated.

Also, I'm using a theming system which, I'm not sure where I got it anymore. But I like the look of it. So, it's not the original theme.lua that comes with AwesomeWM.

Solution: Add a comma then a 1 after " %H:%M:%S ") so that whole line will look like this:

local mytextclock = wibox.widget.textclock(markup("#7788af", "%A %d %B %r %S ") .. markup("#535f7a", ">") .. markup("#de5e1e", " %H:%M:%S "), 1)
13 Comments
2024/11/03
15:42 UTC

1

How to switch between keyboard layouts with a keyboard shortcut in Awesome WM?

Context

I can't switch between keyboard layouts with Alt+CapsLock with Awesome WM (v4.3) on Debian 12.

I would like to use a French layout and the Programmer Dvorak layout (dvp).

I succeed to use these two layouts with the keyboard_layout extension by adding the following lines into my awesome config file rc.lua:

-- Keyboard map indicator and switcher
local keyboard_layout = require("keyboard_layout")

-- {{{ Wibar
-- Create a textclock widget
mytextclock = wibox.widget.textclock()

-- Create keyboard layout text label
local kbdcfg = keyboard_layout.kbdcfg({type = "tui"})
kbdcfg.add_primary_layout("Français", "FR", "fr")
kbdcfg.add_primary_layout("English", "US", "dvp")
kbdcfg.bind()


-- Mouse bindings keyboard layout 
kbdcfg.widget:buttons(
 awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch_next() end),
                       awful.button({ }, 3, function () kbdcfg.menu:toggle() end))
)

-- Switching keyboard layout shortcut
globalkeys = awful.util.table.join(globalkeys,
    -- CapsLock-Alt to change keyboard layout (from https://github.com/echuraev/keyboard_layout/issues/7#issuecomment-442742606)
    awful.key({"Caps_Lock"}, "Alt_L", function () kbdcfg.switch_next() end),
    -- Alt-CapsLock to change keyboard layout
    awful.key({"Mod1"}, "Caps_Lock", function () kbdcfg.switch_next() end) 
)

I am able to switch between layouts by clicking on the FR or US icon on the top right corner.

However, the keyboard shortcut Alt+CapsLock for switching between layouts does noting.

Question

How to set up a keyboard shortcut Alt+CapsLock for switching between layouts?

I managed to set up the layouts with the keyboard_layout extension but I'm completely open to solutions without this extension.

Attempts

  • I've tried with other layouts than dvp.
  • I've tried with other shortcut: CapsLock alone and Alt+*
  • I've tried to set "XkbOptions" "grp:alt_caps_toggle" (removing caps:none) in my X11 config file (i.e. /etc/X11/xorg.conf.d), see "Additional materials" section below.

None of this attempts permits to switch between layouts with a keyboard shortcut.

Additional materials

  • Content of my X11 config file (i.e. /etc/X11/xorg.conf.d) but it seems that it is completely ignored by Awesome:
Section "InputClass"
    Identifier "system-keyboard"
    MatchIsKeyboard "on"
    Option "XkbLayout" "fr,us"
    Option "XkbModel" "pc105"
    Option "XkbVariant" ",dvp"
    Option "XkbOptions" "grp:alt_caps_toggle,caps:none"
EndSection
wget http://www.kaufmann.no/downloads/linux/kbddvp-1_2_1-src-linux.tgz
DVP_DIR=$(mktemp -t -d kbddvp.XXXXXX)
cat kbddvp-1_2_1-src-linux.tgz | gzip -d | tar xf - -C $DVP_DIR
pushd $DVP_DIR/kbddvp-1.2
chmod +x dvp.install.sh 
chmod +x dvp.postinst.sh 
sudo ./dvp.install.sh && sudo ./dvp.postinst.sh
  • Here is my entire rc.lua config file of Awesome WM:
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")

-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local menubar = require("menubar")
local hotkeys_popup = require("awful.hotkeys_popup")
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")

local tyrannical = require("tyrannical")

-- Load Debian menu entries
local debian = require("debian.menu")
local has_fdo, freedesktop = pcall(require, "freedesktop")

-- {{{ 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 = tostring(err) })
        in_error = false
    end)
end
-- }}}

-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
beautiful.init(gears.filesystem.get_configuration_dir() .. "theme.lua")

-- This is used later as the default terminal and editor to run.
terminal = "x-terminal-emulator"
editor = os.getenv("EDITOR") or "editor"
editor_cmd = terminal .. " -e " .. editor

-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"

-- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = {
    awful.layout.suit.tile,
    awful.layout.suit.floating,
    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.spiral.dwindle,
    awful.layout.suit.max,
    --awful.layout.suit.max.fullscreen,
    awful.layout.suit.magnifier,
    --awful.layout.suit.corner.nw,
    -- awful.layout.suit.corner.ne,
    -- awful.layout.suit.corner.sw,
    -- awful.layout.suit.corner.se,
}
-- }}}


-- {{{ Menu
-- Create a launcher widget and a main 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 },
}

local menu_awesome = { "awesome", myawesomemenu, beautiful.awesome_icon }
local menu_terminal = { "open terminal", terminal }

if has_fdo then
    mymainmenu = freedesktop.menu.build({
        before = { menu_awesome },
        after =  { menu_terminal }
    })
else
    mymainmenu = awful.menu({
        items = {
                  menu_awesome,
                  { "Debian", debian.menu.Debian_menu.Debian },
                  menu_terminal,
                }
    })
end


mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
                                     menu = mymainmenu })

-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}

-- Keyboard map indicator and switcher
local keyboard_layout = require("keyboard_layout")

-- {{{ Wibar
-- Create a textclock widget
mytextclock = wibox.widget.textclock()

-- Create keyboard layout text label
local kbdcfg = keyboard_layout.kbdcfg({type = "tui"})
kbdcfg.add_primary_layout("Français", "FR", "fr")
kbdcfg.add_primary_layout("English", "US", "dvp")
kbdcfg.bind()


-- Mouse bindings keyboard layout 
kbdcfg.widget:buttons(
 awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch_next() end),
                       awful.button({ }, 3, function () kbdcfg.menu:toggle() end))
)

-- Switching keyboard layout shortcut
globalkeys = awful.util.table.join(globalkeys,
    -- CapsLock-Alt to change keyboard layout (from https://github.com/echuraev/keyboard_layout/issues/7#issuecomment-442742606)
    awful.key({"Caps_Lock"}, "Alt_L", function () kbdcfg.switch_next() end),
    -- Alt-CapsLock to change keyboard layout
    awful.key({"Mod1"}, "Caps_Lock", function () kbdcfg.switch_next() end) 
)

-- 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))

local function set_wallpaper(s)
    -- Wallpaper
    if beautiful.wallpaper then
        local wallpaper = beautiful.wallpaper
        -- If wallpaper is a function, call it with the screen
        if type(wallpaper) == "function" then
            wallpaper = wallpaper(s)
        end
        gears.wallpaper.set("#400000")
        -- gears.wallpaper.maximized(wallpaper, s, true)
    end
end

-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper)

awful.screen.connect_for_each_screen(function(s)
    -- Wallpaper
    set_wallpaper(s)

    -- Each screen has its own tag table.


    -- 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.
    -- We need one layoutbox per screen.
    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,
            kbdcfg.widget,
            wibox.widget.systray(),
            mytextclock,
            s.mylayoutbox,
        },
    }
end)
-- }}}


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

-- {{{ Key bindings
globalkeys = gears.table.join(
    awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
              {description="show help", group="awesome"}),
    awful.key({ modkey,           }, ",",   awful.tag.viewprev,
              {description = "view previous", group = "tag"}),
    awful.key({ modkey,           }, ";",  awful.tag.viewnext,
              {description = "view next", group = "tag"}),
    awful.key({ modkey,           }, "Escape", awful.tag.history.restore,
              {description = "go back", group = "tag"}),

    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"}
    ),
    awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
              {description = "show main menu", group = "awesome"}),

    -- 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"}),
    awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
              {description = "focus the next screen", group = "screen"}),
    awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
              {description = "focus the previous screen", group = "screen"}),
    awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
              {description = "jump to urgent client", group = "client"}),
    awful.key({ modkey,           }, "Tab",
        function ()
            awful.client.focus.history.previous()
            if client.focus then
                client.focus:raise()
            end
        end,
        {description = "go back", 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"}),

    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"}),
    awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1, nil, true) end,
              {description = "increase the number of master clients", group = "layout"}),
    awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1, nil, true) end,
              {description = "decrease the number of master clients", group = "layout"}),
    awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1, nil, true)    end,
              {description = "increase the number of columns", group = "layout"}),
    awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1, nil, true)    end,
              {description = "decrease the number of columns", group = "layout"}),
    awful.key({ modkey,           }, "space", function () awful.layout.inc( 1)                end,
              {description = "select next", group = "layout"}),
    awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
              {description = "select previous", group = "layout"}),

    awful.key({ modkey, "Control" }, "n",
              function ()
                  local c = awful.client.restore()
                  -- Focus restored client
                  if c then
                    c:emit_signal(
                        "request::activate", "key.unminimize", {raise = true}
                    )
                  end
              end,
              {description = "restore minimized", group = "client"}),

    -- Dmenu
    awful.key({ modkey },            "r",     function () 
              awful.util.spawn("dmenu_run") end,
              {description = "run dmenu", group = "launcher"}),
              
    -- Firefox
    awful.key({ modkey },            "b",     function () 
              awful.util.spawn("firefox") end,
              {description = "firefox", group = "applications"}),

    awful.key({ modkey }, "x",
              function ()
                  awful.prompt.run {
                    prompt       = "Run Lua code: ",
                    textbox      = awful.screen.focused().mypromptbox.widget,
                    exe_callback = awful.util.eval,
                    history_path = awful.util.get_cache_dir() .. "/history_eval"
                  }
              end,
              {description = "lua execute prompt", group = "awesome"}),
    -- Menubar
    awful.key({ modkey }, "p", function() menubar.show() end,
              {description = "show the menubar", group = "launcher"})
)

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,  }, "q",      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)
            -- The client currently has the input focus, so it cannot be
            -- minimized, since minimized clients can't have the focus.
            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"}),
    awful.key({ modkey, "Control" }, "m",
        function (c)
            c.maximized_vertical = not c.maximized_vertical
            c:raise()
        end ,
        {description = "(un)maximize vertically", group = "client"}),
    awful.key({ modkey, "Shift"   }, "m",
        function (c)
            c.maximized_horizontal = not c.maximized_horizontal
            c:raise()
        end ,
        {description = "(un)maximize horizontally", group = "client"})
)

-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
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

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
-- Rules to apply to new clients (through the "manage" signal).
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 }
    },

    -- Set Firefox to always map on the tag named "2" on screen 1.
    -- { rule = { class = "Firefox" },
    --   properties = { screen = 1, tag = "2" } },
}
-- }}}

-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c)
    -- Set the windows at the slave,
    -- i.e. put it at the end of others instead of setting it master.
    -- if not awesome.startup then awful.client.setslave(c) end

    if awesome.startup
      and not c.size_hints.user_position
      and not c.size_hints.program_position then
        -- Prevent clients from being unreachable after screen count changes.
        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)
-- }}}


-- Windows border gaps
beautiful.useless_gap = 5

-- autostart apps
awful.util.spawn("firefox")


-- Collision plugin
require("collision")()
  • I am using a Typmatrix 2030 keyboard.

FYI: Question originally asked on Codidact

17 Comments
2024/10/26
13:38 UTC

3

Focus client on tasklist hover

Is it possible to focus client when i hover over its name in tasklist widget?

Tried "mouse::enter" but cant get client name under cursor, only tasklist object...

1 Comment
2024/10/23
23:38 UTC

2

How to make tasklist width to get all available space?

How can i make my tasklist not to cut off client names when it have free enough space to render them full?

My current widget code:

    }    s.mytasklist = awful.widget.tasklist {
        screen   = s,
        filter   = awful.widget.tasklist.filter.currenttags,
        buttons  = awful.util.tasklist_buttons,
        layout   = {
            spacing = 30,
            layout  = wibox.layout.flex.horizontal
        },
    }

I tried to use "wibox.layout.fixed.horizontal", it works, but than i have problem with tags don't fit in my task list (when they have long names). And in these cases some tags are not visible in tasklist at all...

https://preview.redd.it/bhcjue8x4lwd1.jpg?width=1920&format=pjpg&auto=webp&s=25594750e43e8bea71b12379b57a1b617b6dfcfa

1 Comment
2024/10/23
22:47 UTC

3

Cool things to use ctrl+x/run lua code for ?

Hi,

I have been using awesome for more than a decade and a half and only recently found out about super+p.

Which led me to super+x. I never used it for anything. What kind of cool things are people using it for ?

1 Comment
2024/10/20
19:08 UTC

1

Weird bug: sometimes super+shift+2 (also +5 sometimes) just doesn't work.

Hi,

I have had this bug for years now. From time to time it's impossible to move window to tag number 2 (sometimes 5) by using super+shift+2. I check with xev that key 2 is working, other tags work but tag number 2 is stubborn.

Any idea what could cause that ? There isn't anything specific about that tag in my config, no auto tag, just standard 1,2,3.

3 Comments
2024/10/20
19:06 UTC

2

Question about modifying configs (and text editors)

I've started using awesomewm for almost a year now, and i have yet to find a fix for this (or i just suck a googling) so i guess ill just make a post myself

When editing awesomewm configs, rc.lua and such, how do i get not shit support (with vscode, that is)

it constantly gets mad cause theres non-defined globals, and get autocomplete is completely out of the question

I know that there *has* to be a way to get this to work, i just cant figure out out

1 Comment
2024/10/20
07:36 UTC

1

Client spawns on wrong tag

I have setup in rc.lua to spawn firefox client on screen 3 and tag 1, and when i create new clients they spawn properly. But when client spawns on awesome restart (tried with console script and with awful.spawn.once) it spawns on tag where i placed it last time.

For example: i spawn firefox - it spawns on tag 1, than i move it to tag 3 and close.
Than restart awesome and it spawns at tag 3 (or maybe it spawns on tag 1 and immediatly moves to tag 3)

Is it normal or bug?

{ 
   rule_any = { class = {"Firefox", "firefox-esr"} },
   properties = { screen = 3, tag = "1" } 
}, 

awful.spawn.once("firefox-esr", {
    screen = 3, tag = "1"
})
2 Comments
2024/10/19
23:33 UTC

2

Is there a way to keep my tag setup when switching screens?

Part of my odyssey to convert my desktop workflow to the laptop :)

I would like to use awesome with two different setups:

  • When my laptop is docked (90+% of the time), I exclusively use the external monitor. The laptop monitor is turned off, the lid is closed.
  • When I unplug, I will obviously use the laptop screen.

Now, I've managed to get that working with a simple script that parses xrandr and runs one of two possible xrandr incantations. I'm fine doing this manually as I only need it every few days, no big deal.

The issue is that switching monitors like this moves all of my windows to tag 1 of the new monitor, which forces me to redo whatever setup I had. Is there any way to avoid this? I'd like the new screen to have the same tag-client association as before.

Thanks in advance!

2 Comments
2024/10/17
14:17 UTC

2

Tried compiling and running picom-jonaburg on fedora, and Kitty broke / got corrupted.

How kitty appears now

I'm running AwesomeWM on Fedora, and i added this to my rc.lua to get picom to run on startup, but when i opened Kitty, it showed some weird symbol along with the battery level? I have no idea what the error is, any ideas on how to fix this?

local handle = io.popen("pgrep -f " .. cmd)
    local result = handle:read("*a")
    handle:close()
    if result == "" then
        awful.spawn.with_shell("picom --experimental-backend --config ~/.config/picom/picom.conf")
endlocal

2 Comments
2024/10/16
08:01 UTC

2

Titlebars not working the way I think they should

I am not sure if I am misunderstanding how titlebars should be working or not.

I am using a default rc.lua file. with version 4.3

awesome v4.3 (Too long)
 • Compiled against Lua 5.3.6 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2

In my config file I have tried setting up a rule for my wezterm to have a titlebar:

awful.rules.rules = {    { rule = { },
      properties = { border_width = beautiful.border_width,
                     border_color = beautiful.border_normal,
                     focus = awful.client.focus.filter,
                     keys = clientkeys,
                     buttons = clientbuttons } },
    { rule = { class = "MPlayer" },
      properties = { floating = true } },
    { rule = { class = "pinentry" },
      properties = { floating = true } },
    { rule = { class = "gimp" },
      properties = { floating = true } },
    { rule = { class = "org.wezfurlong.wezterm" },
      properties = { floating = true, titlebars_enabled = true, } },
}

later in the file i have set local titlebars_enabled = false

When I restart awesome and load wezterm, there are no titlebars. Is this not how this is supposed to work ? I have tried other applications there also like kitty, firefox, etc with the same results. Is there something I am missing ?

4 Comments
2024/10/14
17:30 UTC

2

Prompt with tab autocomplete

Currently working on creating a prompt widget that has tab autocompletion: when the "tab" key is pressed, the text should update with the first command that matches the substring. Although, I'm stuck with getting the prompt textbox to actually display the new text. Currently, I have this:

-- Make a console the user can type commands into. 
local function command_prompt() 
    awful.prompt.run {
        prompt = "<b>$ </b>", 
        text = "", 
        bg_cursor = "#000000", 
        textbox = mouse.screen.mypromptbox.widget, 
        exe_callback = function(input) 
            if not input or #input == 0 then return end 
            command = "bash -c '" .. input .. "'" 
            awful.spawn.easy_async(command, function() end) 
        end, 
        keypressed_callback = function(mod, key, command) 
            if key == 'Tab' then
                -- Get the list of files in /usr/bin
                for dir in io.popen([[ls -pa /usr/bin | grep -v /]]):lines() do 
                    if string.sub(dir, 1, string.len(command)) == command then 
                        mouse.screen.mypromptbox.widget.text = dir
                        break 
                    end
                end 
            end
        end
    }
end 

Basically, exe_callback runs the command with bash, and keypressed_callback attempts to replace the incomplete text with a full command if a command in /usr/bin begins with the incomplete text. The problem is that setting the prompt widget text to the new text (mouse.screen.mypromptbox.widget.text = dir) does not persist outside of the function. In other words, widget.text is getting re-set somewhere outside of the function.

Is there another way of auto-completing the prompt with the tab key? Thanks for the help! :+)

1 Comment
2024/10/13
15:40 UTC

Back To Top