rc.lua 42.6 KB
Newer Older
Maze's avatar
awesome  
Maze committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
-- 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")

-- TODO soru what is gears is a library 
-- 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")

-- {{{ 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
Maze's avatar
Maze committed
26 27 28
    naughty.notify({ preset = naughty.config.presets.critical,
            title = "Oops, there were errors during startup!",
        text = awesome.startup_errors })
Maze's avatar
awesome  
Maze committed
29 30 31 32
end

-- Handle runtime errors after startup
do
Maze's avatar
Maze committed
33 34 35 36 37 38 39 40 41 42 43
    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)
Maze's avatar
awesome  
Maze committed
44 45 46 47 48 49 50 51
end
-- }}}

-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
-- beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
beautiful.init("~/.config/awesome/themes/default/theme.lua")
for s = 1, screen.count() do
Maze's avatar
Maze committed
52
    gears.wallpaper.maximized(beautiful.wallpaper, s, true)
Maze's avatar
awesome  
Maze committed
53 54 55 56
end

-- This is used later as the default terminal and editor to run.
terminal = "urxvt"
Maze's avatar
nvim  
Maze committed
57
editor = os.getenv("EDITOR") or "nvim"
Maze's avatar
awesome  
Maze committed
58 59 60 61 62 63 64 65 66 67 68
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 = {
Maze's avatar
Maze committed
69 70 71 72
    -- awful.layout.suit.floating,
    -- awful.layout.suit.tile,
    awful.layout.suit.fair,
    -- awful.layout.suit.tile.left,
Maze's avatar
Maze committed
73
    -- awful.layout.suit.tile.bottom,
Maze's avatar
Maze committed
74
    -- awful.layout.suit.tile.top,
Maze's avatar
Maze committed
75
    awful.layout.suit.fair.horizontal,
Maze's avatar
Maze committed
76 77 78 79 80 81 82 83 84
    -- 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,
Maze's avatar
awesome  
Maze committed
85 86 87 88 89
}
-- }}}

-- {{{ Menu
-- Create a launcher widget and a main menu
Maze's avatar
Maze committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
-- myawesomemenu = {
--   { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
--   { "manual", terminal .. " -e man awesome" },
--   { "edit config", editor_cmd .. " " .. awesome.conffile },
--   { "restart", awesome.restart },
--   { "quit", function() awesome.quit() end },
-- }

-- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
--       { "open terminal", terminal }
--     }
--   })

-- mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
--   menu = mymainmenu })
Maze's avatar
awesome  
Maze committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118

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

-- Keyboard map indicator and switcher
mykeyboardlayout = awful.widget.keyboardlayout()

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

-- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join(
Maze's avatar
Maze committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    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)
    )
Maze's avatar
awesome  
Maze committed
134 135 136 137



local function nextoccupied(direction)
Maze's avatar
Maze committed
138 139 140 141 142 143 144 145 146 147 148 149
    local screen = awful.screen.focused()
    local tag
    local tagname = screen.selected_tag.name
    repeat
        tagname = tostring(tonumber(tagname)+direction)
        tag = awful.tag.find_by_name(screen, tagname)
        if not tag then
            -- there's nothing left, so I guess not. lel
            break
        end
    until #(tag:clients()) > 0
    return tag
Maze's avatar
awesome  
Maze committed
150 151 152
end

local function makeclear(tagname, direction)
Maze's avatar
Maze committed
153 154 155
    local screen = awful.screen.focused()
    local tag = awful.tag.find_by_name(screen, tagname)
    if not tag then
Maze's avatar
Maze committed
156 157 158 159 160 161 162 163 164
        if screen.index == 3 then
            tag = awful.tag.add(tagname, {
                    layout = awful.layout.suit.fair.horizontal,
                })
        else
            tag = awful.tag.add(tagname, {
                    layout = awful.layout.suit.fair,
                })
        end
Maze's avatar
Maze committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178
    else
        if #(tag:clients()) > 0 then
            -- need to clear out these clients
            -- make the next tag clear
            local nexttagname = tostring(tonumber(tagname)+direction)
            local nexttag = makeclear(nexttagname, direction)
            -- alright now that the next tag is clear,
            -- just swap the names of the two tags, lol
            -- (yes this actually works)
            nexttag.name = "TEMP"
            tag.name = nexttagname
            nexttag.name = tagname
            tag = nexttag
        end
Maze's avatar
awesome  
Maze committed
179
    end
Maze's avatar
Maze committed
180
    return tag
Maze's avatar
awesome  
Maze committed
181 182 183
end

local function insert(direction)
Maze's avatar
Maze committed
184 185 186 187 188 189 190 191 192
    local screen = awful.screen.focused()
    local tagname = screen.selected_tag.name
    local tag = awful.tag.find_by_name(screen, tagname)
    if #(tag:clients()) == 0 then
        return tag
    end
    local nexttagname = tostring(tonumber(tagname)+direction)
    local nexttag = makeclear(nexttagname, direction)
    return nexttag
Maze's avatar
awesome  
Maze committed
193 194
end

Maze's avatar
Maze committed
195
-- minecraft or loe over 3 screens
Maze's avatar
Maze committed
196 197 198 199
local function fullscreens(c)
    awful.client.floating.toggle(c)
    if awful.client.floating.get(c) then
            -- c.fullscreen = true
Maze's avatar
Maze committed
200
            local clientX = screen[1].workarea.x+1920-1080
Maze's avatar
Maze committed
201 202
            local clientY = screen[1].workarea.y
            -- local clientWidth = config.screens * 1920
Maze's avatar
Maze committed
203
            local clientWidth = 1920 + 2 * 1080
Maze's avatar
Maze committed
204 205 206
            -- -- look at http://www.rpm.org/api/4.4.2.2/llimits_8h-source.html
            local clientHeight = 1080
            local t = c:geometry({x = clientX, y = clientY, width = clientWidth, height = clientHeight})
Maze's avatar
awesome  
Maze committed
207
    else
Maze's avatar
Maze committed
208 209
            --apply the rules to this client so he can return to the right tag if there is a rule for that.
            awful.rules.apply(c)
Maze's avatar
awesome  
Maze committed
210
    end
Maze's avatar
Maze committed
211 212 213
    -- focus our client
    client.focus = c
end
Maze's avatar
Maze committed
214

Maze's avatar
awesome  
Maze committed
215

Maze's avatar
Maze committed
216 217 218 219 220 221 222 223 224 225
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}
                )
Maze's avatar
awesome  
Maze committed
226
        end
Maze's avatar
Maze committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
    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.maximized(wallpaper, s, true)
Maze's avatar
Maze committed
247
        end
Maze's avatar
Maze committed
248
    end
Maze's avatar
awesome  
Maze committed
249

Maze's avatar
Maze committed
250 251 252 253 254
    -- 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
Maze's avatar
Maze committed
255
        -- set_wallpaper(s)
Maze's avatar
Maze committed
256 257

        -- Each screen has its own tag table.
Maze's avatar
Maze committed
258 259 260 261 262
        if s.index == 3 then
            awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[2])
        else
            awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
        end
Maze's avatar
Maze committed
263

Maze's avatar
Maze committed
264 265 266 267
        if s.index == 1 then
            awful.tag.add("myfloatingclock", { screen = s, selected = false })
        end

Maze's avatar
Maze committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
        -- 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
Maze's avatar
Maze committed
293
            s.mywibox = awful.wibar({ position = "bottom", screen = s })
Maze's avatar
Maze committed
294
            s.mywibox.visible = false
Maze's avatar
Maze committed
295 296 297
            if s.index == 3 then
                s.mywibox.visible = true
            end
Maze's avatar
Maze committed
298 299 300 301 302 303

            -- Add widgets to the wibox
            s.mywibox:setup {
                layout = wibox.layout.align.horizontal,
                { -- Left widgets
                    layout = wibox.layout.fixed.horizontal,
Maze's avatar
Maze committed
304 305 306
                    -- mylauncher,
                    -- s.mytaglist,
                    -- s.mypromptbox,
Maze's avatar
Maze committed
307
                },
Maze's avatar
Maze committed
308 309
                nil,
                -- s.mytasklist, -- Middle widget
Maze's avatar
Maze committed
310 311 312
                { -- Right widgets
                    layout = wibox.layout.fixed.horizontal,
                    -- mykeyboardlayout,
Maze's avatar
Maze committed
313
                    -- wibox.widget.systray(),
Maze's avatar
Maze committed
314
                    mytextclock,
Maze's avatar
Maze committed
315
                    -- s.mylayoutbox,
Maze's avatar
Maze committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
                },
            }
        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(

            -- DANGER

            awful.key({ modkey, "Shift" }, "grave",
            function () awesome.quit() end),

Maze's avatar
Maze committed
337 338 339
            awful.key({ modkey, "Shift" }, "Insert",
            function () awesome.quit() end),

Maze's avatar
Maze committed
340
            awful.key({ modkey, "Shift" }, "1",
Maze's avatar
Maze committed
341
            function () awful.spawn.with_shell("sleep 1 && systemctl hibernate", false) end),
Maze's avatar
Maze committed
342

Maze's avatar
Maze committed
343
            awful.key({ modkey, "Control", "Shift" }, "1",
Maze's avatar
Maze committed
344
            function () awful.spawn.with_shell("sleep 1 && systemctl hibernate -i", false) end),
Maze's avatar
Maze committed
345

Maze's avatar
Maze committed
346 347 348
            awful.key({ modkey, "Shift" }, "2",
            function () awful.spawn("systemctl reboot", false) end),

Maze's avatar
Maze committed
349 350 351
            awful.key({ modkey, "Control", "Shift" }, "2",
            function () awful.spawn("systemctl reboot -i", false) end),

Maze's avatar
Maze committed
352
            -- force by default, otherwise it is annoying.
Maze's avatar
Maze committed
353
            awful.key({ modkey, "Shift" }, "3", function ()
Maze's avatar
Maze committed
354
                awful.spawn.with_shell("i3lock -i ~/.lockbg.png -t -f -e && sleep 0.5 && systemctl suspend -i", false)
Maze's avatar
Maze committed
355 356
            end),

Maze's avatar
Maze committed
357
            awful.key({ modkey, "Control", "Shift" }, "3", function ()
Maze's avatar
Maze committed
358
                awful.spawn.with_shell("i3lock -i ~/.lockbg.png -t -f -e && sleep 0.5 && systemctl suspend -i", false)
Maze's avatar
Maze committed
359 360
            end),

Maze's avatar
Maze committed
361 362 363
            awful.key({ modkey, "Shift" }, "4",
            function () awful.spawn("systemctl poweroff", false) end),

Maze's avatar
Maze committed
364 365 366
            awful.key({ modkey, "Control", "Shift" }, "4",
            function () awful.spawn("systemctl poweroff -i", false) end),

Maze's avatar
Maze committed
367 368 369 370 371 372
            -- awful.key({ modkey, "Control" }, "s",      hotkeys_popup.show_help,
            --     {description="show help", group="awesome"}),

            awful.key({ modkey, "Control" }, "s", function ()
                awful.spawn("screenlayout", false)
            end),
Maze's avatar
Maze committed
373 374 375 376 377 378 379 380 381 382 383 384 385 386

            awful.key({ modkey }, "i", function()
                local nexttag = nextoccupied(1)
                if nexttag then
                    awful.tag.viewmore({nexttag})
                end
            end,
            {description = "focus next occupied tag", group = "tag"}),

        awful.key({ modkey }, "u", function()
            local nexttag = nextoccupied(-1)
            if nexttag then
                awful.tag.viewmore({nexttag})
            end
Maze's avatar
awesome  
Maze committed
387
        end,
Maze's avatar
Maze committed
388
        {description = "focus prev occupied tag", group = "tag"}),
Maze's avatar
awesome  
Maze committed
389

Maze's avatar
Maze committed
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
    awful.key({ modkey }, "o", function()
        local nexttag = insert(1)
        awful.tag.viewmore({nexttag})
    end,
    {description = "focus next empty tag", group = "tag"}),

awful.key({ modkey }, "y", function()
    local nexttag = insert(-1)
    awful.tag.viewmore({nexttag})
end,
{description = "focus prev empty tag", group = "tag"}),

            awful.key({ modkey, }, "l",      function () awful.screen.focus(awful.screen.focused().index+1) end,
                {description = "move to screen", group = "client"}),

            awful.key({ modkey, }, "h",      function ()
                if awful.screen.focused().index > 1 then
                    awful.screen.focus(awful.screen.focused().index-1)
                end
            end,
            {description = "move to screen", group = "client"}),

        -- 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"}
            ),

Maze's avatar
Maze committed
428 429
        awful.key({ modkey, }, "a",
        function () awful.spawn.with_shell("dmenu-mpd", false) end),
Maze's avatar
Maze committed
430

Maze's avatar
Maze committed
431 432 433 434 435 436
        awful.key({ modkey, }, "g",
        function () awful.spawn("mpc next", false) end),
        awful.key({ modkey, }, "d",
        function () awful.spawn("mpc prev", false) end),
        awful.key({ modkey, }, "s",
        function () awful.spawn("mpc toggle", false) end),
Maze's avatar
awesome  
Maze committed
437 438 439 440

        -- TODO key to turn on unclutter
        -- TODO key to turn off unclutter

Maze's avatar
Maze committed
441
        awful.key({ modkey, }, "semicolon",
Maze's avatar
nvim  
Maze committed
442
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc; env EDITOR=nvim /usr/bin/ranger\"", false) end),
Maze's avatar
awesome  
Maze committed
443

Maze's avatar
Maze committed
444
        awful.key({ modkey, "Control" }, "apostrophe",
Maze's avatar
firefox  
Maze committed
445
        function () awful.spawn("firefox") end),
Maze's avatar
awesome  
Maze committed
446

Maze's avatar
Maze committed
447
        awful.key({ modkey, "Control" }, "w",
Maze's avatar
nvim  
Maze committed
448
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc; env EDITOR=nvim nmtui-connect\"", false) end),
Maze's avatar
awesome  
Maze committed
449

Maze's avatar
Maze committed
450
        awful.key({ modkey, }, "r",
Maze's avatar
awesome  
Maze committed
451
        function () awful.spawn("amixer -c 0 -q set Master 2dB+ unmute", false) end),
Maze's avatar
Maze committed
452
        awful.key({ modkey, }, "e",
Maze's avatar
awesome  
Maze committed
453 454
        function () awful.spawn("amixer -c 0 -q set Master 2dB- unmute", false) end),

Maze's avatar
Maze committed
455
        awful.key({ modkey, }, "p",
Maze's avatar
awesome  
Maze committed
456 457
        function () awful.spawn("passmenu -l 15 -i -fn 'monospace:size=16'", false) end),

Maze's avatar
Maze committed
458
        awful.key({ modkey, "Control" }, "p",
Maze's avatar
Maze committed
459 460 461
        function () awful.spawn("dmenu-octoprint", false) end),

        awful.key({ modkey, "Shift" }, "p",
Maze's avatar
stream  
Maze committed
462
        function ()
Maze's avatar
Maze committed
463
            awful.spawn("mpv \"http://mazieprinter:8080?action=stream\" --no-correct-pts --fps=10", false)
Maze's avatar
stream  
Maze committed
464 465
            awful.spawn("ssh mazieprinter ./bin/rpi-light-on.py", false)
        end),
Maze's avatar
Maze committed
466

Maze's avatar
Maze committed
467
        awful.key({ modkey, "Control" }, "x",
Maze's avatar
Maze committed
468
        function () awful.spawn.with_shell("i3lock -i ~/.lockbg.png -t -f -e", false) end),
Maze's avatar
awesome  
Maze committed
469

Maze's avatar
Maze committed
470
        awful.key({ modkey, }, "v",
Maze's avatar
Maze committed
471
        function () awful.spawn("mpc seek -10", false) end),
Maze's avatar
Maze committed
472
        awful.key({ modkey, }, "b",
Maze's avatar
Maze committed
473
        function () awful.spawn("mpc seek +10", false) end),
Maze's avatar
Maze committed
474 475 476 477
        awful.key({ modkey, "Shift" }, "v",
        function () awful.spawn("mpc seek -60", false) end),
        awful.key({ modkey, "Shift" }, "b",
        function () awful.spawn("mpc seek +60", false) end),
Maze's avatar
Maze committed
478
        awful.key({ modkey, "Control" }, "v",
Maze's avatar
Maze committed
479
        function () awful.spawn("mpc seek -60", false) end),
Maze's avatar
Maze committed
480
        awful.key({ modkey, "Control" }, "b",
Maze's avatar
Maze committed
481
        function () awful.spawn("mpc seek +60", false) end),
Maze's avatar
Maze committed
482
        awful.key({ modkey, "Control", "Shift" }, "v",
Maze's avatar
Maze committed
483
        function () awful.spawn("mpc seek -10%", false) end),
Maze's avatar
Maze committed
484
        awful.key({ modkey, "Control", "Shift" }, "b",
Maze's avatar
Maze committed
485
        function () awful.spawn("mpc seek +10%", false) end),
Maze's avatar
Maze committed
486

Maze's avatar
Maze committed
487 488
        awful.key({ modkey, "Control" }, "bracketleft",
        function () awful.spawn('element-desktop') end),
Maze's avatar
Maze committed
489 490 491 492
        -- awful.key({ modkey, "Control" }, "bracketleft",
        -- function () awful.spawn('xfce4-terminal -e "bash -c \\"source ~/.bashrc; env EDITOR=nvim weechat\\""') end),
        -- awful.key({ modkey, }, "bracketleft",
        -- function () awful.spawn.with_shell('sxiv ~/.avi-weechat.png -fbg 200x200+0-150') end),
Maze's avatar
weechat  
Maze committed
493

Maze's avatar
awesome  
Maze committed
494

Maze's avatar
Maze committed
495
        awful.key({ modkey, "Control" }, "t",
Maze's avatar
awesome  
Maze committed
496 497
        function () awful.spawn("thunderbird") end),

Maze's avatar
Maze committed
498 499 500
        awful.key({ modkey, "Shift" }, "t",
        function () awful.spawn(terminal.." -e htop -d 10", true) end),

Maze's avatar
Maze committed
501 502
        -- awful.key({ modkey, }, "t",
        -- function () awful.spawn("dmenu-termdown", true) end),
Maze's avatar
Maze committed
503

Maze's avatar
Maze committed
504
        awful.key({ modkey, }, "backslash",
Maze's avatar
awesome  
Maze committed
505 506
        function () awful.spawn("txth", false) end),

Maze's avatar
Maze committed
507
        awful.key({ modkey, }, "7",
Maze's avatar
Maze committed
508
        function () awful.spawn("amixer -c 0 -q set Headphone 0db+,0.6db-", false) end),
Maze's avatar
Maze committed
509
        awful.key({ modkey, }, "8",
Maze's avatar
Maze committed
510
        function () awful.spawn("amixer -c 0 -q set Headphone 100%", false) end),
Maze's avatar
Maze committed
511
        awful.key({ modkey, }, "9",
Maze's avatar
Maze committed
512 513
        function () awful.spawn("amixer -c 0 -q set Headphone 0.6db-,0db+", false) end),

Maze's avatar
Maze committed
514 515 516
        awful.key({ modkey, "Control" }, "0",
        function () awful.spawn("mpc seek 0", false) end),
        -- can't have this because it interferes with keyboard layout
Maze's avatar
Maze committed
517 518
        awful.key({ modkey, "Control" }, "minus",
        function () awful.spawn("bash -c \"mpc seek $(shuf -i 0-99 -n 1).$(shuf -i 0-99 -n 1)%\"", false) end),
Maze's avatar
Maze committed
519 520
        -- awful.key({ modkey, "Shift" }, "Delete",
        -- function () awful.spawn.with_shell("mv ~/music/\"$(mpc current -f %file% | cut -d / -f 2)\" ~/musicgraveyard/ && mpc del 0", false) end),
Maze's avatar
awesome  
Maze committed
521

Maze's avatar
Maze committed
522 523 524
        -- don't need this. run cura from ranger directly.
        -- awful.key({ modkey,  }, "c",
        -- function () awful.spawn("cura") end),
Maze's avatar
awesome  
Maze committed
525

Maze's avatar
Maze committed
526 527
        -- awful.key({ modkey,  }, "n",
        -- function () awful.spawn("waterfox \"https://mynoise.net/clone.php?url=%2FNoiseMachines%2FthunderNoiseGenerator.php%3Fc%3D1%26l%3D00404040404040404040%26a%3D1%26am%3D1%26m%3D%26d%3D0\"") end),
Maze's avatar
mynoise  
Maze committed
528

Maze's avatar
Maze committed
529 530 531
        awful.key({ modkey,  }, "m",
        function () awful.spawn("dmenu-mount") end),

Maze's avatar
"  
Maze committed
532
        awful.key({ modkey, "Control" }, "m",
Maze's avatar
Maze committed
533 534
        function () awful.spawn("dmenu-unmount") end),

Maze's avatar
"  
Maze committed
535
        awful.key({ modkey, "Control" }, "q",
Maze's avatar
Maze committed
536 537 538
        function () awful.screen.focused().mywibox.visible = true end,
        function () awful.screen.focused().mywibox.visible = false end),

Maze's avatar
Maze committed
539 540
        awful.key({ modkey,  }, "0",
            -- TODO use ~
Maze's avatar
Maze committed
541
        function () awful.spawn(terminal.." -cd /home/maze/cd/d", false) end),
Maze's avatar
awesome  
Maze committed
542

Maze's avatar
Maze committed
543
        awful.key({ modkey,  }, "1",
Maze's avatar
awesome  
Maze committed
544 545
        function () awful.spawn(terminal.." -cd /usr/share/X11/xkb/symbols", false) end),

Maze's avatar
Maze committed
546
        awful.key({ modkey,  }, "2",
Maze's avatar
nvim  
Maze committed
547
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc && nvim ~/.config/awesome/rc.lua\"", false) end), 
Maze's avatar
Maze committed
548
        awful.key({ modkey,  }, "3",
Maze's avatar
nvim  
Maze committed
549
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc && nvim ~/.config/awesome/autorun.sh\"", false) end), 
Maze's avatar
Maze committed
550
        awful.key({ modkey,  }, "4",
Maze's avatar
nvim  
Maze committed
551
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc && nvim ~/.vimrc\"", false) end), 
Maze's avatar
Maze committed
552
        awful.key({ modkey,  }, "5",
Maze's avatar
nvim  
Maze committed
553
        function () awful.spawn(terminal.." -e bash -c \"source ~/.bashrc && nvim ~/.config/ranger/rc.conf\"", false) end), 
Maze's avatar
awesome  
Maze committed
554

Maze's avatar
Maze committed
555
        awful.key({ modkey, "Control" }, "g",
Maze's avatar
awesome  
Maze committed
556 557
        function () awful.spawn("gimp") end),

Maze's avatar
Maze committed
558
        awful.key({ modkey, "Control" }, "bracketright",
Maze's avatar
Maze committed
559
        function () awful.spawn("loe-dmenu") end),
Maze's avatar
Maze committed
560
        awful.key({ modkey,  }, "Home",
Maze's avatar
Maze committed
561
        function () awful.spawn.with_shell("xdotool getactivewindow >> ~/.marked_loe_windows && notify-send \"$(cat ~/.marked_loe_windows)\"") end),
Maze's avatar
Maze committed
562
        awful.key({ modkey,  }, "End",
Maze's avatar
Maze committed
563
        function () awful.spawn.with_shell("rm ~/.marked_loe_windows && notify-send \"removed ~/.marked_loe_windows\"") end),
Maze's avatar
Maze committed
564

Maze's avatar
Maze committed
565
        awful.key({ modkey,  }, "KP_Subtract",
Maze's avatar
Maze committed
566
        function () awful.spawn.with_shell("sudo /sbin/ifconfig enp4s0 down && sleep 14 && sudo /sbin/ifconfig enp4s0 up") end),
Maze's avatar
Maze committed
567 568
        awful.key({ modkey, "Shift" }, "minus",
        function () awful.spawn.with_shell("sudo /sbin/ifconfig enp4s0 down && sleep 14 && sudo /sbin/ifconfig enp4s0 up") end),
Maze's avatar
Maze committed
569

Maze's avatar
Maze committed
570 571
        awful.key({ modkey,  }, "KP_Add",
        function () awful.spawn.with_shell("sudo /sbin/ifconfig enp4s0 down && sleep 8 && sudo /sbin/ifconfig enp4s0 up") end),
Maze's avatar
Maze committed
572
        awful.key({ modkey, "Shift" }, "backslash",
Maze's avatar
Maze committed
573
        function () awful.spawn.with_shell("sudo /sbin/ifconfig enp4s0 down && sleep 8 && sudo /sbin/ifconfig enp4s0 up") end),
Maze's avatar
Maze committed
574

Maze's avatar
Maze committed
575 576
        -- awful.key({ modkey,  }, "KP_Add",
        --   function () awful.spawn("sudo /sbin/ifconfig enp4s0 up") end),
Maze's avatar
awesome  
Maze committed
577

Maze's avatar
Maze committed
578 579
        -- awful.key({ modkey, "Control" }, "n",
        --   function () awful.spawn("sudo systemctl restart NetworkManager") end),
Maze's avatar
Maze committed
580

Maze's avatar
Maze committed
581
        awful.key({ modkey,  }, "bracketright",
Maze's avatar
Maze committed
582
          function () awful.spawn("rofimoji -c -s neutral") end),
Maze's avatar
Maze committed
583

Maze's avatar
Maze committed
584 585
        -- awful.key({ modkey,  }, "d",
        --   function () awful.spawn("killall dragon-drag-and-drop") end),
Maze's avatar
Maze committed
586

Maze's avatar
Maze committed
587 588
        -- awful.key({ modkey, }, "w",
        --   function () awful.spawn.with_shell("matrix_decrypt \"$(xclip -o)\"") end),
Maze's avatar
Maze committed
589

Maze's avatar
Maze committed
590 591 592
        awful.key({ }, "F13",
          function () awful.spawn("xdotool keyup F13 key ctrl+z") end),

Maze's avatar
Maze committed
593 594 595 596
        awful.key({ }, "Menu",
            function ()
                s = screen[1]
                t = awful.tag.find_by_name(s,"myfloatingclock")
Maze's avatar
Maze committed
597 598 599
                selected = s.selected_tags
                if selected[2] == nil then
                    awful.tag.viewtoggle(t)
Maze's avatar
Maze committed
600 601
                    clockclient = t:clients()[1]
                    awful.placement.centered(clockclient)
Maze's avatar
Maze committed
602 603 604
                end
            end
            ,
Maze's avatar
Maze committed
605 606 607
            function ()
                s = screen[1]
                t = awful.tag.find_by_name(s,"myfloatingclock")
Maze's avatar
Maze committed
608 609 610 611 612 613
                selected = s.selected_tags
                if selected[2] ~= nil then
                    awful.tag.viewtoggle(t)
                end
            end
            ),
Maze's avatar
Maze committed
614

Maze's avatar
3dh  
Maze committed
615 616
        awful.key({ modkey, }, "period",
        function () awful.spawn("3dh", false) end),
Maze's avatar
Maze committed
617

Maze's avatar
no obs  
Maze committed
618 619
        -- awful.key({ modkey, "Control"   }, "b",
        -- function () awful.spawn("obs-launch-shenanigans", false) end),
Maze's avatar
Maze committed
620 621


Maze's avatar
awesome  
Maze committed
622 623 624 625 626 627 628 629







        -- this was the meh menu that spawns on the mouse, eww
Maze's avatar
Maze committed
630 631 632 633 634
        -- awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
        --   {description = "show main menu", group = "awesome"}),

        -- Layout manipulation
        -- TODO ctrl instead of shift
Maze's avatar
Maze committed
635 636
        awful.key({ modkey, "Control"   }, "j", function () awful.client.swap.byidx(  1)    end,
            {description = "swap with next client by index", group = "client"}),
Maze's avatar
Maze committed
637 638
        awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end,
            {description = "swap with next client by index", group = "client"}),
Maze's avatar
Maze committed
639 640
        awful.key({ modkey, "Control"   }, "k", function () awful.client.swap.byidx( -1)    end,
            {description = "swap with previous client by index", group = "client"}),
Maze's avatar
Maze committed
641 642
        awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end,
            {description = "swap with previous client by index", group = "client"}),
Maze's avatar
Maze committed
643 644 645 646 647
        -- TODO change screen switching to something else as ctrl will be taken
        -- TODO ok I changed shift to ctrl above, but here it needs to be shift then
        -- TODO but if screen switch is on j and k, how do you send windows to other screen? doesn't fit! It has to be something else and without modifier, so that sending windows can be with ctrl and that.
        -- TODO same as previous comment applies to switching workspaces. Which definitely shouldn't be on arrows btw.
        -- TODO o is for moving window to screen in 1 direction, need another key for other direction
Maze's avatar
Maze committed
648 649 650 651
        -- awful.key({ modkey, "Shift" }, "j", function () awful.screen.focus_relative( 1) end,
        --     {description = "focus the next screen", group = "screen"}),
        -- awful.key({ modkey, "Shift" }, "k", function () awful.screen.focus_relative(-1) end,
        --     {description = "focus the previous screen", group = "screen"}),
Maze's avatar
Maze committed
652 653 654
        -- TODO maybe remove this to free up U for workspace switching
        -- awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
        -- {description = "jump to urgent client", group = "client"}),
Maze's avatar
Maze committed
655 656 657 658 659 660 661 662
        -- awful.key({ modkey,           }, "Tab",
        --     function ()
        --         awful.client.focus.history.previous()
        --         if client.focus then
        --             client.focus:raise()
        --         end
        --     end,
        --     {description = "go back", group = "client"}),
Maze's avatar
Maze committed
663 664 665 666 667 668 669

        -- Standard program
        awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
            {description = "open a terminal", group = "launcher"}),
        -- TODO don't change restart button because this is important. same for quit
        awful.key({ modkey, "Control" }, "r", awesome.restart,
            {description = "reload awesome", group = "awesome"}),
Maze's avatar
Maze committed
670 671
        -- awful.key({ modkey, "Shift"   }, "q", awesome.quit,
        --     {description = "quit awesome", group = "awesome"}),
Maze's avatar
Maze committed
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689

        -- -- TODO resize is perhaps not important enough to be on h and l
        -- 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"}),
        -- -- TODO I guess this is important enough so maybe keep defaults? idk
        -- -- TODO soru doesn't use
        -- 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"}),
        -- -- TODO alright so with shift it's changing master count, with ctrl it's changing column count. really. omg. this is so confusing. why. gah guess I'll keep it for now
        -- -- TODO soru doesn't use
        -- 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"}),
Maze's avatar
Maze committed
690 691
        -- -- TODO as there's a fixed number of possible layouts, absolute navigation would maybe be better in this case. Not sure though. Anyway space is a strange key to bind this to. So I changed it to c.
        awful.key({ modkey,           }, "c", function () awful.layout.inc( 1)                end,
Maze's avatar
Maze committed
692
            {description = "select next", group = "layout"}),
Maze's avatar
Maze committed
693 694
        -- awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
        --     {description = "select previous", group = "layout"}),
Maze's avatar
Maze committed
695 696

        -- TODO why is there minimizing in a tiled wm, what an abomination. Consider removing this functionality
Maze's avatar
Maze committed
697 698 699 700 701 702 703 704 705 706 707
        -- 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"}),
Maze's avatar
Maze committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727

        -- Prompt
        -- awful.key({ modkey, "Control" },            "d",     function () awful.screen.focused().mypromptbox:run() end,
        --   {description = "run prompt", group = "launcher"}),

        -- 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
        -- soru doesn't use this menu. I won't use it either
        -- awful.key({ modkey }, "p", function() menubar.show() end,
        --   {description = "show the menubar", group = "launcher"}),

Maze's avatar
Maze committed
728
        awful.key({modkey, }, "Print",
Maze's avatar
.s.png  
Maze committed
729
        function () awful.spawn.with_shell('sxiv ~/.s.png') end),
Maze's avatar
Maze committed
730

Maze's avatar
Maze committed
731
        awful.key({ }, "Print",
Maze's avatar
Maze committed
732 733 734 735 736 737
            function () awful.spawn("dmenu-scrot ~/pict/scr/", false) end,
            {description = "dmenu-scrot", group = "launcher"}),
        awful.key({ modkey,  "Control"}, "Print",
        function () awful.spawn("publish-last-scr", false) end),
        awful.key({ modkey,  "Control"}, "F12",
        function () awful.spawn("publish-last-loe", false) end)
Maze's avatar
Maze committed
738 739

        )
Maze's avatar
awesome  
Maze committed
740 741 742 743

    -- TODO soru why are two separate lists of keys and which one should I add to??
    -- this list is for modifying clients. The previous one is for awesome itself.
    clientkeys = gears.table.join(
Maze's avatar
nvim  
Maze committed
744

Maze's avatar
Maze committed
745
        awful.key({ modkey,  }, "f",
Maze's avatar
Maze committed
746
            function (c)
Maze's avatar
nvim  
Maze committed
747
                c.maximized = false
Maze's avatar
Maze committed
748 749 750 751 752
                c.fullscreen = not c.fullscreen
                c:raise()
            end,
            {description = "toggle fullscreen", group = "client"}),

Maze's avatar
Maze committed
753 754 755 756 757 758
        awful.key({ modkey, "Shift" }, "bracketleft",
            function (c)
                c.fullscreen = false
                c:raise()
                awful.client.floating.toggle(c)
                c.ontop = true
Maze's avatar
Maze committed
759
                awful.client.focus.byidx(1)
Maze's avatar
Maze committed
760 761 762
            end
            ),

Maze's avatar
Maze committed
763 764 765 766 767 768 769 770 771 772 773 774 775
        -- awful.key({ modkey, "Control" }, "i", function (c)
        --   local s = awful.screen.focused()
        --   local tagname = c.first_tag.name
        --   local nexttagname = tostring(tonumber(tagname)+1)
        --   local nexttag = awful.tag.find_by_name(s, nexttagname)
        --   if not nexttag then
        --     nexttag = awful.tag.add(nexttagname)
        --   end
        --   c:move_to_tag(nexttag)
        -- end,
        -- {description = "move to next", group = "tag"}),

        awful.key({ modkey, "Control" }, "i", function(c)
Maze's avatar
awesome  
Maze committed
776 777
        local nexttag = nextoccupied(1)
        if nexttag then
Maze's avatar
Maze committed
778
        c:move_to_tag(nexttag)
Maze's avatar
awesome  
Maze committed
779
        end
Maze's avatar
Maze committed
780 781
        end,
        {description = "move to next occupied tag", group = "tag"}),
Maze's avatar
awesome  
Maze committed
782

Maze's avatar
Maze committed
783 784 785 786 787 788 789 790
        awful.key({ modkey, "Shift" }, "i", function(c)
        local nexttag = nextoccupied(1)
        if nexttag then
        c:move_to_tag(nexttag)
        end
        end,
        {description = "move to next occupied tag", group = "tag"}),

Maze's avatar
Maze committed
791
        awful.key({ modkey, "Control" }, "u", function(c)
Maze's avatar
awesome  
Maze committed
792 793
        local nexttag = nextoccupied(-1)
        if nexttag then
Maze's avatar
Maze committed
794
        c:move_to_tag(nexttag)
Maze's avatar
awesome  
Maze committed
795
        end
Maze's avatar
Maze committed
796 797
        end,
        {description = "move to prev occupied tag", group = "tag"}),
Maze's avatar
awesome  
Maze committed
798

Maze's avatar
Maze committed
799 800 801 802 803 804 805 806
        awful.key({ modkey, "Shift" }, "u", function(c)
        local nexttag = nextoccupied(-1)
        if nexttag then
        c:move_to_tag(nexttag)
        end
        end,
        {description = "move to prev occupied tag", group = "tag"}),

Maze's avatar
Maze committed
807
        awful.key({ modkey, "Control" }, "o", function(c)
Maze's avatar
awesome  
Maze committed
808 809
        local nexttag = insert(1)
        c:move_to_tag(nexttag)
Maze's avatar
Maze committed
810 811
        end,
        {description = "move to next empty tag", group = "tag"}),
Maze's avatar
awesome  
Maze committed
812

Maze's avatar
Maze committed
813 814 815 816 817 818
        awful.key({ modkey, "Shift" }, "o", function(c)
        local nexttag = insert(1)
        c:move_to_tag(nexttag)
        end,
        {description = "move to next empty tag", group = "tag"}),

Maze's avatar
Maze committed
819 820 821 822 823 824
        awful.key({ modkey, "Control" }, "y", function(c)
        local nexttag = insert(-1)
        c:move_to_tag(nexttag)
        end,
        {description = "move to prev empty tag", group = "tag"}),

Maze's avatar
Maze committed
825 826 827 828 829 830
        awful.key({ modkey, "Shift" }, "y", function(c)
        local nexttag = insert(-1)
        c:move_to_tag(nexttag)
        end,
        {description = "move to prev empty tag", group = "tag"}),

Maze's avatar
Maze committed
831 832
        awful.key({ modkey, "Control" }, "l",      function (c) c:move_to_screen(c.screen.index+1)               end,
        {description = "move to screen", group = "client"}),
Maze's avatar
Maze committed
833 834
        awful.key({ modkey, "Shift" }, "l",      function (c) c:move_to_screen(c.screen.index+1)               end,
        {description = "move to screen", group = "client"}),
Maze's avatar
Maze committed
835 836 837

        awful.key({ modkey, "Control" }, "h",      function (c) c:move_to_screen(c.screen.index-1)               end,
        {description = "move to screen", group = "client"}),
Maze's avatar
Maze committed
838 839 840
        awful.key({ modkey, "Shift" }, "h",      function (c) c:move_to_screen(c.screen.index-1)               end,
        {description = "move to screen", group = "client"}),

Maze's avatar
Maze committed
841 842 843

        awful.key({ modkey,           }, "q",      function (c) c:kill()                         end,
        {description = "close", group = "client"}),
Maze's avatar
Maze committed
844 845
        awful.key({ modkey,  }, "w",  awful.client.floating.toggle                     ,
        {description = "toggle floating", group = "client"}),
Maze's avatar
Maze committed
846 847 848 849 850 851
        -- TODO ask soru what this does move to next screen
        -- 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"}),
        -- TODO still can't think of why I'd minimize windows
Maze's avatar
Maze committed
852 853 854 855 856 857 858
        -- 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"}),
Maze's avatar
Maze committed
859
        -- TODO why would I ever maximize instead of fullscreen, what is difference if you are not using the statusbar, windowbar and borders? look at statusbar and see what all it adds
Maze's avatar
Maze committed
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
        -- 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"}),
Maze's avatar
awesome  
Maze committed
878

Maze's avatar
Maze committed
879 880 881
        awful.key({ modkey,  }, "Next", function (c)
        fullscreens(c)
        end)
Maze's avatar
awesome  
Maze committed
882

Maze's avatar
Maze committed
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907
        )

        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 = { },
Maze's avatar
Maze committed
908
        properties = { border_width = 1,
Maze's avatar
awesome  
Maze committed
909 910 911 912 913 914 915 916 917
        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,
        -- do not match to perfect character size:
        size_hints_honor = false
Maze's avatar
Maze committed
918 919
        }
        },
Maze's avatar
awesome  
Maze committed
920

Maze's avatar
Maze committed
921 922
        { rule_any = {
            class = {
Maze's avatar
firefox  
Maze committed
923
                "Firefox",
Maze's avatar
Maze committed
924
                "MuPDF",
Maze's avatar
Maze committed
925 926 927 928 929
            }
        },
        properties = { border_width = 1}
        },

Maze's avatar
Maze committed
930
        { rule_any = {
Maze's avatar
Maze committed
931 932 933
            name = {
            "Legends of Equestria",
            }
Maze's avatar
Maze committed
934
        }, properties = {border_width = 0, floating = false }},
Maze's avatar
Maze committed
935 936 937 938 939 940

        -- cura floating by default
        { rule_any = {
        name = {
        "Ultimaker Cura",
        }
Maze's avatar
Maze committed
941
        }, properties = { maximized = true }},
Maze's avatar
Maze committed
942

Maze's avatar
Maze committed
943 944 945 946 947 948 949
        -- my floating clock options
        { rule_any = {
        name = {
        "floatingwindow",
        }
        }, properties = { floating = true, ontop = true, height = 250, width=1918}},

Maze's avatar
Maze committed
950 951 952 953 954
        -- my floating clock options
        { rule_any = {
        name = {
        "myfloatingclock",
        }
Maze's avatar
Maze committed
955
        }, properties = { floating = true, height = 50, width = 160, ontop = true, screen = 1, tag = "myfloatingclock", border_width = 0 }},
Maze's avatar
Maze committed
956

Maze's avatar
Maze committed
957 958 959 960 961 962 963
        -- dragon always on top
        { rule_any = {
        name = {
        "dragon",
        }
        }, properties = { ontop = true }},

Maze's avatar
Maze committed
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
        -- Floating clients.
        -- { rule_any = {
        --     instance = {
        --       "DTA",  -- Firefox addon DownThemAll.
        --       "copyq",  -- Includes session name in class.
        --       "pinentry",
        --     },
        --     class = {
        --       "Blueman-manager",
        --       "Gpick",
        --       "Kruler",
        --       "MessageWin",  -- kalarm.
        --       "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 }},

Maze's avatar
Maze committed
992 993 994 995 996
        -- -- Add titlebars to normal clients and dialogs
        -- { rule_any = {type = { "normal", "dialog" }
        -- -- I changed this to false. Later, I totally commented out the paragraph.
        -- }, properties = { titlebars_enabled = false }
        -- },
Maze's avatar
awesome  
Maze committed
997

Maze's avatar
Maze committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
        -- 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()
Maze's avatar
awesome  
Maze committed
1024 1025
        c:emit_signal("request::activate", "titlebar", {raise = true})
        awful.mouse.client.move(c)
Maze's avatar
Maze committed
1026 1027
        end),
        awful.button({ }, 3, function()
Maze's avatar
awesome  
Maze committed
1028 1029
        c:emit_signal("request::activate", "titlebar", {raise = true})
        awful.mouse.client.resize(c)
Maze's avatar
Maze committed
1030 1031
        end)
        )
Maze's avatar
awesome  
Maze committed
1032

Maze's avatar
Maze committed
1033 1034
        awful.titlebar(c) : setup {
        { -- Left
Maze's avatar
awesome  
Maze committed
1035 1036 1037
        awful.titlebar.widget.iconwidget(c),
        buttons = buttons,
        layout  = wibox.layout.fixed.horizontal
Maze's avatar
Maze committed
1038 1039
        },
        { -- Middle
Maze's avatar
awesome  
Maze committed
1040
        { -- Title
Maze's avatar
Maze committed
1041 1042
        align  = "center",
        widget = awful.titlebar.widget.titlewidget(c)
Maze's avatar
awesome  
Maze committed
1043 1044 1045
        },
        buttons = buttons,
        layout  = wibox.layout.flex.horizontal
Maze's avatar
Maze committed
1046 1047
        },
        { -- Right
Maze's avatar
awesome  
Maze committed
1048 1049 1050 1051 1052 1053
        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()
Maze's avatar
Maze committed
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
        },
        layout = wibox.layout.align.horizontal
        }
        end)

        -- Enable lazy sloppy focus, so that focus follows mouse.
        client.connect_signal("mouse::enter", function(c)
        c:emit_signal("request::activate", "mouse_enter", {raise = false})
        end)

Maze's avatar
Maze committed
1064 1065 1066 1067 1068 1069 1070
        client.connect_signal("focus", function(c)
            if(c.name == "Legends of Equestria") then
                c.border_color = "#ffffff"
            else
                c.border_color = beautiful.border_focus
            end
        end)
Maze's avatar
Maze committed
1071 1072 1073 1074 1075
        client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
        -- }}}

        -- Autostart stuff
        awful.spawn.with_shell("~/.config/awesome/autorun.sh")
Maze's avatar
Maze committed
1076