rc.lua (25483B) - Raw
1 -- If LuaRocks is installed, make sure that packages installed through it are 2 -- found (e.g. lgi). If LuaRocks is not installed, do nothing. 3 pcall(require, "luarocks.loader") 4 5 -- Standard awesome library 6 local gears = require("gears") 7 local awful = require("awful") 8 require("awful.autofocus") 9 -- Widget and layout library 10 local wibox = require("wibox") 11 -- Theme handling library 12 local beautiful = require("beautiful") 13 -- Notification library 14 local naughty = require("naughty") 15 local menubar = require("menubar") 16 local hotkeys_popup = require("awful.hotkeys_popup") 17 -- Enable hotkeys help widget for VIM and other apps 18 -- when client with a matching name is opened: 19 require("awful.hotkeys_popup.keys") 20 21 -- {{{ Error handling 22 -- Check if awesome encountered an error during startup and fell back to 23 -- another config (This code will only ever execute for the fallback config) 24 if awesome.startup_errors then 25 naughty.notify({ preset = naughty.config.presets.critical, 26 title = "Oops, there were errors during startup!", 27 text = awesome.startup_errors }) 28 end 29 30 -- Handle runtime errors after startup 31 do 32 local in_error = false 33 awesome.connect_signal("debug::error", function (err) 34 -- Make sure we don't go into an endless error loop 35 if in_error then return end 36 in_error = true 37 38 naughty.notify({ preset = naughty.config.presets.critical, 39 title = "Oops, an error happened!", 40 text = tostring(err) }) 41 in_error = false 42 end) 43 end 44 -- }}} 45 46 -- {{{ Variable definitions 47 -- Themes define colours, icons, font and wallpapers. 48 mytheme = dofile(gears.filesystem.get_themes_dir() .. "default/theme.lua") 49 mytheme.wallpaper = gears.wallpaper.set("#008080") 50 beautiful.init(mytheme) 51 52 -- This is used later as the default terminal and editor to run. 53 --terminal = "xfce4-terminal" 54 terminal = "ghostty" 55 editor = os.getenv("EDITOR") or "editor" 56 editor_cmd = terminal .. " -e " .. editor 57 58 -- Default modkey. 59 -- Usually, Mod4 is the key with a logo between Control and Alt. 60 -- If you do not like this or do not have such a key, 61 -- I suggest you to remap Mod4 to another key using xmodmap or other tools. 62 -- However, you can use another modifier like Mod1, but it may interact with others. 63 modkey = "Mod4" 64 65 -- Table of layouts to cover with awful.layout.inc, order matters. 66 awful.layout.layouts = { 67 --awful.layout.suit.floating, 68 awful.layout.suit.tile, 69 awful.layout.suit.tile.left, 70 awful.layout.suit.tile.bottom, 71 --awful.layout.suit.tile.top, 72 --awful.layout.suit.fair, 73 --awful.layout.suit.fair.horizontal, 74 --awful.layout.suit.spiral, 75 --awful.layout.suit.spiral.dwindle, 76 --awful.layout.suit.max, 77 --awful.layout.suit.max.fullscreen, 78 --awful.layout.suit.magnifier, 79 awful.layout.suit.corner.nw 80 -- awful.layout.suit.corner.ne, 81 -- awful.layout.suit.corner.sw, 82 -- awful.layout.suit.corner.se, 83 } 84 -- }}} 85 86 -- {{{ Menu 87 -- Create a launcher widget and a main menu 88 myawesomemenu = { 89 { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, 90 { "manual", terminal .. " -e man awesome" }, 91 { "edit config", editor_cmd .. " " .. awesome.conffile }, 92 { "restart", awesome.restart }, 93 { "quit", function() awesome.quit() end }, 94 } 95 96 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, 97 { "open terminal", terminal } 98 } 99 }) 100 101 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, 102 menu = mymainmenu }) 103 104 -- Menubar configuration 105 menubar.utils.terminal = terminal -- Set the terminal for applications that require it 106 -- }}} 107 108 -- Keyboard map indicator and switcher 109 mykeyboardlayout = awful.widget.keyboardlayout() 110 111 -- {{{ Wibar 112 -- Create a textclock widget 113 114 local timezone_popup = awful.popup { 115 widget = { 116 { 117 -- Timezone widgets 118 wibox.widget.textclock("VNO: %F %T%z", 1, "Europe/Vilnius"), 119 wibox.widget.textclock("UTC: %F %T%z", 1, "UTC"), 120 wibox.widget.textclock("IAD: %F %T%z", 1, "US/Eastern"), 121 wibox.widget.textclock("SEA: %F %T%z", 1, "US/Pacific"), 122 layout = wibox.layout.fixed.vertical 123 }, 124 margins = 8, 125 widget = wibox.container.margin 126 }, 127 border_width = 2, 128 border_color = "#ffffff", 129 placement = function(d) 130 awful.placement.top_right(d, { margins = { top = 20, right = 10 } } ) 131 end, 132 ontop = true, 133 visible = false 134 } 135 136 mytextclock = wibox.widget.textclock("%T%z", 1, "UTC") 137 mytextclock:buttons(gears.table.join( 138 awful.button({}, 1, function() 139 timezone_popup.visible = not timezone_popup.visible 140 end) 141 )) 142 143 vnoclock = wibox.widget.textclock(" | %F %T%z %a", 1, "Europe/Vilnius") 144 vnoclock:buttons(gears.table.join( 145 awful.button({}, 1, function() 146 timezone_popup.visible = not timezone_popup.visible 147 end) 148 )) 149 150 -- Create a wibox for each screen and add it 151 local taglist_buttons = gears.table.join( 152 awful.button({ }, 1, function(t) t:view_only() end), 153 awful.button({ modkey }, 1, function(t) 154 if client.focus then 155 client.focus:move_to_tag(t) 156 end 157 end), 158 awful.button({ }, 3, awful.tag.viewtoggle), 159 awful.button({ modkey }, 3, function(t) 160 if client.focus then 161 client.focus:toggle_tag(t) 162 end 163 end), 164 awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), 165 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) 166 ) 167 168 local tasklist_buttons = gears.table.join( 169 awful.button({ }, 1, function (c) 170 if c == client.focus then 171 c.minimized = true 172 else 173 c:emit_signal( 174 "request::activate", 175 "tasklist", 176 {raise = true} 177 ) 178 end 179 end), 180 awful.button({ }, 3, function() 181 awful.menu.client_list({ theme = { width = 250 } }) 182 end), 183 awful.button({ }, 4, function () 184 awful.client.focus.byidx(1) 185 end), 186 awful.button({ }, 5, function () 187 awful.client.focus.byidx(-1) 188 end)) 189 190 local function set_wallpaper(s) 191 -- Wallpaper 192 if beautiful.wallpaper then 193 local wallpaper = beautiful.wallpaper 194 -- If wallpaper is a function, call it with the screen 195 if type(wallpaper) == "function" then 196 wallpaper = wallpaper(s) 197 end 198 gears.wallpaper.maximized(wallpaper, s, true) 199 end 200 end 201 202 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) 203 screen.connect_signal("property::geometry", set_wallpaper) 204 205 awful.screen.connect_for_each_screen(function(s) 206 -- Wallpaper 207 set_wallpaper(s) 208 209 -- Each screen has its own tag table. 210 awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) 211 212 -- Create a promptbox for each screen 213 s.mypromptbox = awful.widget.prompt() 214 -- Create an imagebox widget which will contain an icon indicating which layout we're using. 215 -- We need one layoutbox per screen. 216 s.mylayoutbox = awful.widget.layoutbox(s) 217 s.mylayoutbox:buttons(gears.table.join( 218 awful.button({ }, 1, function () awful.layout.inc( 1) end), 219 awful.button({ }, 3, function () awful.layout.inc(-1) end), 220 awful.button({ }, 4, function () awful.layout.inc( 1) end), 221 awful.button({ }, 5, function () awful.layout.inc(-1) end))) 222 -- Create a taglist widget 223 s.mytaglist = awful.widget.taglist { 224 screen = s, 225 filter = awful.widget.taglist.filter.all, 226 buttons = taglist_buttons 227 } 228 229 -- Create a tasklist widget 230 s.mytasklist = awful.widget.tasklist { 231 screen = s, 232 filter = awful.widget.tasklist.filter.currenttags, 233 buttons = tasklist_buttons 234 } 235 236 -- Create the wibox 237 s.mywibox = awful.wibar({ position = "top", screen = s }) 238 239 -- Add widgets to the wibox 240 s.mywibox:setup { 241 layout = wibox.layout.align.horizontal, 242 { -- Left widgets 243 layout = wibox.layout.fixed.horizontal, 244 --mylauncher, 245 s.mytaglist, 246 s.mypromptbox, 247 }, 248 s.mytasklist, -- Middle widget 249 { -- Right widgets 250 layout = wibox.layout.fixed.horizontal, 251 mykeyboardlayout, 252 wibox.widget.systray(), 253 mytextclock, 254 vnoclock, 255 s.mylayoutbox, 256 }, 257 } 258 end) 259 -- }}} 260 261 -- {{{ Mouse bindings 262 root.buttons(gears.table.join( 263 awful.button({ }, 3, function () mymainmenu:toggle() end), 264 awful.button({ }, 4, awful.tag.viewnext), 265 awful.button({ }, 5, awful.tag.viewprev) 266 )) 267 -- }}} 268 269 -- {{{ Key bindings 270 globalkeys = gears.table.join( 271 --awful.key({ modkey, }, "s", hotkeys_popup.show_help, 272 -- {description="show help", group="awesome"}), 273 awful.key({ modkey }, "s", function() 274 awful.spawn.with_shell([[ 275 scrot --select --file '%F_%T_$wx$h.png' --exec '\ 276 xclip -selection clipboard -target image/png -i $f && \ 277 zopflipng -y $f $f && \ 278 xclip -selection clipboard -target image/png -i $f' 279 ]]) 280 end), 281 awful.key({}, "XF86MonBrightnessDown", function() 282 awful.spawn.easy_async_with_shell("brightness down", function(stdout) 283 naughty.notify({text = stdout, timeout = 1}) 284 end) 285 end), 286 awful.key({}, "XF86MonBrightnessUp", function() 287 awful.spawn.easy_async_with_shell("brightness up", function(stdout) 288 naughty.notify({text = stdout, timeout = 1}) 289 end) 290 end), 291 awful.key({ modkey, }, "Left", awful.tag.viewprev, 292 {description = "view previous", group = "tag"}), 293 awful.key({ modkey, }, "Right", awful.tag.viewnext, 294 {description = "view next", group = "tag"}), 295 awful.key({ modkey, }, "Escape", awful.tag.history.restore, 296 {description = "go back", group = "tag"}), 297 298 awful.key({ modkey, }, "j", 299 function () 300 awful.client.focus.byidx( 1) 301 end, 302 {description = "focus next by index", group = "client"} 303 ), 304 awful.key({ modkey, }, "k", 305 function () 306 awful.client.focus.byidx(-1) 307 end, 308 {description = "focus previous by index", group = "client"} 309 ), 310 awful.key({ modkey, }, "w", function () mymainmenu:show() end, 311 {description = "show main menu", group = "awesome"}), 312 313 -- Layout manipulation 314 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, 315 {description = "swap with next client by index", group = "client"}), 316 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, 317 {description = "swap with previous client by index", group = "client"}), 318 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, 319 {description = "focus the next screen", group = "screen"}), 320 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, 321 {description = "focus the previous screen", group = "screen"}), 322 awful.key({ modkey, }, "u", awful.client.urgent.jumpto, 323 {description = "jump to urgent client", group = "client"}), 324 awful.key({ modkey, }, "Tab", 325 function () 326 awful.client.focus.history.previous() 327 if client.focus then 328 client.focus:raise() 329 end 330 end, 331 {description = "go back", group = "client"}), 332 333 -- Standard program 334 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end, 335 {description = "open a terminal", group = "launcher"}), 336 awful.key({ modkey, "Control" }, "r", awesome.restart, 337 {description = "reload awesome", group = "awesome"}), 338 --awful.key({ modkey, "Shift" }, "q", awesome.quit, 339 -- {description = "quit awesome", group = "awesome"}), 340 341 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, 342 {description = "increase master width factor", group = "layout"}), 343 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, 344 {description = "decrease master width factor", group = "layout"}), 345 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, 346 {description = "increase the number of master clients", group = "layout"}), 347 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end, 348 {description = "decrease the number of master clients", group = "layout"}), 349 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, 350 {description = "increase the number of columns", group = "layout"}), 351 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, 352 {description = "decrease the number of columns", group = "layout"}), 353 awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, 354 {description = "select next", group = "layout"}), 355 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, 356 {description = "select previous", group = "layout"}), 357 358 awful.key({ modkey, "Control" }, "n", 359 function () 360 local c = awful.client.restore() 361 -- Focus restored client 362 if c then 363 c:emit_signal( 364 "request::activate", "key.unminimize", {raise = true} 365 ) 366 end 367 end, 368 {description = "restore minimized", group = "client"}), 369 370 -- Prompt 371 awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, 372 {description = "run prompt", group = "launcher"}), 373 374 --awful.key({ modkey }, "x", 375 -- function () 376 -- awful.prompt.run { 377 -- prompt = "Run Lua code: ", 378 -- textbox = awful.screen.focused().mypromptbox.widget, 379 -- exe_callback = awful.util.eval, 380 -- history_path = awful.util.get_cache_dir() .. "/history_eval" 381 -- } 382 -- end, 383 -- {description = "lua execute prompt", group = "awesome"}), 384 -- Menubar 385 awful.key({ modkey }, "p", function() menubar.show() end, 386 {description = "show the menubar", group = "launcher"}), 387 -- My customizations 388 awful.key({ modkey }, "x", function() 389 awful.spawn.with_shell("loginctl lock-session") 390 end), 391 awful.key({ modkey }, "q", function() 392 awful.spawn.with_shell("qalculate-qt") 393 end) 394 ) 395 396 clientkeys = gears.table.join( 397 awful.key({ modkey, }, "f", 398 function (c) 399 c.fullscreen = not c.fullscreen 400 c:raise() 401 end, 402 {description = "toggle fullscreen", group = "client"}), 403 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, 404 {description = "close", group = "client"}), 405 awful.key({ modkey, "Shift" }, "q", function (c) c:kill() end, 406 {description = "close", group = "client"}), 407 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , 408 {description = "toggle floating", group = "client"}), 409 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, 410 {description = "move to master", group = "client"}), 411 awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, 412 {description = "move to screen", group = "client"}), 413 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, 414 {description = "toggle keep on top", group = "client"}), 415 awful.key({ modkey, }, "n", 416 function (c) 417 -- The client currently has the input focus, so it cannot be 418 -- minimized, since minimized clients can't have the focus. 419 c.minimized = true 420 end , 421 {description = "minimize", group = "client"}), 422 awful.key({ modkey, }, "m", 423 function (c) 424 c.maximized = not c.maximized 425 c:raise() 426 end , 427 {description = "(un)maximize", group = "client"}), 428 awful.key({ modkey, "Control" }, "m", 429 function (c) 430 c.maximized_vertical = not c.maximized_vertical 431 c:raise() 432 end , 433 {description = "(un)maximize vertically", group = "client"}), 434 awful.key({ modkey, "Shift" }, "m", 435 function (c) 436 c.maximized_horizontal = not c.maximized_horizontal 437 c:raise() 438 end , 439 {description = "(un)maximize horizontally", group = "client"}) 440 ) 441 442 -- Bind all key numbers to tags. 443 -- Be careful: we use keycodes to make it work on any keyboard layout. 444 -- This should map on the top row of your keyboard, usually 1 to 9. 445 for i = 1, 9 do 446 globalkeys = gears.table.join(globalkeys, 447 -- View tag only. 448 awful.key({ modkey }, "#" .. i + 9, 449 function () 450 local screen = awful.screen.focused() 451 local tag = screen.tags[i] 452 if tag then 453 tag:view_only() 454 end 455 end, 456 {description = "view tag #"..i, group = "tag"}), 457 -- Toggle tag display. 458 awful.key({ modkey, "Control" }, "#" .. i + 9, 459 function () 460 local screen = awful.screen.focused() 461 local tag = screen.tags[i] 462 if tag then 463 awful.tag.viewtoggle(tag) 464 end 465 end, 466 {description = "toggle tag #" .. i, group = "tag"}), 467 -- Move client to tag. 468 awful.key({ modkey, "Shift" }, "#" .. i + 9, 469 function () 470 if client.focus then 471 local tag = client.focus.screen.tags[i] 472 if tag then 473 client.focus:move_to_tag(tag) 474 end 475 end 476 end, 477 {description = "move focused client to tag #"..i, group = "tag"}), 478 -- Toggle tag on focused client. 479 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, 480 function () 481 if client.focus then 482 local tag = client.focus.screen.tags[i] 483 if tag then 484 client.focus:toggle_tag(tag) 485 end 486 end 487 end, 488 {description = "toggle focused client on tag #" .. i, group = "tag"}) 489 ) 490 end 491 492 clientbuttons = gears.table.join( 493 awful.button({ }, 1, function (c) 494 c:emit_signal("request::activate", "mouse_click", {raise = true}) 495 end), 496 awful.button({ modkey }, 1, function (c) 497 c:emit_signal("request::activate", "mouse_click", {raise = true}) 498 awful.mouse.client.move(c) 499 end), 500 awful.button({ modkey }, 3, function (c) 501 c:emit_signal("request::activate", "mouse_click", {raise = true}) 502 awful.mouse.client.resize(c) 503 end) 504 ) 505 506 -- Set keys 507 root.keys(globalkeys) 508 -- }}} 509 510 -- {{{ Rules 511 -- Rules to apply to new clients (through the "manage" signal). 512 awful.rules.rules = { 513 -- All clients will match this rule. 514 { rule = { }, 515 properties = { border_width = beautiful.border_width, 516 border_color = beautiful.border_normal, 517 focus = awful.client.focus.filter, 518 raise = true, 519 keys = clientkeys, 520 buttons = clientbuttons, 521 screen = awful.screen.preferred, 522 placement = awful.placement.no_overlap+awful.placement.no_offscreen 523 } 524 }, 525 526 -- Floating clients. 527 { rule_any = { 528 instance = { 529 "DTA", -- Firefox addon DownThemAll. 530 "copyq", -- Includes session name in class. 531 "pinentry", 532 }, 533 class = { 534 "Arandr", 535 "Blueman-manager", 536 "Gpick", 537 "Kruler", 538 "MessageWin", -- kalarm. 539 "Sxiv", 540 "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. 541 "Wpa_gui", 542 "pinentry", 543 "veromix", 544 "xtightvncviewer"}, 545 546 -- Note that the name property shown in xprop might be set slightly after creation of the client 547 -- and the name shown there might not match defined rules here. 548 name = { 549 "Event Tester", -- xev. 550 }, 551 role = { 552 "AlarmWindow", -- Thunderbird's calendar. 553 "ConfigManager", -- Thunderbird's about:config. 554 "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. 555 } 556 }, properties = { floating = true }}, 557 558 -- Add titlebars to normal clients and dialogs 559 { rule_any = {type = { "normal", "dialog" } 560 }, properties = { titlebars_enabled = false } 561 }, 562 563 { rule = { class = "firefox" }, 564 properties = { screen = 1, tag = "2" } }, 565 { rule = { class = "Signal" }, 566 properties = { screen = 1, tag = "9" } }, 567 { rule = { class = "Element" }, 568 properties = { screen = 1, tag = "9" } }, 569 } 570 -- }}} 571 572 -- {{{ Signals 573 -- Signal function to execute when a new client appears. 574 client.connect_signal("manage", function (c) 575 -- Set the windows at the slave, 576 -- i.e. put it at the end of others instead of setting it master. 577 -- if not awesome.startup then awful.client.setslave(c) end 578 579 if awesome.startup 580 and not c.size_hints.user_position 581 and not c.size_hints.program_position then 582 -- Prevent clients from being unreachable after screen count changes. 583 awful.placement.no_offscreen(c) 584 end 585 end) 586 587 -- Add a titlebar if titlebars_enabled is set to true in the rules. 588 client.connect_signal("request::titlebars", function(c) 589 -- buttons for the titlebar 590 local buttons = gears.table.join( 591 awful.button({ }, 1, function() 592 c:emit_signal("request::activate", "titlebar", {raise = true}) 593 awful.mouse.client.move(c) 594 end), 595 awful.button({ }, 3, function() 596 c:emit_signal("request::activate", "titlebar", {raise = true}) 597 awful.mouse.client.resize(c) 598 end) 599 ) 600 601 awful.titlebar(c) : setup { 602 { -- Left 603 awful.titlebar.widget.iconwidget(c), 604 buttons = buttons, 605 layout = wibox.layout.fixed.horizontal 606 }, 607 { -- Middle 608 { -- Title 609 align = "center", 610 widget = awful.titlebar.widget.titlewidget(c) 611 }, 612 buttons = buttons, 613 layout = wibox.layout.flex.horizontal 614 }, 615 { -- Right 616 awful.titlebar.widget.floatingbutton (c), 617 awful.titlebar.widget.maximizedbutton(c), 618 awful.titlebar.widget.stickybutton (c), 619 awful.titlebar.widget.ontopbutton (c), 620 awful.titlebar.widget.closebutton (c), 621 layout = wibox.layout.fixed.horizontal() 622 }, 623 layout = wibox.layout.align.horizontal 624 } 625 end) 626 627 -- Enable sloppy focus, so that focus follows mouse. 628 client.connect_signal("mouse::enter", function(c) 629 c:emit_signal("request::activate", "mouse_enter", {raise = false}) 630 end) 631 632 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) 633 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) 634 -- }}}