Advertisement
Haron_Prime

rc.lua

Jul 9th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 40.42 KB | None | 0 0
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. awful.rules = require("awful.rules")
  5. require("awful.autofocus")
  6. require("eminent")
  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 applicationsmenu = require("applicationsmenu")
  15. local vicious = require("vicious")
  16. local bashets = require("bashets")
  17. local quake = require("quake")
  18. local quakeconsole = {}
  19. for s = 1, screen.count() do
  20.    quakeconsole[s] = quake({ terminal = "urxvtc",
  21.            height = 0.95,
  22.            screen = s })
  23. end
  24.  
  25. -- os.setlocale("ru_UA.UTF-8")
  26. os.setlocale(os.getenv("LANG"), "time")
  27.  
  28. -- {{{ Error handling
  29. -- Check if awesome encountered an error during startup and fell back to
  30. -- another config (This code will only ever execute for the fallback config)
  31. if awesome.startup_errors then
  32.     naughty.notify({ preset = naughty.config.presets.critical,
  33.                      title = "Oops, there were errors during startup!",
  34.                      text = awesome.startup_errors })
  35. end
  36.  
  37. -- Handle runtime errors after startup
  38. do
  39.     local in_error = false
  40.     awesome.connect_signal("debug::error", function (err)
  41.         -- Make sure we don't go into an endless error loop
  42.         if in_error then return end
  43.         in_error = true
  44.  
  45.         naughty.notify({ preset = naughty.config.presets.critical,
  46.                          title = "Oops, an error happened!",
  47.                          text = err })
  48.         in_error = false
  49.     end)
  50. end
  51. -- }}}
  52.  
  53. -- {{{ Variable definitions
  54. -- Themes define colours, icons, font and wallpapers.
  55. beautiful.init("/home/haron/.config/awesome/themes/haron/theme.lua")
  56.  
  57. -- This is used later as the default terminal and editor to run.
  58. terminal = "urxvtc"
  59. editor = os.getenv("EDITOR") or "nano"
  60. editor_cmd = terminal .. " -e " .. editor
  61.  
  62. -- Default modkey.
  63. -- Usually, Mod4 is the key with a logo between Control and Alt.
  64. -- If you do not like this or do not have such a key,
  65. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  66. -- However, you can use another modifier like Mod1, but it may interact with others.
  67. modkey = "Mod4"
  68.  
  69. -- Table of layouts to cover with awful.layout.inc, order matters.
  70. local layouts =
  71. {
  72.     awful.layout.suit.floating,
  73.     awful.layout.suit.tile,
  74.     awful.layout.suit.tile.left,
  75.     awful.layout.suit.tile.bottom,
  76.     awful.layout.suit.tile.top,
  77.     awful.layout.suit.fair,
  78.     awful.layout.suit.fair.horizontal,
  79. --    awful.layout.suit.spiral,
  80. --    awful.layout.suit.spiral.dwindle,
  81.     awful.layout.suit.max,
  82.     awful.layout.suit.max.fullscreen,
  83.     awful.layout.suit.magnifier
  84.  
  85. }
  86. -- }}}
  87.  
  88. -- {{{ Wallpaper
  89. if beautiful.wallpaper then
  90.     for s = 1, screen.count() do
  91.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  92.     end
  93. end
  94. -- }}}
  95.  
  96. -- {{{ Tags
  97. -- Define a tag table which hold all screen tags.
  98. tags = {}
  99. for s = 1, screen.count() do
  100.     -- Each screen has its own tag table.
  101.     tags[s] = awful.tag({ "Web", "Mail", "Editor", "Files", "System", "Video", "Pictures", "Work", "Torrents" }, s, {layouts[1], layouts[1], layouts[8], layouts[10], layouts[10], layouts[9], layouts[8], layouts[10], layouts[10]})
  102. end
  103. -- }}}
  104.  
  105. mymainmenu = awful.menu({items = {
  106. --                                { "awesome", myawesomemenu, beautiful.awesome_icon },
  107.                                   {"Accessories", applicationsmenu.applicationsmenu() ,beautiful.accesoires_icon},
  108.                                   { " " },
  109.                                   { "Run", "dmenu_run -i -p 'Run command:' -nb '" .. beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal .. "' -sb '" .. beautiful.bg_myfocus .. "' -sf '" .. beautiful.fg_myurgent .. "' -fn '-misc-fixed-medium-r-normal-*-15-140-75-75-c-90-iso10646-1'", beautiful.run_icon},
  110.                                   { " " },
  111.                                   { " Exit", awesome.quit, beautiful.logout_icon},
  112.                                   { " Reboot", function()  awful.util.spawn_with_shell("systemctl reboot") end, beautiful.reboot_icon},
  113.                                   { " Power off", function()  awful.util.spawn_with_shell("systemctl poweroff") end, beautiful.shutdown_icon},
  114.                            }
  115.                         })
  116.  
  117. mylauncher = awful.widget.launcher({ image = beautiful.a2_icon,
  118.                                      menu = mymainmenu })
  119.  
  120. -- Menubar configuration
  121. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  122. -- }}}
  123.  
  124.  
  125.  
  126. -- {{{ Wibox
  127.  
  128. -- {{{ My widgets
  129.  
  130. -- Language widget
  131. local function lang_output()
  132.     local f = io.popen("skb 1")
  133.     local out = f:read("*a")
  134.     f:close()
  135.     return { out }
  136. end
  137. mylangbox = wibox.widget.textbox()
  138. vicious.register(mylangbox, lang_output, "<span font=\"Terminus Re33 12\">$1</span>", 1)
  139.  
  140. -- Weather widget
  141. local function temp_output()
  142.     local f = io.popen("cat /home/haron/.config/gis-weather/cur_temp")
  143.     local out = f:read("*a")
  144.     f:close()
  145.     return { out }
  146. end
  147. myweatherbox1 = wibox.widget.textbox()
  148. vicious.register(myweatherbox1, temp_output, "<span color=\"#90d0f0\" font=\"Terminus Re33 14\">$1</span>", 10)
  149.  
  150. -- CPU widget
  151. cpuwidget = wibox.widget.textbox()
  152. vicious.register(cpuwidget, vicious.widgets.cpu, "☢ $1%", 1)
  153.  
  154. -- Memory widget
  155. memwidget = wibox.widget.textbox()
  156. vicious.register(memwidget, vicious.widgets.mem, "⛁ $1%", 1)
  157.  
  158. -- Temp CPU widget
  159. local function temp_cpu()
  160.     local f = io.popen("sensors | grep 'temp2' | cut -c 16-17")
  161.     local out = f:read("*a")
  162.     f:close()
  163.     return { out }
  164. end
  165. mytempbox1 = wibox.widget.textbox()
  166. vicious.register(mytempbox1, temp_cpu, "<span font=\"Terminus Re33 12\">+$1</span>", 1)
  167. mytempbox1a = wibox.widget.textbox("<span font=\"Terminus Re33 11\">°C</span>")
  168.  
  169. -- Temp GPU widget
  170. local function temp_gpu()
  171.     local f = io.popen("nvidia-settings -q gpucoretemp -t")
  172.     local out = f:read("*a")
  173.     f:close()
  174.     return { out }
  175. end
  176. mytempbox2 = wibox.widget.textbox()
  177. vicious.register(mytempbox2, temp_gpu, "<span font=\"Terminus Re33 12\">+$1</span>", 5)
  178. mytempbox2a = wibox.widget.textbox("<span font=\"Terminus Re33 11\">°C</span>")
  179.  
  180. -- Netstat widget
  181.   --Speed
  182. netwidget = wibox.widget.textbox()
  183. vicious.register(netwidget, vicious.widgets.net, "⬇ <span font=\"Terminus Re33 12\">${enp3s0 down_mb}M</span> <span color=\"#ffffff\"> ✦ </span>⬆ <span font=\"Terminus Re33 12\">${enp3s0 up_mb}M</span>", 1)
  184.   --In
  185. local function net_stat_in()
  186.     local f = io.popen("vnstat  | grep 'today' | awk '{print $2 $3}'")
  187.     local out = f:read("*a")
  188.     f:close()
  189.     return { out }
  190. end
  191. netstat_in = wibox.widget.textbox()
  192. vicious.register(netstat_in, net_stat_in, "<span font=\"Terminus Re33 12\">$1</span>", 60)
  193.   --Out
  194. local function net_stat_out()
  195.     local f = io.popen("vnstat  | grep 'today' | awk '{print $5 $6}'")
  196.     local out = f:read("*a")
  197.     f:close()
  198.     return { out }
  199. end
  200. netstat_out = wibox.widget.textbox()
  201. vicious.register(netstat_out, net_stat_out, "<span font=\"Terminus Re33 12\">$1</span>", 60)
  202.  
  203. -- MPD widget
  204. mpdwidget = wibox.widget.textbox()
  205. vicious.register(mpdwidget, vicious.widgets.mpd,
  206.     function (mpdwidget, args)
  207.         if args["{state}"] == "Stop" then
  208.             return ""
  209.         else
  210.             return args["{Artist}"]..' - '.. args["{Title}"]..'   '
  211.         end
  212.     end, 10)
  213.  
  214. -- Volume widget
  215. volumewidget = wibox.widget.textbox()
  216. vicious.register( volumewidget, vicious.widgets.volume,
  217.   function(widget, args)
  218.     return '<span color=\"#90d0f0\">' .. args[2] .. '</span>' .. " " .. '<span font=\"Terminus Re33 12\">' .. args[1] .. "%" .. '</span>'
  219.   end, 1, "Master")
  220. volumewidget:buttons(awful.util.table.join(
  221.     awful.button({ }, 1, function () awful.util.spawn("amixer -q sset Master toggle", false) end),
  222.     awful.button({ }, 3, function () awful.util.spawn("".. terminal.. " -e alsamixer -D equal", true) end),
  223.     awful.button({ }, 4, function () awful.util.spawn("amixer -q sset Master 1dB+", false) end),
  224.     awful.button({ }, 5, function () awful.util.spawn("amixer -q sset Master 1dB-", false) end)
  225.  ))
  226.  
  227. -- Separator Widget
  228. separator = wibox.widget.textbox()
  229. separator: set_text ("   ")
  230.  
  231. separator2 = wibox.widget.textbox("<span color=\"#ffffff\"> ✦ </span>")
  232.  
  233. separator3 = wibox.widget.textbox()
  234. separator3: set_text (" ")
  235.  
  236. separator4 = wibox.widget.textbox()
  237. separator4: set_text ("/")
  238.  
  239. -- }}}
  240.  
  241. mytextclock = awful.widget.textclock("<span font=\"Terminus Re33 12\">%a, %d %b</span>", 1)
  242. mytextclock2 = awful.widget.textclock("<span color=\"#90d0f0\" font=\"Terminus Re33 14\">%H:%M</span>", 1)
  243.  
  244. -- Create a wibox for each screen and add it
  245. mywibox = {}
  246. mypromptbox = {}
  247. mylayoutbox = {}
  248. mytaglist = {}
  249. mytaglist.buttons = awful.util.table.join(
  250.                     awful.button({ }, 1, awful.tag.viewonly),
  251.                     awful.button({ modkey }, 1, awful.client.movetotag),
  252.                     awful.button({ }, 3, awful.tag.viewtoggle),
  253.                     awful.button({ modkey }, 3, awful.client.toggletag),
  254.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  255.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  256.                     )
  257. mytasklist = {}
  258. mytasklist.buttons = awful.util.table.join(
  259.                      awful.button({ }, 1, function (c)
  260.                                               if c == client.focus then
  261.                                                   c.minimized = true
  262.                                               else
  263.                                                   -- Without this, the following
  264.                                                   -- :isvisible() makes no sense
  265.                                                   c.minimized = false
  266.                                                   if not c:isvisible() then
  267.                                                       awful.tag.viewonly(c:tags()[1])
  268.                                                   end
  269.                                                   -- This will also un-minimize
  270.                                                   -- the client, if needed
  271.                                                   client.focus = c
  272.                                                   c:raise()
  273.                                               end
  274.                                           end),
  275.                      awful.button({ }, 3, function ()
  276.                                               if instance then
  277.                                                   instance:hide()
  278.                                                   instance = nil
  279.                                               else
  280.                                                   instance = awful.menu.clients({
  281.                                                       theme = { width = 250 }
  282.                                                   })
  283.                                               end
  284.                                           end),
  285.                      awful.button({ }, 4, function ()
  286.                                               awful.client.focus.byidx(1)
  287.                                               if client.focus then client.focus:raise() end
  288.                                           end),
  289.                      awful.button({ }, 5, function ()
  290.                                               awful.client.focus.byidx(-1)
  291.                                               if client.focus then client.focus:raise() end
  292.                                           end))
  293.  
  294. for s = 1, screen.count() do
  295.     -- Create a promptbox for each screen
  296.     mypromptbox[s] = awful.widget.prompt()
  297.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  298.     -- We need one layoutbox per screen.
  299.     mylayoutbox[s] = awful.widget.layoutbox(s)
  300.     mylayoutbox[s]:buttons(awful.util.table.join(
  301.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  302.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  303.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  304.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  305.     -- Create a taglist widget
  306.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  307.  
  308.     -- Create a tasklist widget
  309.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  310.  
  311.     -- Create the wibox
  312.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  313.  
  314.     -- Widgets that are aligned to the left
  315.     local left_layout = wibox.layout.fixed.horizontal()
  316.     left_layout:add(separator3)
  317.     left_layout:add(mylauncher)
  318.     left_layout:add(separator3)
  319.     left_layout:add(mytaglist[s])
  320.     left_layout:add(separator)
  321.     left_layout:add(mypromptbox[s])
  322.  
  323.     -- Widgets that are aligned to the right
  324.     local right_layout = wibox.layout.fixed.horizontal()
  325.     right_layout:add(separator2)
  326.     right_layout:add(mpdwidget)
  327.     right_layout:add(volumewidget)
  328.     right_layout:add(separator2)
  329.     right_layout:add(netwidget)
  330.     right_layout:add(separator2)
  331.     right_layout:add(netstat_in)
  332.     right_layout:add(separator4)
  333.     right_layout:add(netstat_out)
  334.     right_layout:add(separator2)
  335.     right_layout:add(cpuwidget)
  336.     right_layout:add(separator2)
  337.     right_layout:add(mytempbox1)
  338.     right_layout:add(mytempbox1a)
  339.     right_layout:add(separator2)
  340.     right_layout:add(memwidget)
  341.     right_layout:add(separator2)
  342.     right_layout:add(mytempbox2)
  343.     right_layout:add(mytempbox2a)
  344.     right_layout:add(separator2)
  345.     right_layout:add(mylangbox)
  346.     right_layout:add(separator2)
  347.     right_layout:add(mytextclock)
  348.     right_layout:add(separator2)
  349.     right_layout:add(mytextclock2)
  350.     right_layout:add(separator2)
  351.     right_layout:add(myweatherbox1)
  352.     right_layout:add(separator2)
  353.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  354.     right_layout:add(separator3)
  355.     right_layout:add(mylayoutbox[s])
  356.  
  357.     -- Now bring it all together (with the tasklist in the middle)
  358.     local layout = wibox.layout.align.horizontal()
  359.     layout:set_left(left_layout)
  360.     layout:set_middle(mytasklist[s])
  361.     layout:set_right(right_layout)
  362.  
  363.     mywibox[s]:set_widget(layout)
  364. end
  365. -- }}}
  366.  
  367. -- {{{ Mouse bindings
  368. root.buttons(awful.util.table.join(
  369.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  370.     awful.button({ }, 4, awful.tag.viewnext),
  371.     awful.button({ }, 5, awful.tag.viewprev)
  372. ))
  373. -- }}}
  374.  
  375. -- {{{ Key bindings
  376. globalkeys = awful.util.table.join(
  377.     awful.key({ modkey,           }, "Left",                  awful.tag.viewprev                                                                                ),
  378.     --awful.key({                   }, "XF86Back",     awful.tag.viewprev       ),
  379.     awful.key({ modkey,           }, "Right",                 awful.tag.viewnext                                                                                ),
  380.     --awful.key({                   }, "XF86Forward",  awful.tag.viewnext       ),
  381.     awful.key({ modkey,           }, "Escape",                awful.tag.history.restore                                                                         ),
  382.  
  383.  
  384.     awful.key({ modkey,           }, "#44",                                                                                                                        -- Win+j
  385.         function ()
  386.             awful.client.focus.byidx( 1)
  387.             if client.focus then client.focus:raise() end
  388.         end),
  389.     awful.key({ modkey,           }, "#45",                                                                                                                        -- Win+k
  390.         function ()
  391.             awful.client.focus.byidx(-1)
  392.             if client.focus then client.focus:raise() end
  393.         end),
  394.     awful.key({ modkey,           }, "#25",                  function () mymainmenu:show() end), -- Win+w
  395.  
  396.     -- Layout manipulation
  397.     awful.key({ modkey, "Shift"   }, "#44",                  function () awful.client.swap.byidx(  1)                                                        end), -- Win+Shift+j
  398.     awful.key({ modkey, "Shift"   }, "#45",                  function () awful.client.swap.byidx( -1)                                                        end), -- Win+Shift+k
  399.     awful.key({ modkey, "Control" }, "#44",                  function () awful.screen.focus_relative( 1)                                                     end), -- Win+Ctrl+j
  400.     awful.key({ modkey, "Control" }, "#45",                  function () awful.screen.focus_relative(-1)                                                     end), -- Win+Ctrl+k
  401.     awful.key({ modkey,           }, "#30",                  awful.client.urgent.jumpto                                                                         ), -- Win+u
  402.     awful.key({ modkey,           }, "Tab",
  403.         function ()
  404.             awful.client.focus.history.previous()
  405.             if client.focus then
  406.                 client.focus:raise()
  407.             end
  408.         end),
  409.  
  410.     -- Standard program
  411.     awful.key({ modkey,           }, "Return",               function () awful.util.spawn(terminal)                                                          end),
  412.     awful.key({ modkey, "Control" }, "#27",                  awesome.restart                                                                                    ), -- Win+Ctrl+r
  413.     awful.key({ modkey, "Shift"   }, "#24",                  awesome.quit                                                                                       ), -- Win+Shift+q
  414.  
  415.     awful.key({ modkey,           }, "#46",                  function () awful.tag.incmwfact( 0.05)                                                          end), -- Win+l
  416.     awful.key({ modkey,           }, "#43",                  function () awful.tag.incmwfact(-0.05)                                                          end), -- Win+h
  417.     awful.key({ modkey, "Shift"   }, "#43",                  function () awful.tag.incnmaster( 1)                                                            end), -- Win+Shift+h
  418.     awful.key({ modkey, "Shift"   }, "#46",                  function () awful.tag.incnmaster(-1)                                                            end), -- Win+Shift+l
  419.     awful.key({ modkey, "Control" }, "#43",                  function () awful.tag.incncol( 1)                                                               end), -- Win+Ctrl+h
  420.     awful.key({ modkey, "Control" }, "#46",                  function () awful.tag.incncol(-1)                                                               end), -- Win+Ctrl+l
  421.     awful.key({ modkey,           }, "space",                function () awful.layout.inc(layouts,  1)                                                       end),
  422.     awful.key({ modkey, "Shift"   }, "space",                function () awful.layout.inc(layouts, -1)                                                       end),
  423.  
  424.     awful.key({ modkey, "Control" }, "#57",                  awful.client.restore                                                                               ), -- Win+Ctrl+n
  425.  
  426.     -- Prompt
  427.     awful.key({ modkey            }, "#27",                  function () mypromptbox[mouse.screen]:run()                                                     end), -- Win+r
  428.  
  429.     awful.key({ modkey            }, "#53",                                                                                                                        -- Win+x
  430.               function ()
  431.                   awful.prompt.run({ prompt = "Run Lua code: " },
  432.                   mypromptbox[mouse.screen].widget,
  433.                   awful.util.eval, nil,
  434.                   awful.util.getdir("cache") .. "/history_eval")
  435.               end),
  436.     -- Menubar
  437.     awful.key({ modkey            }, "#33",                  function() menubar.show()                                                                       end), -- Win+p
  438.  
  439.     -- {{{ My keys
  440.  
  441.     awful.key({                   }, "XF86Reload",           awesome.restart                                                                                    ),
  442.     awful.key({                   }, "F12",                  function () quakeconsole[mouse.screen]:toggle()                                                 end),
  443.     awful.key({                   }, "XF86Favorites",        function () awful.util.spawn_with_shell("urxvtc -name htop -e /usr/bin/htop")                   end),
  444.     awful.key({                   }, "XF86Explorer",         function () awful.util.spawn_with_shell("/home/haron/.local/bin/firefox")                       end),
  445.     awful.key({                   }, "XF86Mail",             function () awful.util.spawn_with_shell("/home/haron/.local/bin/thunderbird")                   end),
  446.     awful.key({                   }, "XF86Calculator",       function () awful.util.spawn_with_shell("galculator")                                           end),
  447.     awful.key({                   }, "XF86Tools",            function () awful.util.spawn_with_shell("urxvtc -e /usr/bin/ncmpcpp")                           end),
  448.     awful.key({                   }, "XF86HomePage",         function () awful.util.spawn_with_shell("pcmanfm")                                              end),
  449.     awful.key({ "Mod1"            }, "XF86HomePage",         function () awful.util.spawn_with_shell("gksu pcmanfm")                                         end),
  450.     awful.key({                   }, "XF86Search",           function () awful.util.spawn_with_shell("catfish")                                              end),
  451.     awful.key({                   }, "XF86AudioMute",        function () awful.util.spawn(           "amixer sset Master toggle")                            end),
  452.     awful.key({                   }, "XF86AudioLowerVolume", function () awful.util.spawn(           "amixer set Master 5%-")                                end),
  453.     awful.key({                   }, "XF86AudioRaiseVolume", function () awful.util.spawn(           "amixer set Master 5%+")                                end),
  454.     awful.key({                   }, "XF86AudioPrev",        function () awful.util.spawn(           "mpc prev")                                             end),
  455.     awful.key({                   }, "XF86AudioNext",        function () awful.util.spawn(           "mpc next")                                             end),
  456.     awful.key({                   }, "XF86AudioPlay",        function () awful.util.spawn(           "mpc toggle")                                           end),
  457.     awful.key({                   }, "XF86AudioStop",        function () awful.util.spawn(           "mpc stop")                                             end),
  458.     awful.key({                   }, "XF86Sleep",            function () awful.util.spawn(           "xautolock -locknow")                                   end),
  459.     awful.key({                   }, "Cancel",               function () awful.util.spawn(           "/home/haron/bin/awst")                                 end),
  460.     awful.key({                   }, "Print",                function () awful.util.spawn(           "scrot -e 'mv $f ~/Screenshots/ 2>/dev/null'")          end),
  461.     awful.key({ "Mod1"            }, "Print",                function () awful.util.spawn(           "scrot -s -e 'mv $f ~/Screenshots/ 2>/dev/null'")       end),
  462.     awful.key({ "Mod1"            }, "#28",                  function () awful.util.spawn_with_shell("tixati")                                               end), -- Alt+t
  463.     awful.key({ "Mod1"            }, "#31",                  function () awful.util.spawn_with_shell("/home/haron/.local/bin/iron")                          end), -- Alt+i
  464.     awful.key({ "Mod1"            }, "#32",                  function () awful.util.spawn_with_shell("/home/haron/.local/bin/opera")                         end), -- Alt+o
  465.     awful.key({ "Mod1",           }, "#33",                  function () awful.util.spawn_with_shell("env WINEPREFIX='/home/haron/.wine' wine '/home/haron/lib/Pro100-5.20-GIV/PRO100.exe'")                                                                                                                                          end), -- Alt+p
  466.     awful.key({ "Mod1"            }, "#39",                  function () awful.util.spawn_with_shell("subl3")                                                end), -- Alt+s
  467.     awful.key({ "Mod1"            }, "#40",                  function () awful.util.spawn_with_shell("/home/haron/.local/bin/doublecmd")                     end), -- Alt+d
  468.     awful.key({ "Mod1"            }, "#41",                  function () awful.util.spawn(           "/home/haron/.local/bin/fupdate.zsh")                   end), -- Alt+f
  469.     awful.key({ "Mod1"            }, "#42",                  function () awful.util.spawn_with_shell("gimp")                                                 end), -- Alt+g
  470.     awful.key({ "Mod1"            }, "#43",                  function () awful.util.spawn_with_shell("/usr/bin/hexchat")                                     end), -- Alt+h
  471.     awful.key({ "Mod1"            }, "#46",                  function () awful.util.spawn_with_shell("cat /home/haron/Documents/last.pass | xclip -selection clipboard")                                                                                                                                                      end), -- Alt+l
  472.     awful.key({ "Mod1"            }, "#52",                  function () awful.util.spawn(           "/home/haron/.local/bin/transd")                        end), -- Alt+z
  473.     awful.key({ "Mod1", "Shift"   }, "#52",                  function () awful.util.spawn_with_shell("transmission-remote-gtk")                              end), -- Alt+Shift+z
  474.     awful.key({ "Mod1", "Control" }, "#52",                  function () awful.util.spawn_with_shell("transgui")                                             end), -- Alt+Ctrl+z
  475.     awful.key({ "Mod1"            }, "#53",                  function () awful.util.spawn_with_shell("gksu /usr/bin/pacmanxg")                               end), -- Alt+x
  476.     awful.key({ "Mod1"            }, "#54",                  function () awful.util.spawn_with_shell("mpv --fs /dev/video0")                                 end), -- Alt+c
  477.     awful.key({ "Mod1"            }, "#55",                  function () awful.util.spawn_with_shell("/home/haron/.local/bin/start-tor-browser")             end), -- Alt+v
  478.     awful.key({ "Mod1"            }, "#56",                  function () awful.util.spawn_with_shell("baobab")                                               end), -- Alt+b
  479.     awful.key({ "Mod1"            }, "#58",                  function () awful.util.spawn_with_shell("urxvtc -name mc -e /usr/bin/mc")                       end), -- Alt+m
  480.     awful.key({ "Mod1"            }, "#59",                  function () awful.util.spawn_with_shell("thunar")                                               end), -- Alt+<
  481.     awful.key({ "Mod1"            }, "#60",                  function () awful.util.spawn_with_shell("gksu thunar")                                          end), -- Alt+>
  482.     awful.key({ "Mod1"            }, "F2",                   function () awful.util.spawn_with_shell("dmenu_run -i -p 'Run command:' -nb '" .. beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal .. "' -sb '" .. beautiful.bg_myfocus .. "' -sf '" .. beautiful.fg_myurgent .. "' -fn '-misc-fixed-medium-r-normal-*-15-140-75-75-c-90-iso10646-1'")                                                                                                                                                      end)
  483.     -- }}}
  484. )
  485.  
  486. clientkeys = awful.util.table.join(
  487.     awful.key({ modkey,           }, "#41",                  function (c) c.fullscreen = not c.fullscreen                                                    end), -- Win+f
  488.     awful.key({ modkey, "Shift"   }, "#54",                  function (c) c:kill()                                                                           end), -- Win+Shift+c
  489.     awful.key({ modkey, "Control" }, "space",                awful.client.floating.toggle                                                                       ),
  490.     awful.key({ modkey, "Control" }, "Return",               function (c) c:swap(awful.client.getmaster())                                                   end),
  491.     awful.key({ modkey,           }, "#32",                  awful.client.movetoscreen                                                                          ), -- Win+o
  492.     awful.key({ modkey,           }, "#28",                  function (c) c.ontop = not c.ontop                                                              end), -- Win+t
  493.     awful.key({ modkey,           }, "#57",                                                                                                                        -- Win+n
  494.         function (c)
  495.             -- The client currently has the input focus, so it cannot be
  496.             -- minimized, since minimized clients can't have the focus.
  497.             c.minimized = true
  498.         end),
  499.     awful.key({ modkey,           }, "#58",                                                                                                                        -- Win+m
  500.         function (c)
  501.             c.maximized_horizontal = not c.maximized_horizontal
  502.             c.maximized_vertical   = not c.maximized_vertical
  503.         end)
  504. )
  505.  
  506. -- Bind all key numbers to tags.
  507. -- Be careful: we use keycodes to make it works on any keyboard layout.
  508. -- This should map on the top row of your keyboard, usually 1 to 9.
  509. for i = 1, 9 do
  510.     globalkeys = awful.util.table.join(globalkeys,
  511.         -- View tag only.
  512.         awful.key({ modkey }, "#" .. i + 9,
  513.                   function ()
  514.                         local screen = mouse.screen
  515.                         local tag = awful.tag.gettags(screen)[i]
  516.                         if tag then
  517.                            awful.tag.viewonly(tag)
  518.                         end
  519.                   end),
  520.         -- Toggle tag.
  521.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  522.                   function ()
  523.                       local screen = mouse.screen
  524.                       local tag = awful.tag.gettags(screen)[i]
  525.                       if tag then
  526.                          awful.tag.viewtoggle(tag)
  527.                       end
  528.                   end),
  529.         -- Move client to tag.
  530.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  531.                   function ()
  532.                       if client.focus then
  533.                           local tag = awful.tag.gettags(client.focus.screen)[i]
  534.                           if tag then
  535.                               awful.client.movetotag(tag)
  536.                           end
  537.                      end
  538.                   end),
  539.         -- Toggle tag.
  540.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  541.                   function ()
  542.                       if client.focus then
  543.                           local tag = awful.tag.gettags(client.focus.screen)[i]
  544.                           if tag then
  545.                               awful.client.toggletag(tag)
  546.                           end
  547.                       end
  548.                   end))
  549. end
  550.  
  551. clientbuttons = awful.util.table.join(
  552.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  553.     awful.button({ modkey }, 1, awful.mouse.client.move),
  554.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  555.  
  556. -- Set keys
  557. root.keys(globalkeys)
  558. -- }}}
  559.  
  560. -- {{{ Rules
  561. -- Rules to apply to new clients (through the "manage" signal).
  562. awful.rules.rules = {
  563.     -- All clients will match this rule.
  564.     { rule = { },
  565.       properties = { border_width = beautiful.border_width,
  566.                      border_color = beautiful.border_normal,
  567.                      focus = awful.client.focus.filter,
  568.                      raise = true,
  569.                      keys = clientkeys,
  570.                      buttons = clientbuttons } },
  571.     { rule = { class = "MPlayer" },
  572.        properties = { floating = true } },
  573.     { rule = { class = "pinentry" },
  574.        properties = { floating = true, focus = true } },
  575.     { rule = { class = "gimp" },
  576.       properties = { floating = true } },
  577.     { rule = { class = "galculator" },
  578.       properties = { floating = true, focus = true } },
  579.     { rule = { class = "hexchat" },
  580.       properties = { floating = true, focus = true } },
  581.     { rule = { class = "Firefox" },
  582.        properties = {                   tag = tags[1][1], switchtotag = true, focus = true } },
  583.     { rule = { class = "Opera" },
  584.        properties = {                   tag = tags[1][1], switchtotag = true, focus = true } },
  585.     { rule = { class = "Iron" },
  586.        properties = {                   tag = tags[1][1], switchtotag = true, focus = true } },
  587.     { rule = { class = "Thunderbird" },
  588.        properties = {                   tag = tags[1][2] } },
  589.     { rule = { class = "Subl3"},
  590.        properties = {                   tag = tags[1][3], switchtotag = true, focus = true } },
  591.     { rule = { class = "Doublecmd"},
  592.        properties = {                   tag = tags[1][4], switchtotag = true, focus = true } },
  593.     { rule = { class = "Pcmanfm"},
  594.        properties = {                   tag = tags[1][4], switchtotag = true, focus = true } },
  595.     { rule = { class = "Thunar"},
  596.        properties = {                   tag = tags[1][4], switchtotag = true,  focus = true } },
  597.     { rule = { class = "pacmanxg"},
  598.        properties = {                   tag = tags[1][5], switchtotag = true, focus = true } },
  599.     { rule = { class = "Baobab"},
  600.        properties = {                   tag = tags[1][5], switchtotag = true, focus = true } },
  601.     { rule = { class = "systemdx"},
  602.        properties = {                   tag = tags[1][5], switchtotag = true, maximized_horizontal = true, maximized_vertical = true, focus = true } },
  603.     { rule = { class = "VirtualBox"},
  604.        properties = {                   tag = tags[1][5], switchtotag = true, focus = true } },
  605.     { rule = { class = "GParted"},
  606.        properties = {                   tag = tags[1][5], switchtotag = true, focus = true } },
  607.     { rule = { class = "mpv"},
  608.        properties = {                   tag = tags[1][6], switchtotag = true, focus = true } },
  609.     { rule = { class = "Sopcast-player.py"},
  610.        properties = {                   tag = tags[1][6], switchtotag = true, focus = true } },
  611.     { rule = { class = "Pinta"},
  612.        properties = {                   tag = tags[1][7], switchtotag = true, focus = true } },
  613.     { rule = { class = "feh"},
  614.        properties = {                   tag = tags[1][7], switchtotag = true, focus = true } },
  615.     { rule = { class = "Gthumb"},
  616.        properties = {                   tag = tags[1][7], switchtotag = true, focus = true } },
  617.     { rule = { class = "Gimp"},
  618.        properties = {                   tag = tags[1][7], switchtotag = true, focus = true } },
  619.     { rule = { class = "Gimp-2.8"},
  620.        properties = {                   tag = tags[1][7], switchtotag = true, focus = true } },
  621.     { rule = { class = "Wine"},
  622.        properties = {                   tag = tags[1][8], switchtotag = true, focus = true } },
  623.     { rule = { class = "psi"},
  624.        properties = { tag = tags[1][8], border_width = 0, floating = true, maximized_horizontal = false, maximized_vertical = false, focus = false } },
  625.     { rule = { class = "Tixati"},
  626.        properties = {                   tag = tags[1][9], switchtotag = true, focus = true } },
  627.     { rule = { class = "Transmission-remote-gtk"},
  628.        properties = {                   tag = tags[1][9], switchtotag = true, focus = true } },
  629.     { rule = { class = "Transgui"},
  630.        properties = {                   tag = tags[1][9], switchtotag = true, focus = true } },
  631.     { rule = { class = "Conky"},
  632.        properties = { border_width = 0, floating = true } },
  633.     { rule = { class = "Gis-weather.py"},
  634.        properties = { tag = tags[1][1], border_width = 0, floating = true, maximized_horizontal = false, maximized_vertical = false, focus = false } },
  635.     { rule = { class = "Galculator" },
  636.        properties = { floating = true, maximized_horizontal = false, maximized_vertical = false, focus = true } },
  637.     { rule = { instance = "htop" },
  638.        properties = { floating = true, maximized_horizontal = true, maximized_vertical = true, focus = true } },
  639.     { rule = { instance = "mc" },
  640.        properties = { floating = true, maximized_horizontal = true, maximized_vertical = true, focus = true } },
  641.     { rule = { instance = "nano" },
  642.        properties = { floating = true, maximized_horizontal = true, maximized_vertical = true, focus = true } },
  643.     { rule = { instance = "ncmpcpp" },
  644.        properties = { floating = true, maximized_horizontal = true, maximized_vertical = true, focus = true } }
  645. }
  646. -- }}}
  647.  
  648. -- {{{ Signals
  649. -- Signal function to execute when a new client appears.
  650. client.connect_signal("manage", function (c, startup)
  651.     -- Enable sloppy focus
  652.     c:connect_signal("mouse::enter", function(c)
  653.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  654.             and awful.client.focus.filter(c) then
  655.             client.focus = c
  656.         end
  657.     end)
  658.  
  659.     if not startup then
  660.         -- Set the windows at the slave,
  661.         -- i.e. put it at the end of others instead of setting it master.
  662.         -- awful.client.setslave(c)
  663.  
  664.         -- Put windows in a smart way, only if they does not set an initial position.
  665.         if not c.size_hints.user_position and not c.size_hints.program_position then
  666.             awful.placement.no_overlap(c)
  667.             awful.placement.no_offscreen(c)
  668.         end
  669.     end
  670.  
  671.     local titlebars_enabled = false
  672.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  673.         -- buttons for the titlebar
  674.         local buttons = awful.util.table.join(
  675.                 awful.button({ }, 1, function()
  676.                     client.focus = c
  677.                     c:raise()
  678.                     awful.mouse.client.move(c)
  679.                 end),
  680.                 awful.button({ }, 3, function()
  681.                     client.focus = c
  682.                     c:raise()
  683.                     awful.mouse.client.resize(c)
  684.                 end)
  685.                 )
  686.  
  687.         -- Widgets that are aligned to the left
  688.         local left_layout = wibox.layout.fixed.horizontal()
  689.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  690.         left_layout:buttons(buttons)
  691.  
  692.         -- Widgets that are aligned to the right
  693.         local right_layout = wibox.layout.fixed.horizontal()
  694.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  695.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  696.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  697.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  698.         right_layout:add(awful.titlebar.widget.closebutton(c))
  699.  
  700.         -- The title goes in the middle
  701.         local middle_layout = wibox.layout.flex.horizontal()
  702.         local title = awful.titlebar.widget.titlewidget(c)
  703.         title:set_align("center")
  704.         middle_layout:add(title)
  705.         middle_layout:buttons(buttons)
  706.  
  707.         -- Now bring it all together
  708.         local layout = wibox.layout.align.horizontal()
  709.         layout:set_left(left_layout)
  710.         layout:set_right(right_layout)
  711.         layout:set_middle(middle_layout)
  712.  
  713.         awful.titlebar(c):set_widget(layout)
  714.     end
  715. end)
  716.  
  717. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  718. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  719. -- }}}
  720.  
  721. -- {{{ Run autostarting applications only once
  722. function autostart(cmd, delay)
  723.     delay = delay or 0
  724.     awful.util.spawn_with_shell("pgrep -u $USER -x -f '" .. cmd .. "' || ( sleep " .. delay .. " && " .. cmd .. " )")
  725. end
  726.  
  727. -- Autostart applications. The extra argument is optional, it means how long to
  728. -- delay a command before starting it (in seconds).
  729. autostart("compton -b", 1)
  730. autostart("urxvtd -q -f -o &", 1)
  731. autostart("mpd", 1)
  732. autostart("python3 /home/haron/lib/gis-weather/gis-weather.py", 1)
  733. autostart("xxkb", 1)
  734. -- autostart("thunar --daemon", 1)
  735. -- }}}
  736.  
  737. -- {{{ Run .desktop files with dex
  738. -- Because 'dex' is not an application, autostart("dex -ae Awesome") will always
  739. -- execute every entry (which is unwanted).
  740. local dex_output = io.popen("dex -ade Awesome")
  741. for cmd in dex_output:lines() do
  742.     autostart(cmd:gsub("Executing command: ", ""), 4)
  743. end
  744. dex_output:close()
  745. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement