Guest User

Untitled

a guest
Feb 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.19 KB | None | 0 0
  1.  
  2. Welcome to Steve Jobs's Awesome-wm config. Listed below is are the important keybindings that differ from the defaults. Underneath is the file itself.
  3.  
  4.  
  5. Goodies:
  6. -toggle maximized as layout, not just for a single window
  7. -xtra mode for less important windows
  8. -dmenu with ability to switch to searched window
  9. -bin tag
  10. -undo minimize
  11.  
  12.  
  13. How to install:
  14. -Install Awesome-wm. Derp.
  15. -Replace /etc/xdg/awesome/rc.lua with the contents below
  16. -Mod + Ctrl + r to reload Awesome
  17.  
  18.  
  19. Description / bindings
  20.  
  21. Awesome has two ways of maximizing windows: through a layout, and by putting a maximize flag on the active window. The former has the advantage of not being set to a specific window. This way, you can use mod + j/k to go through windows maxmized. The latter has another advantage: you can toggle it on and off with the same binding. This config takes both these advantages: you can toggle on and off as a layout, not just for single windows.
  22.  
  23. In Awesome, while multiple tags are selected, it uses the layout of the leftmost selected tag. That's why the first tag is reserved for the 'max' layout. With one keybinding (mod+f), you can toggle the tag on/off, thus toggling its layout. You're not supposed to open windows in it, though it can't do harm either. The next 6 tags are your main workspaces. Evens have tile.bottom and odds have tile by default.
  24.  
  25. The next tag is called 'bin', which simulates an option to undo closing a window. The last tag is called 'xtra' and functions as a place for less important windows. You can send a window there with mod+g and toggle the tag with mod+space.
  26.  
  27. mod + f         toggle max
  28. mod + i         send window to bin
  29. mod + backspace     kill window
  30. mod + g         send window to xtra
  31. mod + space     toggle xtra
  32. mod + j/k       focus next/previous window, regardless of whether max is enabled
  33.  
  34.  
  35. If a window will be used more, you might want to send it from xtra to whatever tag you're using. Sending a window to a tag is more accessible with this config:
  36.  
  37. mod + #         send window to #
  38. mod + s/d       go to previous/next tag
  39.  
  40.  
  41. Besides the use of xtra and bin, this config still allows you to minimize windows. In fact, it has extended support for it:
  42.  
  43. mod + v         minimize window
  44. mod + c         restore last minimized window
  45.  
  46.  
  47. Steve Jobs prefers to have a few important windows in a tag with the rest in xtra. While xtra is on, he wants the important windows to be master windows. This config makes multiple master windows easier:
  48.  
  49. mod + n/m       increase/decrease number of master windows
  50. mod + ;/'       increase/decrease focused window's size compared to other masters/slaves
  51. mod + h/l       increase/decrease master/slave area size
  52.  
  53. However, resizing might be easier with mod + right click dragging
  54.  
  55.  
  56. mod + p         open dmenu
  57.  
  58. When you open a program with dmenu, it will first check if there already is an instance of that program. If there is, it will go to that window instead of opening a new instance. This way, you can also use dmenu to switch between windows/tags. If you want to open another instance, use mod + r.
  59.  
  60.  
  61. Other stuff:
  62.  
  63. mod + return        make focused window master
  64. mod+shift + return  open terminal
  65. mod+shift + #       go to #
  66. mod+shift + n/m     next/previous layout
  67.  
  68.  
  69. If you prefer fullscreen over maximized, that layout is still left in. You can switch to it manually in the max tag, or change
  70.   layout = { layouts[1], layouts[3], layouts[4], layouts[3], layouts[4],
  71.              layouts[3], layouts[4], layouts[2], layouts[2]
  72. in the config file to
  73.   layout = { layouts[5], layouts[3], layouts[4], layouts[3], layouts[4],
  74.              layouts[3], layouts[4], layouts[2], layouts[2]
  75.  
  76.  
  77. Near the end in the config, you will see the line:
  78. run_once("firefox")
  79.  
  80. This will run firefox on startup. Feel free to add other programs there. Firefox was used for the example because every valid person uses Firefox.
  81.  
  82.  
  83. THE FILE IS BELOW
  84.  
  85. -- Standard awesome library
  86. require("awful")
  87. require("awful.autofocus")
  88. require("awful.rules")
  89. -- Theme handling library
  90. require("beautiful")
  91. -- Notification library
  92. require("naughty")
  93.  
  94. -- Load Debian menu entries
  95. require("debian.menu")
  96.  
  97. -- {{{ Variable definitions
  98. -- Themes define colours, icons, and wallpapers
  99. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  100.  
  101. -- This is used later as the default terminal and editor to run.
  102. terminal = "x-terminal-emulator"
  103. editor = os.getenv("EDITOR") or "editor"
  104. editor_cmd = terminal .. " -e " .. editor
  105.  
  106. -- Default modkey.
  107. -- Usually, Mod4 is the key with a logo between Control and Alt.
  108. -- If you do not like this or do not have such a key,
  109. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  110. -- However, you can use another modifier like Mod1, but it may interact with others.
  111. modkey = "Mod4"
  112.  
  113. -- Table of layouts to cover with awful.layout.inc, order matters.
  114. layouts =
  115. {
  116.   awful.layout.suit.max,
  117.   awful.layout.suit.fair,
  118.   awful.layout.suit.tile.bottom,
  119.   awful.layout.suit.tile,
  120.   awful.layout.suit.max.fullscreen
  121. }
  122. -- }}}
  123.  
  124. -- {{{ Tags
  125. tags = {
  126.   names  = { "max", 2, 3, 4, 5, 6, 7, "bin", "xtra"},
  127.   layout = { layouts[1], layouts[3], layouts[4], layouts[3], layouts[4],
  128.              layouts[3], layouts[4], layouts[2], layouts[2]
  129. }}
  130.  
  131. for s = 1, screen.count() do
  132.     tags[s] = awful.tag(tags.names, s, tags.layout)
  133. end
  134. -- }}}
  135.  
  136. -- {{{ Menu
  137. -- Create a laucher widget and a main menu
  138. myawesomemenu = {
  139.   { "manual", terminal .. " -e man awesome" },
  140.   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  141.   { "restart", awesome.restart },
  142.   { "quit", awesome.quit }
  143. }
  144.  
  145. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  146.                                    { "Debian", debian.menu.Debian_menu.Debian },
  147.                                    { "open terminal", terminal }
  148.                                  }
  149.                        })
  150.  
  151. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  152.                                     menu = mymainmenu })
  153. -- }}}
  154.  
  155. -- {{{ Wibox
  156. -- Create a textclock widget
  157. mytextclock = awful.widget.textclock({ align = "right" })
  158.  
  159. -- Create a systray
  160. mysystray = widget({ type = "systray" })
  161.  
  162. -- Create a wibox for each screen and add it
  163. mywibox = {}
  164. mypromptbox = {}
  165. mylayoutbox = {}
  166. mytaglist = {}
  167. mytaglist.buttons = awful.util.table.join(
  168.                    awful.button({ }, 1, awful.tag.viewonly),
  169.                    awful.button({ modkey }, 1, awful.client.movetotag),
  170.                    awful.button({ }, 3, awful.tag.viewtoggle),
  171.                    awful.button({ modkey }, 3, awful.client.toggletag),
  172.                    awful.button({ }, 4, awful.tag.viewnext),
  173.                    awful.button({ }, 5, awful.tag.viewprev)
  174.                    )
  175. mytasklist = {}
  176. mytasklist.buttons = awful.util.table.join(
  177.                     awful.button({ }, 1, function (c)
  178.                                              if not c:isvisible() then
  179.                                                  awful.tag.viewonly(c:tags()[1])
  180.                                              end
  181.                                              client.focus = c
  182.                                              c:raise()
  183.                                          end),
  184.                     awful.button({ }, 3, function ()
  185.                                              if instance then
  186.                                                  instance:hide()
  187.                                                  instance = nil
  188.                                              else
  189.                                                  instance = awful.menu.clients({ width=250 })
  190.                                              end
  191.                                          end),
  192.                     awful.button({ }, 4, function ()
  193.                                              awful.client.focus.byidx(1)
  194.                                              if client.focus then client.focus:raise() end
  195.                                          end),
  196.                     awful.button({ }, 5, function ()
  197.                                              awful.client.focus.byidx(-1)
  198.                                              if client.focus then client.focus:raise() end
  199.                                          end))
  200.  
  201. for s = 1, screen.count() do
  202.    -- Create a promptbox for each screen
  203.    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  204.    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  205.     -- We need one layoutbox per screen.
  206.     mylayoutbox[s] = awful.widget.layoutbox(s)
  207.     mylayoutbox[s]:buttons(awful.util.table.join(
  208.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  209.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  210.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  211.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  212.     -- Create a taglist widget
  213.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  214.  
  215.     -- Create a tasklist widget
  216.     mytasklist[s] = awful.widget.tasklist(function(c)
  217.                                               return awful.widget.tasklist.label.currenttags(c, s)
  218.                                           end, mytasklist.buttons)
  219.  
  220.     -- Create the wibox
  221.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  222.     -- Add widgets to the wibox - order matters
  223.     mywibox[s].widgets = {
  224.         {
  225.             mylauncher,
  226.             mytaglist[s],
  227.             mypromptbox[s],
  228.             layout = awful.widget.layout.horizontal.leftright
  229.         },
  230.         mylayoutbox[s],
  231.         mytextclock,
  232.         s == 1 and mysystray or nil,
  233.         mytasklist[s],
  234.         layout = awful.widget.layout.horizontal.rightleft
  235.     }
  236. end
  237. -- }}}
  238.  
  239. -- {{{ Mouse bindings
  240. root.buttons(awful.util.table.join(
  241.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  242.     awful.button({ }, 4, awful.tag.viewnext),
  243.     awful.button({ }, 5, awful.tag.viewprev)
  244. ))
  245. -- }}}
  246.  
  247. -- {{{ Key bindings
  248. globalkeys = awful.util.table.join(
  249.  
  250. -- Run or raise applications with dmenu
  251.     awful.key({ modkey }, "p",
  252.     function ()
  253.        local f_reader = io.popen( "dmenu_path | dmenu -b -nb '"..
  254.     beautiful.bg_normal .."' -nf '".. beautiful.fg_normal .."' -sb      '#955'")
  255.       local command = assert(f_reader:read('*a'))
  256.       f_reader:close()
  257.       if command == "" then return end
  258.  
  259. -- Check throught the clients if the class match the command
  260.    local lower_command=string.lower(command)
  261.    for k, c in pairs(client.get()) do
  262.        local class=string.lower(c.class)
  263.        if string.match(class, lower_command) then
  264.            for i, v in ipairs(c:tags()) do
  265.                awful.tag.viewonly(v)
  266.                c:raise()
  267.                c.minimized = false
  268.                return
  269.            end
  270.        end
  271.    end
  272.    awful.util.spawn(command)
  273. end),
  274.  
  275. -- Mod + c = unminimize
  276.    awful.key({ modkey,        }, "c",
  277.        function ()
  278.            local allclients = client.get(mouse.screen)
  279.  
  280.            for _,c in ipairs(allclients) do
  281.                if c.minimized and c:tags()[mouse.screen] ==
  282. awful.tag.selected(mouse.screen) then
  283.                    c.minimized = false
  284.                    client.focus = c
  285.                    c:raise()
  286.                    return
  287.                end
  288.            end
  289.        end),
  290.  
  291.     awful.key({ modkey,           }, "f",  
  292.                   function ()
  293.                       local screen = mouse.screen
  294.                       if tags[screen] then
  295.                           awful.tag.viewtoggle(tags[screen][1])
  296.                       end
  297.                   end),
  298.  
  299.     awful.key({ modkey,           }, "space",
  300.                   function ()
  301.                       local screen = mouse.screen
  302.                       if tags[screen] then
  303.                           awful.tag.viewtoggle(tags[screen][9])
  304.                       end
  305.                   end),
  306.  
  307.     awful.key({ modkey,           }, "g",
  308.                   function ()
  309.                       if client.focus and tags[client.focus.screen] then
  310.                           awful.client.movetotag(tags[client.focus.screen][9])
  311.                       end
  312.                   end),
  313.  
  314.     awful.key({ modkey,           }, "i",
  315.                   function ()
  316.                       if client.focus and tags[client.focus.screen] then
  317.                           awful.client.movetotag(tags[client.focus.screen][8])
  318.                       end
  319.                   end),
  320.  
  321.    awful.key({ modkey,         }, ";", function () awful.client.incwfact(-0.05) end),
  322.    awful.key({ modkey,         }, "'", function () awful.client.incwfact( 0.05) end),
  323.  
  324.     awful.key({ modkey,           }, "s",   awful.tag.viewprev       ),
  325.     awful.key({ modkey,           }, "d",  awful.tag.viewnext       ),
  326.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  327.  
  328.     awful.key({ modkey,           }, "j",
  329.         function ()
  330.             awful.client.focus.byidx( 1)
  331.             if client.focus then client.focus:raise() end
  332.         end),
  333.     awful.key({ modkey,           }, "k",
  334.         function ()
  335.             awful.client.focus.byidx(-1)
  336.             if client.focus then client.focus:raise() end
  337.         end),
  338.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  339.  
  340.     -- Layout manipulation
  341.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  342.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  343.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  344.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  345.     awful.key({ modkey,           }, "y", awful.client.urgent.jumpto),
  346.     awful.key({ modkey,           }, "Tab",
  347.         function ()
  348.             awful.client.focus.history.previous()
  349.             if client.focus then
  350.                 client.focus:raise()
  351.             end
  352.         end),
  353.  
  354.     -- Standard program
  355.     awful.key({ modkey, "Shift"   }, "Return", function () awful.util.spawn(terminal) end),
  356.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  357.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  358.  
  359.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  360.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  361.     awful.key({ modkey,           }, "n",     function () awful.tag.incnmaster( 1)      end),
  362.     awful.key({ modkey,           }, "m",     function () awful.tag.incnmaster(-1)      end),
  363.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  364.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  365.     awful.key({ modkey, "Shift"   }, "n", function () awful.layout.inc(layouts,  1) end),
  366.     awful.key({ modkey, "Shift"   }, "m", function () awful.layout.inc(layouts, -1) end),
  367.  
  368.     -- Prompt
  369.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  370.  
  371.     awful.key({ modkey }, "x",
  372.               function ()
  373.                   awful.prompt.run({ prompt = "Run Lua code: " },
  374.                   mypromptbox[mouse.screen].widget,
  375.                   awful.util.eval, nil,
  376.                   awful.util.getdir("cache") .. "/history_eval")
  377.               end)
  378. )
  379.  
  380. clientkeys = awful.util.table.join(
  381.     awful.key({ modkey, "Shift"   }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  382.     awful.key({ modkey,           }, "BackSpace",      function (c) c:kill()                         end),
  383.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  384.     awful.key({ modkey,           }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  385.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  386.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  387.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  388.     awful.key({ modkey,           }, "v",      function (c) c.minimized = not c.minimized    end)
  389. )
  390.  
  391. -- Compute the maximum number of digit we need, limited to 9
  392. keynumber = 0
  393. for s = 1, screen.count() do
  394.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  395. end
  396.  
  397. -- Bind all key numbers to tags.
  398. -- Be careful: we use keycodes to make it works on any keyboard layout.
  399. -- This should map on the top row of your keyboard, usually 1 to 9.
  400. for i = 1, keynumber do
  401.     globalkeys = awful.util.table.join(globalkeys,
  402.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  403.                   function ()
  404.                         local screen = mouse.screen
  405.                         if tags[screen][i] then
  406.                             awful.tag.viewonly(tags[screen][i])
  407.                         end
  408.                   end),
  409.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  410.                   function ()
  411.                       local screen = mouse.screen
  412.                       if tags[screen][i] then
  413.                           awful.tag.viewtoggle(tags[screen][i])
  414.                       end
  415.                   end),
  416.         awful.key({ modkey,        }, "#" .. i + 9,
  417.                   function ()
  418.                       if client.focus and tags[client.focus.screen][i] then
  419.                           awful.client.movetotag(tags[client.focus.screen][i])
  420.                       end
  421.                   end),
  422.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  423.                   function ()
  424.                       if client.focus and tags[client.focus.screen][i] then
  425.                           awful.client.toggletag(tags[client.focus.screen][i])
  426.                       end
  427.                   end))
  428. end
  429.  
  430. clientbuttons = awful.util.table.join(
  431.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  432.     awful.button({ modkey }, 1, awful.mouse.client.move),
  433.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  434.  
  435. -- Set keys
  436. root.keys(globalkeys)
  437. -- }}}
  438.  
  439. -- {{{ Rules
  440. awful.rules.rules = {
  441.     -- All clients will match this rule.
  442.     { rule = { },
  443.       properties = { border_width = beautiful.border_width,
  444.                      border_color = beautiful.border_normal,
  445.                      focus = true,
  446.                      keys = clientkeys,
  447.                      buttons = clientbuttons } },
  448.     { rule = { class = "MPlayer" },
  449.       properties = { floating = true } },
  450.     { rule = { class = "pinentry" },
  451.       properties = { floating = true } },
  452.     { rule = { class = "gimp" },
  453.       properties = { floating = true } },
  454.     -- Set Firefox to always map on tags number 2 of screen 1.
  455.     -- { rule = { class = "Firefox" },
  456.     --   properties = { tag = tags[1][2] } },
  457. }
  458. -- }}}
  459.  
  460. -- {{{ Signals
  461. -- Signal function to execute when a new client appears.
  462. client.add_signal("manage", function (c, startup)
  463.     -- Add a titlebar
  464.     -- awful.titlebar.add(c, { modkey = modkey })
  465.  
  466.     -- Enable sloppy focus
  467.     c:add_signal("mouse::enter", function(c)
  468.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  469.             and awful.client.focus.filter(c) then
  470.             client.focus = c
  471.         end
  472.     end)
  473.  
  474.     if not startup then
  475.         -- Set the windows at the slave,
  476.         -- i.e. put it at the end of others instead of setting it master.
  477.         -- awful.client.setslave(c)
  478.  
  479.         -- Put windows in a smart way, only if they does not set an initial position.
  480.         if not c.size_hints.user_position and not c.size_hints.program_position then
  481.             awful.placement.no_overlap(c)
  482.             awful.placement.no_offscreen(c)
  483.         end
  484.     end
  485. end)
  486.  
  487. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  488. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  489. -- }}}
  490.  
  491. function run_once(prg)
  492.     if not prg then
  493.         do return nil end
  494.     end
  495.     awful.util.spawn_with_shell("pgrep -f -u $USER -x " .. prg .. " || (" .. prg .. ")")
  496. end
  497.  
  498. run_once("firefox")
  499.  
  500.  
  501. awful.tag.viewonly(tags[1][3])
Add Comment
Please, Sign In to add comment