Advertisement
Guest User

awesome config

a guest
Feb 6th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.49 KB | None | 0 0
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. local vicious = require("vicious")
  5. awful.rules = require("awful.rules")
  6. require("awful.autofocus")
  7. -- Widget and layout library
  8. local wibox = require("wibox")
  9. -- Theme handling library
  10. local beautiful = require("beautiful")
  11. -- Notification library
  12. local naughty = require("naughty")
  13. local menubar = require("menubar")
  14. local net_widgets = require("net_widgets")
  15.  
  16. -- Load Debian menu entries
  17. require("debian.menu")
  18.  
  19. -- {{{ Error handling
  20. -- Check if awesome encountered an error during startup and fell back to
  21. -- another config (This code will only ever execute for the fallback config)
  22. if awesome.startup_errors then
  23.     naughty.notify({ preset = naughty.config.presets.critical,
  24.                      title = "Oops, there were errors during startup!",
  25.                      text = awesome.startup_errors })
  26. end
  27.  
  28. -- Handle runtime errors after startup
  29. do
  30.     local in_error = false
  31.     awesome.connect_signal("debug::error", function (err)
  32.         -- Make sure we don't go into an endless error loop
  33.         if in_error then return end
  34.         in_error = true
  35.  
  36.         naughty.notify({ preset = naughty.config.presets.critical,
  37.                          title = "Oops, an error happened!",
  38.                          text = err })
  39.         in_error = false
  40.     end)
  41. end
  42. -- }}}
  43.  
  44. -- {{{ Variable definitions
  45. -- Themes define colours, icons, font and wallpapers.
  46. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  47.  
  48. -- This is used later as the default terminal and editor to run.
  49. terminal = "konsole"
  50. editor = os.getenv("EDITOR") or "atom"
  51. editor_cmd = terminal .. " -e " .. editor
  52.  
  53. -- Default modkey.
  54. -- Usually, Mod4 is the key with a logo between Control and Alt.
  55. -- If you do not like this or do not have such a key,
  56. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  57. -- However, you can use another modifier like Mod1, but it may interact with others.
  58. modkey = "Mod4"
  59.  
  60.   awful.util.spawn_with_shell("run_once firefox")
  61.  
  62.  
  63. -- Table of layouts to cover with awful.layout.inc, order matters.
  64. local layouts =
  65. {
  66.     awful.layout.suit.floating,
  67.     awful.layout.suit.tile,  
  68.     awful.layout.suit.tile.left,
  69.     awful.layout.suit.tile.bottom,
  70.     awful.layout.suit.tile.top,
  71.     awful.layout.suit.fair,
  72.     awful.layout.suit.fair.horizontal,
  73.     --awful.layout.suit.spiral,
  74.     --awful.layout.suit.spiral.dwindle,
  75.     awful.layout.suit.max,
  76.     awful.layout.suit.max.fullscreen,
  77.     awful.layout.suit.magnifier
  78. }
  79. -- }}}
  80.  
  81. -- {{{ Wallpaper
  82. if beautiful.wallpaper then
  83.     for s = 1, screen.count() do
  84.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  85.     end
  86. end
  87. -- }}}
  88. -- {{{ Tags
  89. -- Define a tag table which hold all screen tags.
  90. tags = {
  91.   names  = { '🌍', 'Ⅵ', '{}', "👁", "🖌", "🖹", "➐", "➑"},
  92.   layouts = { layouts[2], layouts[8], layouts[6], layouts[1], layouts[1],
  93.              layouts[1], layouts[1], layouts[1]}
  94.       }
  95. for s = 1, screen.count() do
  96.     -- Each screen has its own tag tablze.
  97.     tags[s] = awful.tag(tags.names, s, tags.layouts)
  98.  
  99. end
  100. -- }}}
  101.  
  102. -- {{{ Menu
  103. -- Create a laucher widget and a main menu
  104. myawesomemenu = {
  105.    { "manual", terminal .. " -e man awesome" },
  106.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  107.    { "restart", awesome.restart },
  108.    { "quit", awesome.quit }
  109. }
  110.  
  111. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  112.                                     { "Debian", debian.menu.Debian_menu.Debian },
  113.                                     { "open terminal", terminal }
  114.                                   }
  115.                         })
  116.  
  117. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  118.                                      menu = mymainmenu })
  119.  
  120. -- Menubar configuration
  121. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  122. -- }}}
  123.  
  124. -- {{{ Wibox
  125.  
  126. --Create a weather widget
  127. weatherwidget = wibox.widget.textbox()
  128. weatherwidget:set_text(" < " .. awful.util.pread(
  129.    " weather uudd -m --headers=Temperature --quiet | awk '{print $2, $3}'"
  130.    ) .. " < ") -- replace ZIP with the ID for your area. If you prefer Metric add "-m".
  131. weathertimer = timer(
  132.    { timeout = 600 } -- Update every 15 minutes.
  133. )
  134. weathertimer:connect_signal(
  135.    "timeout", function()
  136.       weatherwidget:set_text(" < " .. awful.util.pread(
  137.          " weather uudd -m --headers=Temperature --quiet | awk '{print $2, $3}' &"
  138.       ) .. " < ")end)
  139.  
  140. weathertimer:start() -- Start the timer
  141. weatherwidget:connect_signal(
  142.    "mouse::enter", function()
  143.       weather = naughty.notify(
  144.          {title="Weather",text=awful.util.pread("weather uudd")})
  145. end) -- this creates the hover feature.
  146.  
  147. weatherwidget:connect_signal(
  148.    "mouse::leave", function()
  149.       naughty.destroy(weather)
  150. end)
  151.  
  152. --wireless indicator
  153.  
  154. --sound widget
  155. local alsawidget =
  156. {
  157.     channel = "Master",
  158.     step = "5%",
  159.     colors =
  160.     {
  161.         unmute = "#AECF96",
  162.         mute = "#FF5656"
  163.     },
  164.     mixer = terminal .. " -e alsamixer", -- or whatever your preferred sound mixer is
  165.     notifications =
  166.     {
  167.         icons =
  168.         {
  169.             -- the first item is the 'muted' icon
  170.             "/usr/share/icons/breeze-dark/status/22/audio-volume-muted.svg",
  171.             -- the rest of the items correspond to intermediate volume levels - you can have as many as you want (but must be >= 1)
  172.             "/usr/share/icons/breeze-dark/status/22/audio-volume-low.svg",
  173.             "/usr/share/icons/breeze-dark/status/22/audio-volume-medim.svg",
  174.             "/usr/share/icons/breeze-dark/status/22/audio-volume-high.svg"
  175.         },
  176.         font = "Monospace 11", -- must be a monospace font for the bar to be sized consistently
  177.         icon_size = 48,
  178.         bar_size = 20 -- adjust to fit your font if the bar doesn't fit
  179.     }
  180. }
  181. -- widget
  182. alsawidget.icon = wibox.widget.imagebox()
  183.  
  184. alsawidget.bar = awful.widget.progressbar ()
  185. alsawidget.bar:set_width (10)
  186. alsawidget.bar:set_height (1)
  187. alsawidget.bar:set_ticks_gap(alsawidget.bar, 10)
  188. alsawidget.bar:set_ticks_size(alsawidget.bar, 2)
  189. alsawidget.bar:set_background_color ("#494B4F")
  190. alsawidget.bar:set_color (alsawidget.colors.unmute)
  191. alsawidget.bar:buttons (awful.util.table.join (
  192.     awful.button ({}, 1, function()
  193.         awful.util.spawn (alsawidget.mixer)
  194.     end),
  195.     awful.button ({}, 3, function()
  196.                 -- You may need to specify a card number if you're not using your main set of speakers.
  197.                 -- You'll have to apply this to every call to 'amixer sset'.
  198.                 -- awful.util.spawn ("amixer sset -c " .. yourcardnumber .. " " .. alsawidget.channel .. " toggle")
  199.         awful.util.spawn ("amixer sset " .. alsawidget.channel .. " toggle")
  200.         vicious.force ({ alsawidget.bar })
  201.     end),
  202.     awful.button ({}, 4, function()
  203.         awful.util.spawn ("amixer sset " .. alsawidget.channel .. " " .. alsawidget.step .. "+")
  204.         vicious.force ({ alsawidget.bar })
  205.     end),
  206.     awful.button ({}, 5, function()
  207.         awful.util.spawn ("amixer sset " .. alsawidget.channel .. " " .. alsawidget.step .. "-")
  208.         vicious.force ({ alsawidget.bar })
  209.     end)
  210. ))
  211. -- tooltip
  212. alsawidget.tooltip = awful.tooltip ({ objects = { alsawidget.bar } })
  213. -- naughty notifications
  214. alsawidget._current_level = 0
  215. alsawidget._muted = false
  216. function alsawidget:notify ()
  217.     local preset =
  218.     {
  219.         height = 75,
  220.         width = 300,
  221.         font = alsawidget.notifications.font
  222.     }
  223.     local i = 1;
  224.     while alsawidget.notifications.icons[i + 1] ~= nil
  225.     do
  226.         i = i + 1
  227.     end
  228.     if i >= 2
  229.     then
  230.         preset.icon_size = alsawidget.notifications.icon_size
  231.         if alsawidget._muted or alsawidget._current_level == 0
  232.         then
  233.             preset.icon = alsawidget.notifications.icons[1]
  234.       alsawidget.icon:set_image(alsawidget.notifications.icons[1])
  235.         elseif alsawidget._current_level == 100
  236.         then
  237.             preset.icon = alsawidget.notifications.icons[i]
  238.       alsawidget.icon:set_image(alsawidget.notifications.icons[i])
  239.         else
  240.             local int = math.modf (alsawidget._current_level / 100 * (i - 1))
  241.             preset.icon = alsawidget.notifications.icons[int + 2]
  242.         end
  243.     end
  244.     if alsawidget._muted
  245.     then
  246.         preset.title = alsawidget.channel .. " - Muted"
  247.     elseif alsawidget._current_level == 0
  248.     then
  249.         preset.title = alsawidget.channel .. " - 0% (muted)"
  250.         preset.text = "[" .. string.rep (" ", alsawidget.notifications.bar_size) .. "]"
  251.     elseif alsawidget._current_level == 100
  252.     then
  253.         preset.title = alsawidget.channel .. " - 100% (max)"
  254.         preset.text = "[" .. string.rep ("|", alsawidget.notifications.bar_size) .. "]"
  255.     else
  256.         local int = math.modf (alsawidget._current_level / 100 * alsawidget.notifications.bar_size)
  257.         preset.title = alsawidget.channel .. " - " .. alsawidget._current_level .. "%"
  258.         preset.text = "[" .. string.rep ("|", int) .. string.rep (" ", alsawidget.notifications.bar_size - int) .. "]"
  259.     end
  260.     if alsawidget._notify ~= nil
  261.     then
  262.  
  263.         alsawidget._notify = naughty.notify (
  264.         {
  265.             replaces_id = alsawidget._notify.id,
  266.             preset = preset
  267.         })
  268.     else
  269.         alsawidget._notify = naughty.notify ({ preset = preset })
  270.     end
  271. end
  272. -- register the widget through vicious
  273. vicious.register (alsawidget.bar, vicious.widgets.volume, function (widget, args)
  274.     alsawidget._current_level = args[1]
  275.     if args[2] == "♩"
  276.     then
  277.         alsawidget._muted = true
  278.         alsawidget.tooltip:set_text (" [Muted] ")
  279.         widget:set_color (alsawidget.colors.mute)
  280.         return 100
  281.     end
  282.     alsawidget._muted = false
  283.     alsawidget.tooltip:set_text (" " .. alsawidget.channel .. ": " .. args[1] .. "% ")
  284.     widget:set_color (alsawidget.colors.unmute)
  285.     return args[1]
  286. end, 5, alsawidget.channel) -- relatively high update time, use of keys/mouse will force update
  287.  
  288. -- Keyboard map indicator and changer
  289. kbdcfg = {}
  290. kbdcfg.cmd = "setxkbmap"
  291. kbdcfg.layout = { { "us", "" , " us " }, { "ru,us", "" , " ru " } }
  292. kbdcfg.current = 1  -- us is our default layout
  293. kbdcfg.widget = wibox.widget.textbox()
  294. kbdcfg.widget:set_text("" .. kbdcfg.layout[kbdcfg.current][3] .. "")
  295. kbdcfg.switch = function ()
  296.   kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
  297.   local t = kbdcfg.layout[kbdcfg.current]
  298.   kbdcfg.widget:set_text(" " .. t[3] .. " ")
  299.   os.execute( kbdcfg.cmd .. " " .. t[1] .. " " .. t[2] )
  300. end
  301.  
  302.  -- Mouse bindingse
  303.  
  304. kbdcfg.widget:buttons(
  305.  awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch() end))
  306. )
  307.  
  308. mydate_text = awful.widget.textclock("%d/%m %a")
  309. mydate = wibox.widget.background()
  310. mydate:set_widget(mydate_text)
  311. mydate:set_bg("#000000")
  312.  
  313.  
  314. -- Battery widget
  315. batterywidget_text = wibox.widget.textbox()
  316. batterywidget_text:set_text(" ?% ")
  317. batterywidgettimer = timer({ timeout = 5 })
  318. batterywidgettimer:connect_signal("timeout",
  319.   function()
  320.     fh = assert(io.popen("acpi | cut -d, -f 2", "r"))
  321.     batterywidget_text:set_text(" " .. fh:read("*l") .. " ")
  322.     fh:close()
  323.   end
  324. )
  325. batterywidgettimer:start()
  326. batterywidget = wibox.widget.background()
  327. batterywidget:set_widget(batterywidget_text)
  328. batterywidget:set_bg("#000000")
  329.  
  330. ---Icons and separators go here
  331. separator_f = wibox.widget.imagebox() --first separator
  332. separator_f:set_image("/home/syberic/Pictures/icons/widgetsep_f.png")
  333.  
  334. separator_b = wibox.widget.imagebox() -- black-to-gray separator
  335. separator_b:set_image('/home/syberic/.config/awesome/widgetsep.png')
  336.  
  337. separator_g = wibox.widget.imagebox() -- gray-to-black one
  338. separator_g:set_image('/home/syberic/Pictures/icons/widgetsep_g.png')
  339.  
  340. battery_icon = wibox.widget.imagebox()
  341. battery_icon:set_image('/home/syberic/Pictures/icons/ic_battery_std_white_48dp_2x.png')
  342.  
  343. clock_icon = wibox.widget.imagebox()
  344. clock_icon:set_image('/home/syberic/Pictures/icons/ic_access_time_white_48dp_2x.png')
  345.  
  346. date_icon = wibox.widget.imagebox()
  347. date_icon:set_image('/home/syberic/Pictures/icons/ic_date_range_white_48dp_2x.png')
  348. ---
  349.  
  350.  
  351. -- Create a textclock widget
  352. myclock = awful.widget.textclock(" %H:%M:%S", 1)
  353.  
  354.  
  355. -- Create a wibox for each screen and add it
  356. mywibox = {}
  357. mypromptbox = {}
  358. mylayoutbox = {}
  359. mytaglist = {}
  360. mytaglist.buttons = awful.util.table.join(
  361.                     awful.button({ }, 1, awful.tag.viewonly),
  362.                     awful.button({ modkey }, 1, awful.client.movetotag),
  363.                     awful.button({ }, 3, awful.tag.viewtoggle),
  364.                     awful.button({ modkey }, 3, awful.client.toggletag),
  365.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  366.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  367.                     )
  368. mytasklist = {}
  369. mytasklist.buttons = awful.util.table.join(
  370.                      awful.button({ }, 1, function (c)
  371.                                               if c == client.focus then
  372.                                                   c.minimized = true
  373.                                               else
  374.                                                   -- Without this, the following
  375.                                                   -- :isvisible() makes no sense
  376.                                                   c.minimized = false
  377.                                                   if not c:isvisible() then
  378.                                                       awful.tag.viewonly(c:tags()[1])
  379.                                                   end
  380.                                                   -- This will also un-minimize
  381.                                                   -- the client, if needed
  382.                                                   client.focus = c
  383.                                                   c:raise()
  384.                                               end
  385.                                           end),
  386.                      awful.button({ }, 3, function ()
  387.                                               if instance then
  388.                                                   instance:hide()
  389.                                                   instance = nil
  390.                                               else
  391.                                                   instance = awful.menu.clients({
  392.                                                       theme = { width = 250 }
  393.                                                   })
  394.                                               end
  395.                                           end),
  396.                      awful.button({ }, 4, function ()
  397.                                               awful.client.focus.byidx(1)
  398.                                               if client.focus then client.focus:raise() end
  399.                                           end),
  400.                      awful.button({ }, 5, function ()
  401.                                               awful.client.focus.byidx(-1)
  402.                                               if client.focus then client.focus:raise() end
  403.                                           end))
  404.  
  405. for s = 1, screen.count() do
  406.     -- Create a promptbox for each screen
  407.     mypromptbox[s] = awful.widget.prompt()
  408.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  409.     -- We need one layoutbox per screen.
  410.     mylayoutbox[s] = awful.widget.layoutbox(s)
  411.     mylayoutbox[s]:buttons(awful.util.table.join(
  412.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  413.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  414.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  415.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  416.     -- Create a taglist widget
  417.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  418.  
  419.     -- Create a tasklist widget
  420.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  421.  
  422.     -- Create the wibox
  423.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  424.  
  425.     -- Widgets that are aligned to the left
  426.     local left_layout = wibox.layout.fixed.horizontal()
  427.          left_layout:add(mytaglist[s])
  428.          left_layout:add(mypromptbox[s])
  429.  
  430.     -- Widgets that are aligned to the right
  431.     local right_layout = wibox.layout.fixed.horizontal()
  432.             right_layout:add(separator_f)
  433.             if s == 1 then right_layout:add(wibox.widget.systray()) end
  434.             right_layout:add(separator_g)
  435.             right_layout:add(battery_icon)
  436.             right_layout:add(batterywidget)
  437.             right_layout:add(separator_b)
  438.             right_layout:add(clock_icon)
  439.             right_layout:add(myclock)
  440.             right_layout:add(separator_g)
  441.             right_layout:add(date_icon)
  442.             right_layout:add(mydate)
  443.             right_layout:add(separator_b)
  444.                 right_layout:add(mylayoutbox[s])
  445.     -- Now bring it all together (with the tasklist in the middle)
  446.     local layout = wibox.layout.align.horizontal()
  447.        layout:set_left(left_layout)
  448.        layout:set_middle(mytasklist[s])
  449.        layout:set_right(right_layout)
  450.  
  451.     mywibox[s]:set_widget(layout)
  452. end
  453. -- }}}
  454.  
  455. -- {{{ Mouse bindings
  456. root.buttons(awful.util.table.join(
  457.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  458.     awful.button({ }, 4, awful.tag.viewnext),
  459.     awful.button({ }, 5, awful.tag.viewprev)
  460. ))
  461. -- }}}
  462.  
  463. -- {{{ Key bindings
  464.  
  465. globalkeys = awful.util.table.join(
  466.     awful.key({                   }, "XF86MonBrightnessUp", function()
  467.     awful.util.spawn("xbacklight -inc 5") end),
  468.     awful.key({                   }, "XF86MonBrightnessDown", function()
  469.     awful.util.spawn("xbacklight -dec 5") end),
  470.     awful.key({                   }, "XF86AudioRaiseVolume", function()
  471.     awful.util.spawn("amixer sset " .. alsawidget.channel .. " " .. alsawidget.step .. "+")
  472.     vicious.force({ alsawidget.bar })
  473.     alsawidget.notify() end),
  474.     awful.key({                   }, "XF86AudioLowerVolume", function()
  475.         awful.util.spawn("amixer sset " .. alsawidget.channel .. " " .. alsawidget.step .. "-")
  476.         vicious.force({ alsawidget.bar })
  477.         alsawidget.icon:set_image("/usr/share/icons/breeze-dark/status/22/audio-volume-medium.svg")
  478.         alsawidget.notify() end),
  479.     awful.key({                   }, "XF86AudioMute", function()
  480.             awful.util.spawn("amixer sset " .. alsawidget.channel .. " toggle")
  481.             -- The 2 following lines were needed at least on my configuration, otherwise it would get stuck muted
  482.             -- However, if the channel you're using is "Speaker" or "Headpphone"
  483.             -- instead of "Master", you'll have to comment out their corresponding line below.
  484.             awful.util.spawn("amixer sset " .. "Speaker" .. " unmute")
  485.             awful.util.spawn("amixer sset " .. "Headphone" .. " unmute")
  486.             vicious.force({ alsawidget.bar })
  487.             alsawidget.icon:set_image("/usr/share/icons/breeze-dark/status/22/audio-volume-muted.svg")
  488.             alsawidget.notify()
  489.         end),
  490.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  491.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  492.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  493.  
  494.     awful.key({ modkey,           }, "j",
  495.         function ()
  496.             awful.client.focus.byidx( 1)
  497.             if client.focus then client.focus:raise() end
  498.         end),
  499.     awful.key({ modkey,           }, "k",
  500.         function ()
  501.             awful.client.focus.byidx(-1)
  502.             if client.focus then client.focus:raise() end
  503.         end),
  504.  
  505.  
  506.     awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  507.  
  508.     -- Layout manipulation
  509.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  510.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  511.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  512.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  513.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  514.     awful.key({ modkey,           }, "Tab",
  515.         function ()
  516.             awful.client.focus.history.previous()
  517.             if client.focus then
  518.                 client.focus:raise()
  519.             end
  520.         end),
  521.  
  522.     -- Standard program
  523.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  524.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  525.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  526.  
  527.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  528.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  529.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  530.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  531.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  532.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  533.     awful.key({ modkey,           }, "d",     function ()
  534.       awful.layout.set(layouts[6])
  535.       awful.util.spawn("/home/syberic/.scripts/sunflower")                               end),
  536.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  537.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  538.     awful.key({                   }, "Print", function () awful.util.spawn_with_shell('sh ~/.scripts/capscr') end),
  539.  
  540.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  541.  
  542.     -- Prompt
  543.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  544.  
  545.     awful.key({ modkey }, "x",
  546.               function ()
  547.                   awful.prompt.run({ prompt = "Run Lua code: " },
  548.                   mypromptbox[mouse.screen].widget,
  549.                   awful.util.eval, nil,
  550.                   awful.util.getdir("cache") .. "/history_eval")
  551.               end),
  552.     -- Menubar
  553.     awful.key({ modkey }, "p", function() menubar.show() end)
  554. )
  555.  
  556. clientkeys = awful.util.table.join(
  557.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  558.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  559.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  560.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  561.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  562.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  563.     awful.key({ modkey,           }, "n",
  564.         function (c)
  565.             -- The client currently has the input focus, so it cannot be
  566.             -- minimized, since minimized clients can't have the focus.
  567.             c.minimized = true
  568.         end),
  569.     awful.key({ modkey,           }, "m",
  570.         function (c)
  571.             c.maximized_horizontal = not c.maximized_horizontal
  572.             c.maximized_vertical   = not c.maximized_vertical
  573.         end)
  574. )
  575.  
  576. -- Bind all key numbers to tags.
  577. -- Be careful: we use keycodes to make it works on any keyboard layout.
  578. -- This should map on the top row of your keyboard, usually 1 to 9.
  579. for i = 1, 9 do
  580.     globalkeys = awful.util.table.join(globalkeys,
  581.         -- View tag only.
  582.         awful.key({ modkey }, "#" .. i + 9,
  583.                   function ()
  584.                         local screen = mouse.screen
  585.                         local tag = awful.tag.gettags(screen)[i]
  586.                         if tag then
  587.                            awful.tag.viewonly(tag)
  588.                         end
  589.                   end),
  590.         -- Toggle tag.
  591.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  592.                   function ()
  593.                       local screen = mouse.screen
  594.                       local tag = awful.tag.gettags(screen)[i]
  595.                       if tag then
  596.                          awful.tag.viewtoggle(tag)
  597.                       end
  598.                   end),
  599.         -- Move client to tag.
  600.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  601.                   function ()
  602.                       if client.focus then
  603.                         local tag = awful.tag.gettags(client.focus.screen)[i]
  604.                           if tag then
  605.                               awful.client.movetotag(tag)
  606.                           end
  607.                      end
  608.                   end),
  609.         -- Toggle tag.
  610.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  611.                   function ()
  612.                       if client.focus then
  613.                           local tag = awful.tag.gettags(client.focus.screen)[i]
  614.                           if tag then
  615.                               awful.client.toggletag(tag)
  616.                           end
  617.                       end
  618.                   end))
  619. end
  620.  
  621. clientbuttons = awful.util.table.join(
  622.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  623.     awful.button({ modkey }, 1, awful.mouse.client.move),
  624.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  625. -- Set keys
  626. root.keys(globalkeys)
  627. -- }}}
  628.  
  629. -- {{{ Rules
  630. -- Rules to apply to new clients (through the "manage" signal).
  631. awful.rules.rules = {
  632.     -- All clients will match this rule.
  633.     { rule = { },
  634.       properties = { border_width = beautiful.border_width,
  635.                      border_color = beautiful.border_normal,
  636.                      focus = awful.client.focus.filter,
  637.                      raise = true,
  638.                      keys = clientkeys,
  639.                      buttons = clientbuttons },
  640.     },
  641.     { rule = { class = "MPlayer" },
  642.       properties = { floating = true } },
  643.     { rule = { class = "pinentry" },
  644.       properties = { floating = true } },
  645.     { rule = { class = "Gimp" },
  646.       properties = { floating = true, tag = tags[1][5] } },
  647.     { rule = { class = "Firefox" },
  648.       properties = { tag = tags[1][1] } },
  649.     { rule = { class = "konsole", instance = "konsole"},
  650.       properties = { tag = tags[1][3] } },
  651.     { rule = { class = "Gvim" },
  652.       properties = { size_hints_honor = false, tag = tags[1][2] } },
  653.     { rule = { class = "Okular" },
  654.       properties = { tag = tags[1][4] } },
  655.     { rule = { class = "love" },
  656.       properties = { floating = true} },
  657.     { rule = { class = "Telegram" },
  658.       properties = { tag = tags[1][1] , x = 684, y = 26, width = 681, height = 741} },
  659. }
  660. -- }}}
  661.  
  662. -- {{{ Signals
  663. -- Signal function to execute when a new client appears.
  664. client.connect_signal("manage", function (c, startup)
  665.     -- Enable sloppy focus
  666.     c:connect_signal("mouse::enter", function(c)
  667.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  668.             and awful.client.focus.filter(c) then
  669.             client.focus = c
  670.         end
  671.     end)
  672.  
  673.     if not startup then
  674.         -- Set the windows at the slave,
  675.         -- i.e. put it at the end of others instead of setting it master.
  676.         -- awful.client.setslave(c)
  677.  
  678.         -- Put windows in a smart way, only if they does not set an initial position.
  679.         if not c.size_hints.user_position and not c.size_hints.program_position then
  680.             awful.placement.no_overlap(c)
  681.             awful.placement.no_offscreen(c)
  682.         end
  683.     elseif not c.size_hints.user_position and not c.size_hints.program_position then
  684.         -- Prevent clients from being unreachable after screen count change
  685.         awful.placement.no_offscreen(c)
  686.     end
  687.  
  688.     local titlebars_enabled = false
  689.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  690.         -- buttons for the titlebar
  691.         local buttons = awful.util.table.join(
  692.                 awful.button({ }, 1, function()
  693.                     client.focus = c
  694.                     c:raise()
  695.                     awful.mouse.client.move(c)
  696.                 end),
  697.                 awful.button({ }, 3, function()
  698.                     client.focus = c
  699.                     c:raise()
  700.                     awful.mouse.client.resize(c)
  701.                 end)
  702.                 )
  703.  
  704.         -- Widgets that are aligned to the left
  705.         local left_layout = wibox.layout.fixed.horizontal()
  706.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  707.         left_layout:buttons(buttons)
  708.  
  709.         -- Widgets that are aligned to the right
  710.         local right_layout = wibox.layout.fixed.horizontal()
  711.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  712.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  713.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  714.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  715.         right_layout:add(awful.titlebar.widget.closebutton(c))
  716.  
  717.         -- The title goes in the middle
  718.         local middle_layout = wibox.layout.flex.horizontal()
  719.         local title = awful.titlebar.widget.titlewidget(c)
  720.         title:set_align("center")
  721.         middle_layout:add(title)
  722.         middle_layout:buttons(buttons)
  723.  
  724.         -- Now bring it all together
  725.         local layout = wibox.layout.align.horizontal()
  726.         layout:set_left(left_layout)
  727.         layout:set_right(right_layout)
  728.         layout:set_middle(middle_layout)
  729.  
  730.         awful.titlebar(c):set_widget(layout)
  731.     end
  732. end)
  733.  
  734. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  735. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  736. -- }}}
  737.  
  738. function run_once(cmd)
  739.   findme = cmd
  740.   firstspace = cmd:find(" ")
  741.   if firstspace then
  742.     findme = cmd:sub(0, firstspace-1)
  743.   end
  744.   awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
  745. end
  746.  
  747. run_once("firefox")
  748. run_once("gvim")
  749. run_once("konsole")
  750. run_once("nm-applet")
  751. run_once("gxkb")
  752. run_once("volumeicon")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement