SHOW:
|
|
- or go back to the newest paste.
| 1 | --[[ | |
| 2 | ||
| 3 | Blackburn Awesome WM config 2.0 | |
| 4 | github.com/copycat-killer | |
| 5 | ||
| 6 | --]] | |
| 7 | ||
| 8 | -- {{{ Required libraries
| |
| 9 | local gears = require("gears")
| |
| 10 | local awful = require("awful")
| |
| 11 | awful.rules = require("awful.rules")
| |
| 12 | require("awful.autofocus")
| |
| 13 | local wibox = require("wibox")
| |
| 14 | local beautiful = require("beautiful")
| |
| 15 | local naughty = require("naughty")
| |
| 16 | local drop = require("scratchdrop")
| |
| 17 | local lain = require("lain")
| |
| 18 | -- }}} | |
| 19 | ||
| 20 | -- {{{ Error handling
| |
| 21 | if awesome.startup_errors then | |
| 22 | naughty.notify({ preset = naughty.config.presets.critical,
| |
| 23 | title = "Oops, there were errors during startup!", | |
| 24 | text = awesome.startup_errors }) | |
| 25 | end | |
| 26 | ||
| 27 | do | |
| 28 | local in_error = false | |
| 29 | awesome.connect_signal("debug::error", function (err)
| |
| 30 | if in_error then return end | |
| 31 | in_error = true | |
| 32 | ||
| 33 | naughty.notify({ preset = naughty.config.presets.critical,
| |
| 34 | title = "Oops, an error happened!", | |
| 35 | text = err }) | |
| 36 | in_error = false | |
| 37 | end) | |
| 38 | end | |
| 39 | -- }}} | |
| 40 | ||
| 41 | -- {{{ Autostart applications
| |
| 42 | function run_once(cmd) | |
| 43 | findme = cmd | |
| 44 | firstspace = cmd:find(" ")
| |
| 45 | if firstspace then | |
| 46 | findme = cmd:sub(0, firstspace-1) | |
| 47 | end | |
| 48 | awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
| |
| 49 | end | |
| 50 | ||
| 51 | run_once("unclutter -idle 10")
| |
| 52 | run_once("urxvtd")
| |
| 53 | run_once("xrdb -merge ~/.Xresources")
| |
| 54 | run_once("setxkbmap pl")
| |
| 55 | run_once("mpd")
| |
| 56 | run_once("/usr/bin/xscreensaver -no-splash &")
| |
| 57 | run_once("/home/rlk120/.scripts/lightson.sh &")
| |
| 58 | -- }}} | |
| 59 | ||
| 60 | -- {{{ Variable definitions
| |
| 61 | -- localization | |
| 62 | os.setlocale(os.getenv("LANG"))
| |
| 63 | ||
| 64 | -- home path | |
| 65 | homedir = os.getenv("HOME") .. "/.config/awesome/"
| |
| 66 | ||
| 67 | -- beautiful init | |
| 68 | beautiful.init(awful.util.getdir("config") .. "/themes/blackburn/theme.lua")
| |
| 69 | ||
| 70 | -- common | |
| 71 | modkey = "Mod4" | |
| 72 | altkey = "Mod1" | |
| 73 | terminal = "urxvtc" or "xterm" | |
| 74 | editor = os.getenv("EDITOR") or "nano" or "vi"
| |
| 75 | editor_cmd = terminal .. " -e " .. editor | |
| 76 | ||
| 77 | -- user defined | |
| 78 | browser = "dwb" | |
| 79 | gui_editor = "gvim" | |
| 80 | graphics = "gimp" | |
| 81 | musicplr = terminal .. " -g 130x34-320+16 -e ncmpcpp " | |
| 82 | tasks = terminal .. " -e htop " | |
| 83 | explorer = "spacefm" | |
| 84 | ||
| 85 | local layouts = {
| |
| 86 | awful.layout.suit.floating, | |
| 87 | lain.layout.uselesstile, | |
| 88 | awful.layout.suit.fair, | |
| 89 | lain.layout.uselesstile.left, | |
| 90 | lain.layout.uselesstile.top | |
| 91 | } | |
| 92 | -- }}} | |
| 93 | ||
| 94 | -- {{{ Tags
| |
| 95 | tags = {
| |
| 96 | names = { "web", "term", "docs", "media", "down"},
| |
| 97 | layout = { layouts[1], layouts[3], layouts[2], layouts[1], layouts[5] }
| |
| 98 | } | |
| 99 | for s = 1, screen.count() do | |
| 100 | tags[s] = awful.tag(tags.names, s, tags.layout) | |
| 101 | end | |
| 102 | -- }}} | |
| 103 | ||
| 104 | -- {{{ Wallpaper
| |
| 105 | if beautiful.wallpaper then | |
| 106 | for s = 1, screen.count() do | |
| 107 | gears.wallpaper.maximized(beautiful.wallpaper, s, true) | |
| 108 | end | |
| 109 | end | |
| 110 | -- }}} | |
| 111 | -- {{{ Menu
| |
| 112 | require("freedesktop/freedesktop")
| |
| 113 | -- }}} | |
| 114 | ||
| 115 | -- {{{ Wibox
| |
| 116 | markup = lain.util.markup | |
| 117 | gray = "#9E9C9A" | |
| 118 | ||
| 119 | -- Textclock | |
| 120 | mytextclock = awful.widget.textclock(" %H:%M ")
| |
| 121 | ||
| 122 | -- Calendar | |
| 123 | lain.widgets.calendar:attach(mytextclock) | |
| 124 | ||
| 125 | -- Mail IMAP check | |
| 126 | -- commented because it needs to be set before use | |
| 127 | mailwidget = lain.widgets.imap({
| |
| 128 | - | is_plain = true, |
| 128 | + | is_plain = true, |
| 129 | - | timeout = 5, |
| 129 | + | timeout = 120, |
| 130 | server = "imap.gmail.com", | |
| 131 | mail = "[email protected]", | |
| 132 | - | password = "tkoK7WR4ejshL6fz", |
| 132 | + | password = "mypassword", |
| 133 | settings = function() | |
| 134 | mail_notification_preset.position = "top_right" | |
| 135 | ||
| 136 | mail = "" | |
| 137 | count = "" | |
| 138 | ||
| 139 | if mailcount > 0 then | |
| 140 | mail = "Mail: " | |
| 141 | count = mailcount .. " " | |
| 142 | end | |
| 143 | ||
| 144 | widget:set_markup(markup(gray, mail) .. count) | |
| 145 | end | |
| 146 | }) | |
| 147 | ||
| 148 | ||
| 149 | -- MPD | |
| 150 | mpdwidget = lain.widgets.mpd({
| |
| 151 | settings = function() | |
| 152 | artist = mpd_now.artist .. " " | |
| 153 | title = mpd_now.title .. " " | |
| 154 | ||
| 155 | if mpd_now.state == "pause" then | |
| 156 | artist = "mpd " | |
| 157 | title = "paused " | |
| 158 | elseif mpd_now.state == "stop" then | |
| 159 | artist = "" | |
| 160 | title = "" | |
| 161 | end | |
| 162 | ||
| 163 | widget:set_markup(markup(gray, artist) .. title) | |
| 164 | end | |
| 165 | }) | |
| 166 | mpdwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn_with_shell(musicplr) end)))
| |
| 167 | ||
| 168 | -- /home fs | |
| 169 | fshome = lain.widgets.fs({
| |
| 170 | partition = "/home", | |
| 171 | settings = function() | |
| 172 | fs_header = "" | |
| 173 | fs_p = "" | |
| 174 | ||
| 175 | if fs_now.used >= 90 then | |
| 176 | fs_header = " Hdd " | |
| 177 | fs_p = fs_now.used | |
| 178 | end | |
| 179 | ||
| 180 | widget:set_markup(markup(gray, fs_header) .. fs_p) | |
| 181 | end | |
| 182 | }) | |
| 183 | ||
| 184 | -- Battery | |
| 185 | batwidget = lain.widgets.bat({
| |
| 186 | settings = function() | |
| 187 | bat_header = " Bat " | |
| 188 | bat_p = bat_now.perc .. " " | |
| 189 | ||
| 190 | if bat_now.status == "Not present" then | |
| 191 | bat_header = "" | |
| 192 | bat_p = "" | |
| 193 | end | |
| 194 | ||
| 195 | widget:set_markup(markup(gray, bat_header) .. bat_p) | |
| 196 | end | |
| 197 | }) | |
| 198 | ||
| 199 | -- ALSA volume | |
| 200 | volumewidget = lain.widgets.alsa({
| |
| 201 | settings = function() | |
| 202 | header = " Vol " | |
| 203 | level = volume_now.level | |
| 204 | ||
| 205 | if volume_now.status == "off" then | |
| 206 | level = "Mute " | |
| 207 | else | |
| 208 | level = level .. " " | |
| 209 | end | |
| 210 | ||
| 211 | widget:set_markup(markup(gray, header) .. level) | |
| 212 | end | |
| 213 | }) | |
| 214 | ||
| 215 | -- Weather | |
| 216 | yawn = lain.widgets.yawn(523920, | |
| 217 | {
| |
| 218 | settings = function() | |
| 219 | widget:set_markup(" " .. units .. " ")
| |
| 220 | end | |
| 221 | }) | |
| 222 | ||
| 223 | -- Separators | |
| 224 | first = wibox.widget.textbox('<span font="Tamsyn 4"> </span>')
| |
| 225 | arrl_pre = wibox.widget.imagebox() | |
| 226 | arrl_pre:set_image(beautiful.arrl_lr_pre) | |
| 227 | arrl_post = wibox.widget.imagebox() | |
| 228 | arrl_post:set_image(beautiful.arrl_lr_post) | |
| 229 | ||
| 230 | -- Create a wibox for each screen and add it | |
| 231 | mywibox = {}
| |
| 232 | mypromptbox = {}
| |
| 233 | mylayoutbox = {}
| |
| 234 | mytaglist = {}
| |
| 235 | mytaglist.buttons = awful.util.table.join( | |
| 236 | awful.button({ }, 1, awful.tag.viewonly),
| |
| 237 | awful.button({ modkey }, 1, awful.client.movetotag),
| |
| 238 | awful.button({ }, 3, awful.tag.viewtoggle),
| |
| 239 | awful.button({ modkey }, 3, awful.client.toggletag),
| |
| 240 | awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
| |
| 241 | awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
| |
| 242 | ) | |
| 243 | mytasklist = {}
| |
| 244 | mytasklist.buttons = awful.util.table.join( | |
| 245 | awful.button({ }, 1, function (c)
| |
| 246 | if c == client.focus then | |
| 247 | c.minimized = true | |
| 248 | else | |
| 249 | -- Without this, the following | |
| 250 | -- :isvisible() makes no sense | |
| 251 | c.minimized = false | |
| 252 | if not c:isvisible() then | |
| 253 | awful.tag.viewonly(c:tags()[1]) | |
| 254 | end | |
| 255 | -- This will also un-minimize | |
| 256 | -- the client, if needed | |
| 257 | client.focus = c | |
| 258 | c:raise() | |
| 259 | end | |
| 260 | end), | |
| 261 | awful.button({ }, 3, function ()
| |
| 262 | if instance then | |
| 263 | instance:hide() | |
| 264 | instance = nil | |
| 265 | else | |
| 266 | instance = awful.menu.clients({ width=250 })
| |
| 267 | end | |
| 268 | end), | |
| 269 | awful.button({ }, 4, function ()
| |
| 270 | awful.client.focus.byidx(1) | |
| 271 | if client.focus then client.focus:raise() end | |
| 272 | end), | |
| 273 | awful.button({ }, 5, function ()
| |
| 274 | awful.client.focus.byidx(-1) | |
| 275 | if client.focus then client.focus:raise() end | |
| 276 | end)) | |
| 277 | ||
| 278 | for s = 1, screen.count() do | |
| 279 | -- Create a promptbox for each screen | |
| 280 | mypromptbox[s] = awful.widget.prompt() | |
| 281 | -- Create an imagebox widget which will contains an icon indicating which layout we're using. | |
| 282 | -- We need one layoutbox per screen. | |
| 283 | mylayoutbox[s] = awful.widget.layoutbox(s) | |
| 284 | mylayoutbox[s]:buttons(awful.util.table.join( | |
| 285 | awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
| |
| 286 | awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
| |
| 287 | awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
| |
| 288 | awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
| |
| 289 | -- Create a taglist widget | |
| 290 | mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) | |
| 291 | ||
| 292 | -- Create a tasklist widget | |
| 293 | mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) | |
| 294 | ||
| 295 | -- Create the wibox | |
| 296 | mywibox[s] = awful.wibox({ position = "top", screen = s, height = 18 })
| |
| 297 | ||
| 298 | -- Widgets that are aligned to the left | |
| 299 | local left_layout = wibox.layout.fixed.horizontal() | |
| 300 | left_layout:add(first) | |
| 301 | left_layout:add(mytaglist[s]) | |
| 302 | left_layout:add(arrl_pre) | |
| 303 | left_layout:add(mylayoutbox[s]) | |
| 304 | left_layout:add(arrl_post) | |
| 305 | left_layout:add(mypromptbox[s]) | |
| 306 | left_layout:add(first) | |
| 307 | ||
| 308 | -- Widgets that are aligned to the right | |
| 309 | local right_layout = wibox.layout.fixed.horizontal() | |
| 310 | if s == 1 then right_layout:add(wibox.widget.systray()) end | |
| 311 | right_layout:add(first) | |
| 312 | right_layout:add(mpdwidget) | |
| 313 | right_layout:add(mailwidget) | |
| 314 | right_layout:add(yawn.icon) | |
| 315 | right_layout:add(yawn.widget) | |
| 316 | right_layout:add(fshome) | |
| 317 | --right_layout:add(batwidget) | |
| 318 | right_layout:add(volumewidget) | |
| 319 | right_layout:add(mytextclock) | |
| 320 | ||
| 321 | -- Now bring it all together (with the tasklist in the middle) | |
| 322 | local layout = wibox.layout.align.horizontal() | |
| 323 | layout:set_left(left_layout) | |
| 324 | layout:set_middle(mytasklist[s]) | |
| 325 | layout:set_right(right_layout) | |
| 326 | ||
| 327 | mywibox[s]:set_widget(layout) | |
| 328 | ||
| 329 | -- Set proper background, instead of beautiful.bg_normal | |
| 330 | mywibox[s]:set_bg(beautiful.topbar_path .. screen[mouse.screen].workarea.width .. ".png") | |
| 331 | end | |
| 332 | -- }}} | |
| 333 | ||
| 334 | -- {{{ Mouse bindings
| |
| 335 | root.buttons(awful.util.table.join( | |
| 336 | awful.button({ }, 3, function () mymainmenu:toggle() end),
| |
| 337 | awful.button({ }, 4, awful.tag.viewnext),
| |
| 338 | awful.button({ }, 5, awful.tag.viewprev)
| |
| 339 | )) | |
| 340 | -- }}} | |
| 341 | ||
| 342 | -- {{{ Key bindings
| |
| 343 | globalkeys = awful.util.table.join( | |
| 344 | -- Take a screenshot | |
| 345 | -- https://github.com/copycat-killer/dots/blob/master/bin/screenshot | |
| 346 | awful.key({ }, "#99", function() os.execute("screenshot") end),
| |
| 347 | ||
| 348 | -- Tag browsing | |
| 349 | awful.key({ modkey }, "Left", awful.tag.viewprev ),
| |
| 350 | awful.key({ modkey }, "Right", awful.tag.viewnext ),
| |
| 351 | awful.key({ modkey }, "Escape", awful.tag.history.restore),
| |
| 352 | ||
| 353 | -- Non-empty tag browsing | |
| 354 | awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end),
| |
| 355 | awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end),
| |
| 356 | ||
| 357 | -- Default client focus | |
| 358 | awful.key({ altkey }, "k",
| |
| 359 | function () | |
| 360 | awful.client.focus.byidx( 1) | |
| 361 | if client.focus then client.focus:raise() end | |
| 362 | end), | |
| 363 | awful.key({ altkey }, "j",
| |
| 364 | function () | |
| 365 | awful.client.focus.byidx(-1) | |
| 366 | if client.focus then client.focus:raise() end | |
| 367 | end), | |
| 368 | ||
| 369 | -- By direction client focus | |
| 370 | awful.key({ modkey }, "j",
| |
| 371 | function() | |
| 372 | awful.client.focus.bydirection("down")
| |
| 373 | if client.focus then client.focus:raise() end | |
| 374 | end), | |
| 375 | awful.key({ modkey }, "k",
| |
| 376 | function() | |
| 377 | awful.client.focus.bydirection("up")
| |
| 378 | if client.focus then client.focus:raise() end | |
| 379 | end), | |
| 380 | awful.key({ modkey }, "h",
| |
| 381 | function() | |
| 382 | awful.client.focus.bydirection("left")
| |
| 383 | if client.focus then client.focus:raise() end | |
| 384 | end), | |
| 385 | awful.key({ modkey }, "l",
| |
| 386 | function() | |
| 387 | awful.client.focus.bydirection("right")
| |
| 388 | if client.focus then client.focus:raise() end | |
| 389 | end), | |
| 390 | ||
| 391 | -- Show Menu | |
| 392 | awful.key({ modkey }, "w",
| |
| 393 | function () | |
| 394 | mymainmenu:show({ keygrabber = true })
| |
| 395 | end), | |
| 396 | ||
| 397 | -- Show/Hide Wibox | |
| 398 | awful.key({ modkey }, "b", function ()
| |
| 399 | mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible | |
| 400 | end), | |
| 401 | ||
| 402 | -- On the fly useless gaps change | |
| 403 | awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end),
| |
| 404 | awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end),
| |
| 405 | ||
| 406 | -- Layout manipulation | |
| 407 | awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
| |
| 408 | awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
| |
| 409 | awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
| |
| 410 | awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
| |
| 411 | awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
| |
| 412 | awful.key({ modkey, }, "Tab",
| |
| 413 | function () | |
| 414 | awful.client.focus.history.previous() | |
| 415 | if client.focus then | |
| 416 | client.focus:raise() | |
| 417 | end | |
| 418 | end), | |
| 419 | awful.key({ altkey, "Shift" }, "l", function () awful.tag.incmwfact( 0.05) end),
| |
| 420 | awful.key({ altkey, "Shift" }, "h", function () awful.tag.incmwfact(-0.05) end),
| |
| 421 | awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
| |
| 422 | awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
| |
| 423 | awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
| |
| 424 | awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
| |
| 425 | awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
| |
| 426 | awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
| |
| 427 | awful.key({ modkey, "Control" }, "n", awful.client.restore),
| |
| 428 | ||
| 429 | -- Standard program | |
| 430 | awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
| |
| 431 | awful.key({ altkey, modkey, "Control" }, "r", awesome.restart),
| |
| 432 | awful.key({ modkey, "Shift" }, "q", awesome.quit),
| |
| 433 | ||
| 434 | -- Dropdown terminal | |
| 435 | -- awful.key({ modkey, }, "z", function () drop(terminal) end),
| |
| 436 | ||
| 437 | -- Widgets popups | |
| 438 | awful.key({ altkey, }, "c", function () lain.widgets.calendar:show(7) end),
| |
| 439 | awful.key({ altkey, }, "h", function () fshome.show(7) end),
| |
| 440 | awful.key({ altkey, }, "w", function () yawn.show(7) end),
| |
| 441 | ||
| 442 | -- ALSA volume control | |
| 443 | --[[awful.key({ altkey }, "Up",
| |
| 444 | function () | |
| 445 | awful.util.spawn("amixer -q set Master 1%+")
| |
| 446 | volumewidget.update() | |
| 447 | end), | |
| 448 | awful.key({ altkey }, "Down",
| |
| 449 | function () | |
| 450 | awful.util.spawn("amixer -q set Master 1%-")
| |
| 451 | volumewidget.update() | |
| 452 | end), | |
| 453 | awful.key({ altkey }, "m",
| |
| 454 | function () | |
| 455 | awful.util.spawn("amixer -q set Master playback toggle")
| |
| 456 | volumewidget.update() | |
| 457 | end), | |
| 458 | awful.key({ altkey, "Control" }, "m",
| |
| 459 | function () | |
| 460 | awful.util.spawn("amixer -q set Master playback 100%")
| |
| 461 | volumewidget.update() | |
| 462 | end),]] | |
| 463 | awful.key({ }, "XF86AudioRaiseVolume", function ()
| |
| 464 | awful.util.spawn("amixer -q set Master 2+ unmute", false )
| |
| 465 | volumewidget.update() | |
| 466 | end), | |
| 467 | awful.key({ }, "XF86AudioLowerVolume", function ()
| |
| 468 | awful.util.spawn("amixer -q set Master 2- unmute", false )
| |
| 469 | volumewidget.update() | |
| 470 | end), | |
| 471 | awful.key({ }, "XF86AudioMute", function ()
| |
| 472 | awful.util.spawn("amixer set Master toggle", false )
| |
| 473 | volumewidget.update() | |
| 474 | end), | |
| 475 | ||
| 476 | -- MPD control | |
| 477 | awful.key({ }, "#172",
| |
| 478 | function () | |
| 479 | awful.util.spawn_with_shell("mpc toggle || ncmpcpp toggle || ncmpc toggle || pms toggle")
| |
| 480 | mpdwidget.update() | |
| 481 | end), | |
| 482 | awful.key({}, "#174",
| |
| 483 | function () | |
| 484 | awful.util.spawn_with_shell("mpc stop || ncmpcpp stop || ncmpc stop || pms stop")
| |
| 485 | mpdwidget.update() | |
| 486 | end), | |
| 487 | awful.key({}, "#173",
| |
| 488 | function () | |
| 489 | awful.util.spawn_with_shell("mpc prev || ncmpcpp prev || ncmpc prev || pms prev")
| |
| 490 | mpdwidget.update() | |
| 491 | end), | |
| 492 | awful.key({}, "#171",
| |
| 493 | function () | |
| 494 | awful.util.spawn_with_shell("mpc next || ncmpcpp next || ncmpc next || pms next")
| |
| 495 | mpdwidget.update() | |
| 496 | end), | |
| 497 | ||
| 498 | -- Copy to clipboard | |
| 499 | awful.key({ modkey }, "c", function () os.execute("xsel -p -o | xsel -i -b") end),
| |
| 500 | ||
| 501 | -- User programs | |
| 502 | awful.key({ modkey }, "q", function () awful.util.spawn(browser) end),
| |
| 503 | awful.key({ modkey }, "s", function () awful.util.spawn(gui_editor) end),
| |
| 504 | awful.key({ modkey }, "g", function () awful.util.spawn(graphics) end),
| |
| 505 | awful.key({ }, "#148", function () awful.util.spawn("speedcrunch", false) end),
| |
| 506 | awful.key({ modkey }, "e", function () awful.util.spawn(explorer) end),
| |
| 507 | ||
| 508 | --shutdown | |
| 509 | awful.key({}, "#150", function () awful.util.spawn("systemctl suspend", false) end),
| |
| 510 | awful.key({ modkey, "Control" }, "#22", function () awful.util.spawn("systemctl shutdown", false) end),
| |
| 511 | awful.key({ modkey, "Control" }, "r", function () awful.util.spawn("systemctl reboot", false) end),
| |
| 512 | ||
| 513 | -- Prompt | |
| 514 | awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
| |
| 515 | awful.key({ modkey }, "x",
| |
| 516 | function () | |
| 517 | awful.prompt.run({ prompt = "Run Lua code: " },
| |
| 518 | mypromptbox[mouse.screen].widget, | |
| 519 | awful.util.eval, nil, | |
| 520 | awful.util.getdir("cache") .. "/history_eval")
| |
| 521 | end) | |
| 522 | ) | |
| 523 | ||
| 524 | clientkeys = awful.util.table.join( | |
| 525 | awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
| |
| 526 | awful.key({ altkey }, "q", function (c) c:kill() end),
| |
| 527 | awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
| |
| 528 | awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
| |
| 529 | awful.key({ modkey, }, "o", awful.client.movetoscreen ),
| |
| 530 | awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
| |
| 531 | awful.key({ modkey, }, "n",
| |
| 532 | function (c) | |
| 533 | -- The client currently has the input focus, so it cannot be | |
| 534 | -- minimized, since minimized clients can't have the focus. | |
| 535 | c.minimized = true | |
| 536 | end), | |
| 537 | awful.key({ modkey, }, "m",
| |
| 538 | function (c) | |
| 539 | c.maximized_horizontal = not c.maximized_horizontal | |
| 540 | c.maximized_vertical = not c.maximized_vertical | |
| 541 | end) | |
| 542 | ) | |
| 543 | ||
| 544 | -- Bind all key numbers to tags. | |
| 545 | -- Be careful: we use keycodes to make it works on any keyboard layout. | |
| 546 | -- This should map on the top row of your keyboard, usually 1 to 9. | |
| 547 | for i = 1, 9 do | |
| 548 | globalkeys = awful.util.table.join(globalkeys, | |
| 549 | awful.key({ modkey }, "#" .. i + 9,
| |
| 550 | function () | |
| 551 | local screen = mouse.screen | |
| 552 | local tag = awful.tag.gettags(screen)[i] | |
| 553 | if tag then | |
| 554 | awful.tag.viewonly(tag) | |
| 555 | end | |
| 556 | end), | |
| 557 | awful.key({ modkey, "Control" }, "#" .. i + 9,
| |
| 558 | function () | |
| 559 | local screen = mouse.screen | |
| 560 | local tag = awful.tag.gettags(screen)[i] | |
| 561 | if tag then | |
| 562 | awful.tag.viewtoggle(tag) | |
| 563 | end | |
| 564 | end), | |
| 565 | awful.key({ modkey, "Shift" }, "#" .. i + 9,
| |
| 566 | function () | |
| 567 | local tag = awful.tag.gettags(client.focus.screen)[i] | |
| 568 | if client.focus and tag then | |
| 569 | awful.client.movetotag(tag) | |
| 570 | end | |
| 571 | end), | |
| 572 | awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
| |
| 573 | function () | |
| 574 | local tag = awful.tag.gettags(client.focus.screen)[i] | |
| 575 | if client.focus and tag then | |
| 576 | awful.client.toggletag(tag) | |
| 577 | end | |
| 578 | end)) | |
| 579 | end | |
| 580 | ||
| 581 | clientbuttons = awful.util.table.join( | |
| 582 | awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
| |
| 583 | awful.button({ modkey }, 1, awful.mouse.client.move),
| |
| 584 | awful.button({ modkey }, 3, awful.mouse.client.resize))
| |
| 585 | ||
| 586 | -- Set keys | |
| 587 | root.keys(globalkeys) | |
| 588 | -- }}} | |
| 589 | ||
| 590 | -- {{{ Rules
| |
| 591 | awful.rules.rules = {
| |
| 592 | -- All clients will match this rule. | |
| 593 | { rule = { },
| |
| 594 | properties = { border_width = beautiful.border_width,
| |
| 595 | border_color = beautiful.border_normal, | |
| 596 | focus = awful.client.focus.filter, | |
| 597 | keys = clientkeys, | |
| 598 | buttons = clientbuttons, | |
| 599 | size_hints_honor = false } }, | |
| 600 | { rule = { class = "URxvt" },
| |
| 601 | properties = { opacity = 0.99 } },
| |
| 602 | ||
| 603 | { rule = { class = "MPlayer" },
| |
| 604 | properties = { floating = true } },
| |
| 605 | ||
| 606 | { rule = { class = "Dwb" },
| |
| 607 | properties = { tag = tags[1][1] } },
| |
| 608 | ||
| 609 | { rule = { class = "Iron" },
| |
| 610 | properties = { tag = tags[1][1] } },
| |
| 611 | ||
| 612 | { rule = { instance = "plugin-container" },
| |
| 613 | properties = { tag = tags[1][1] } },
| |
| 614 | ||
| 615 | { rule = { class = "Gimp" },
| |
| 616 | properties = { tag = tags[1][4] } },
| |
| 617 | ||
| 618 | { rule = { class = "Gimp", role = "gimp-image-window" },
| |
| 619 | properties = { maximized_horizontal = true,
| |
| 620 | maximized_vertical = true } }, | |
| 621 | } | |
| 622 | -- }}} | |
| 623 | ||
| 624 | -- {{{ Signals
| |
| 625 | -- Signal function to execute when a new client appears. | |
| 626 | client.connect_signal("manage", function (c, startup)
| |
| 627 | -- Enable sloppy focus | |
| 628 | c:connect_signal("mouse::enter", function(c)
| |
| 629 | if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier | |
| 630 | and awful.client.focus.filter(c) then | |
| 631 | client.focus = c | |
| 632 | end | |
| 633 | end) | |
| 634 | ||
| 635 | if not startup and not c.size_hints.user_position | |
| 636 | and not c.size_hints.program_position then | |
| 637 | awful.placement.no_overlap(c) | |
| 638 | awful.placement.no_offscreen(c) | |
| 639 | end | |
| 640 | end) | |
| 641 | ||
| 642 | -- No border for maximized clients | |
| 643 | client.connect_signal("focus",
| |
| 644 | function(c) | |
| 645 | if c.maximized_horizontal == true and c.maximized_vertical == true then | |
| 646 | c.border_width = 0 | |
| 647 | c.border_color = beautiful.border_normal | |
| 648 | else | |
| 649 | c.border_width = beautiful.border_width | |
| 650 | c.border_color = beautiful.border_focus | |
| 651 | end | |
| 652 | end) | |
| 653 | client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
| |
| 654 | -- }}} | |
| 655 | ||
| 656 | -- {{{ Arrange signal handler
| |
| 657 | for s = 1, screen.count() do screen[s]:connect_signal("arrange", function ()
| |
| 658 | local clients = awful.client.visible(s) | |
| 659 | local layout = awful.layout.getname(awful.layout.get(s)) | |
| 660 | ||
| 661 | if #clients > 0 then -- Fine grained borders and floaters control | |
| 662 | for _, c in pairs(clients) do -- Floaters always have borders | |
| 663 | if awful.client.floating.get(c) or layout == "floating" then | |
| 664 | c.border_width = beautiful.border_width | |
| 665 | ||
| 666 | -- No borders with only one visible client | |
| 667 | elseif #clients == 1 or layout == "max" then | |
| 668 | clients[1].border_width = 0 | |
| 669 | awful.client.moveresize(0, 0, 2, 2, clients[1]) | |
| 670 | else | |
| 671 | c.border_width = beautiful.border_width | |
| 672 | end | |
| 673 | end | |
| 674 | end | |
| 675 | end) | |
| 676 | end | |
| 677 | -- }}} |