Advertisement
Guest User

rc.lua

a guest
Dec 18th, 2013
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.08 KB | None | 0 0
  1. local gears = require("gears")
  2. local awful = require("awful")
  3. awful.rules = require("awful.rules")
  4. require("awful.autofocus")
  5. local wibox = require("wibox")
  6. local beautiful = require("beautiful")
  7. local naughty = require("naughty")
  8. local menubar = require("menubar")
  9. local scratch = require("scratch")
  10. wicked = require("wicked")
  11. vicious = require("vicious")
  12.  
  13. -- Error handling
  14. if awesome.startup_errors then
  15.     naughty.notify({ preset = naughty.config.presets.critical,
  16.                      title = "Oops, there were errors during startup!",
  17.                      text = awesome.startup_errors })
  18. end
  19.  
  20. -- Handle runtime errors after startup
  21. do
  22.     local in_error = false
  23.     awesome.connect_signal("debug::error", function (err)
  24.         if in_error then return end
  25.         in_error = true
  26.  
  27.         naughty.notify({ preset = naughty.config.presets.critical,
  28.                          title = "Oops, an error happened!",
  29.                          text = err })
  30.         in_error = false
  31.     end)
  32. end
  33.  
  34. -- Variable definitions
  35. beautiful.init("/home/balalaika/.config/awesome/themes/default/theme.lua")
  36.  
  37. terminal_large = "urxvt -name large"
  38. terminal = "urxvt -e tmux -2"
  39. editor = os.getenv("EDITOR") or "nano"
  40. editor_cmd = terminal .. " -e " .. editor
  41.  
  42. modkey = "Mod4"
  43. modkey1 = "Mod1"
  44.  
  45. -- disable startup-notification globally
  46. local oldspawn = awful.util.spawn
  47. awful.util.spawn = function (s)
  48.   oldspawn(s, false)
  49.   end
  50.  
  51. -- run_once function -------------------------------------------------------------------------------
  52. function run_once(cmd)
  53.    findme = cmd
  54.    firstspace = cmd:find(" ")
  55.    if firstspace then
  56.       findme = cmd:sub(0, firstspace-1)
  57.    end
  58.    awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
  59. end
  60.  
  61. -- run_once("chromium")
  62. run_once("transmission-qt -m")
  63. run_once("parcellite")
  64.  
  65. -- Table of layouts to cover with awful.layout.inc, order matters.
  66. local layouts =
  67. {
  68.     awful.layout.suit.floating,
  69.     awful.layout.suit.tile,
  70.     -- awful.layout.suit.tile.left,
  71.     -- awful.layout.suit.tile.bottom,
  72.     awful.layout.suit.tile.top,
  73.      --awful.layout.suit.fair,
  74.     awful.layout.suit.fair.horizontal,
  75.     -- awful.layout.suit.spiral,
  76.     -- awful.layout.suit.spiral.dwindle,
  77.     awful.layout.suit.max,
  78.     awful.layout.suit.max.fullscreen
  79.     -- awful.layout.suit.magnifier
  80. }
  81.  
  82. -- Tags
  83. tags = {
  84.     names = { "~", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "+" },
  85.     layout = { layouts[2], layouts[5], layouts[1], layouts[1], layouts[1], layouts[5], layouts[1], layouts[1], layouts[1], layouts[1], layouts[1], layouts[1], layouts[1] },
  86.     keynum  =   {   "49",       "10",       "11",       "12",       "13",       "14",       "15",       "16",       "17",       "18",       "19",       "20",       "21",       "22" },
  87.     }
  88. for s = 1, screen.count() do
  89.     tags[s] = awful.tag(tags.names, s, tags.layout)
  90. end
  91.  
  92. -- Menu
  93.  
  94. myawesomemenu = {
  95.    { "manual", terminal .. " -e man awesome" },
  96.    { "edit config", "urxvt -e gvim /home/balalaika/.config/awesome/rc.lua"},
  97.    { "edit theme", "urxvt -e gvim /home/balalaika/.config/awesome/themes/default/theme.lua"},
  98.    { "restart", awesome.restart },
  99.    { "quit", awesome.quit },
  100.    { "screenshot", "bash /home/balalaika/D/Dropbox/scripts/screenshoter_full" },
  101.    { "set wallpaper (scale)", "bash /home/balalaika/D/Dropbox/scripts/choose_wall_scale", beautiful.wallpaper },
  102.    { "set wallpaper (center)", "bash /home/balalaika/D/Dropbox/scripts/choose_wall_center", beautiful.wallpaper },
  103.    { "reboot", "sudo reboot", beautiful.reboot }
  104. }
  105.  
  106. mywebmenu = {
  107.    { "Chromium", "chromium", beautiful.chromium_icon },
  108.    { "Gmail",    "chromium --app=http://gmail.com", beautiful.gmail_icon },
  109.    { "firefox",  "firefox", beautiful.firefox_icon }
  110. }
  111.  
  112. mydevmenu = {
  113.    { "Sublime-text", "subl", beautiful.sublime_icon },
  114.    { "Xephyr_awesome", "/home/balalaika/.config/awesome/xephyr" },
  115.    { "Xephyr_restart", "home/balalaika/.config/awesome/xephyr_awesome_restart" }
  116. }
  117.  
  118. mymediamenu = {
  119.    { "Deadbeef", "deadbeef", beautiful.deadbeef_icon }
  120. }
  121.  
  122. mygraphicsmenu = {
  123.    { "Gimp",     "gimp", beautiful.gimp_icon },
  124.    { "Gthumb",   "gthumb", beautiful.snowman_icon }
  125. }
  126. mydocsmenu = {
  127.    { "Okular",   "okular", beautiful.okular_icon }
  128. }
  129. myvirtmenu = {
  130.     { "winXP", "VirtualBox --startvm win-XP --fullscreen", beautiful.virt_winxp_icon }
  131. }
  132. myxfreerdpmenu = {
  133.     { "job_1.1.1.49", "xfreerdp -a 16 --plugin cliprdr 1.1.1.49" },
  134.     { "job_192.168.0.61", "xfreerdp -a 16 --plugin cliprdr 192.168.0.61" }
  135. }
  136.  
  137. mymainmenu = awful.menu({ items = { { "@wesome", myawesomemenu, beautiful.awesome_icon },
  138.                     { "web",     mywebmenu                             },
  139.                     { "media",   mymediamenu                           },
  140.                     { "dev",     mydevmenu                             },
  141.                     { "graphics",mygraphicsmenu                        },
  142.                     { "docs",    mydocsmenu                            },
  143.                     { "VBox",    myvirtmenu                            },
  144.                     { "Rdp",     myxfreerdpmenu                        },
  145.                                     { "open terminal", terminal }
  146.                                   }, theme = { width = 150 }
  147.                         })
  148. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  149.                                      menu = mymainmenu })
  150.  
  151. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  152.  
  153. -- Spacer
  154. spacer = wibox.widget.textbox(" ")
  155. spacer1 = wibox.widget.textbox("::")
  156. -- ( symbol
  157. mark1 = wibox.widget.textbox()
  158. mark1:set_text("(")
  159. -- ) symbol
  160. mark2 = wibox.widget.textbox()
  161. mark2:set_text(")")
  162. -- [ symbol
  163. mark3 = wibox.widget.textbox()
  164. mark3:set_text("[")
  165. colormark3 = wibox.widget.background()
  166. colormark3:set_widget(mark3)
  167. colormark3:set_fg("#B82D2D")
  168. -- ] symbol
  169. mark4 = wibox.widget.textbox()
  170. mark4:set_text("]")
  171. colormark4 = wibox.widget.background()
  172. colormark4:set_widget(mark4)
  173. colormark4:set_fg("#B82D2D")
  174.  
  175. -- Create a textclock widget
  176. mytextclock = wibox.widget.textbox()
  177. vicious.register(mytextclock, vicious.widgets.date, "%e_%B_%A > %R", 61)
  178. ----------------------------------------------------------------------------------------------------------
  179. music = wibox.widget.imagebox("/home/balalaika/.config/awesome/icons/vol.png")
  180. -- music.image = image( "/home/balalaika/.config/awesome/icons/vol.png" )
  181. music:buttons(awful.util.table.join(
  182.       awful.button({ }, 3, function () awful.util.spawn("amixer -q set Master mute", false) end),
  183.       awful.button({ }, 4, function () awful.util.spawn("amixer -q set Master 2dB+ unmute", false) end),
  184.       awful.button({ }, 5, function () awful.util.spawn("amixer -q set Master 2dB- unmute", false) end)))
  185. ----------------------------------------------------------------------------------------------------------
  186.  
  187. -- Volume percent
  188. volumewidget = wibox.widget.textbox()
  189.   vicious.register(volumewidget, vicious.widgets.volume,
  190.   function(widget, args)
  191.      local label = { ["#"] = "O", ["#"] = "M" }
  192.      return args[1]
  193.   end, 1, "Master")
  194. ---------------------------------------------------------------------------------------------------------
  195. -- transmission
  196. --transicon = wibox.widget.imagebox()
  197. --trans = wibox.widget.textbox()
  198. --local function script_output()
  199.       --out = awful.util.pread("/home/balalaika/D/Dropbox/development/transmission.py")
  200.      --if out ~= "\n" then
  201.          --transicon:set_image("/home/balalaika/.config/awesome/icons1/download-cloud.png")
  202.      --else
  203.          --out = ""
  204.          --transicon:set_image(nil)
  205.      --end
  206.         --return out
  207. --end
  208. --vicious.register(trans, script_output, "$1")
  209.  
  210. -- TurnOff
  211. turnoff_image = wibox.widget.imagebox("/home/balalaika/.config/awesome/icons/system-shutdown.png")
  212. turnoff_image:fit(8,8)
  213. turnoff_image:buttons(awful.util.table.join(
  214.     awful.button({ }, 1, function () awful.util.spawn("sudo halt") end)))
  215. ---------------------------------------------------------------------------------------------------------
  216.  
  217. -- Gmail
  218. mailicon = wibox.widget.imagebox()
  219. mailwidget = wibox.widget.textbox()
  220. vicious.register(mailwidget, vicious.widgets.gmail,
  221. function(widget, args)
  222.     if (args["{count}"] > 0) then
  223.         mailicon:set_image("/home/balalaika/.config/awesome/icons/mail.png")
  224.         mail = args["{count}"] .. ":" .. args["{subject}"]
  225.         if not test or test < args["{count}"] -- play music, only if count biggest 0
  226.             then
  227.                 awful.util.spawn_with_shell("mplayer /home/balalaika/.sounds/tutturuu.wav")
  228.                 test = args["{count}"]
  229.             else
  230.                 test = args["{count}"] end
  231.     else
  232.         mail = ""
  233.         mailicon:set_image(nil)
  234.         test = nil
  235.     end
  236.     return mail
  237. end, 60)
  238. mailicon:buttons(awful.util.table.join(
  239.  awful.button({ }, 1, function () awful.util.spawn("chromium --app=http://gmail.com") end)))
  240. --------------------------------------------------------------------------------------------------------
  241.  
  242. -- Cpu graph
  243. graphwidth = 100
  244. graphheight = 16
  245. cpu_background_color = "#222222"
  246. cpu_gradient_color = "#5431CB"
  247. cpuicon = wibox.widget.imagebox()
  248. cpuicon:set_image("/home/balalaika/.config/awesome/icons/cpu.png")
  249. cpugraph = awful.widget.graph()
  250. cpugraph:set_width(graphwidth):set_height(graphheight)
  251. cpugraph:set_border_color(nil)
  252. -- cpugraph:set_border_color(beautiful.bg_widget)
  253. cpugraph:set_background_color(cpu_background_color)
  254. cpugraph:set_color('#5431CB')
  255. cpugraph:set_stack_colors({ '#AECF96', '#88A175', '#FF5656' })
  256. vicious.register(cpugraph, vicious.widgets.cpu, "$1")
  257. ---------------------------------------------------------------------------------------------------------------
  258.  
  259. -- LoadAverage
  260. lawidget = wibox.widget.textbox()
  261. latimer = timer({ timeout = 5 })
  262.     latimer:connect_signal( "timeout", function()  
  263.     local loadavr = awful.util.pread("cat /proc/loadavg| awk '{ print $1 }'")
  264.     lawidget:set_text(loadavr)    
  265. end)
  266. latimer:start()
  267. --------------------------------------------------------------------------------------------------------------
  268.  
  269. -- DiskSpace
  270. diskicon = wibox.widget.imagebox("/home/balalaika/.config/awesome/icons/disk.png")
  271. droot = wibox.widget.textbox()
  272. dusr = wibox.widget.textbox()
  273. dhome = wibox.widget.textbox()
  274. dy = wibox.widget.textbox()
  275. dw = wibox.widget.textbox()
  276. dd = wibox.widget.textbox()
  277.  
  278. vicious.register(droot, vicious.widgets.fs, -- root
  279. function(widget, args)
  280.     if tonumber(args["{/ avail_gb}"]) < 5 then
  281.         return "root: " .. "<span color='#FA9E40'>" .. args['{/ avail_gb}'] .." </span>"
  282.     else
  283.         return "root: " ..  args["{/ avail_gb}"]
  284.     end
  285.     end,60)
  286.  
  287. vicious.register(dusr, vicious.widgets.fs, -- usr
  288. function(widget, args)
  289.     if tonumber(args["{/usr avail_gb}"]) < 5 then
  290.         return "usr: " .. "<span color='#FA9E40'>" .. args['{/usr avail_gb}'] .." </span>"
  291.     else
  292.         return "usr: " ..  args["{/usr avail_gb}"]
  293.     end
  294.     end,60)
  295.  
  296. vicious.register(dhome, vicious.widgets.fs, -- home
  297. function(widget, args)
  298.     if tonumber(args["{/home avail_gb}"]) < 5 then
  299.         return "home: " .. "<span color='#FA9E40'>" .. args['{/home avail_gb}'] .." </span>"
  300.     else
  301.         return "home: " ..  args["{/home avail_gb}"]
  302.     end
  303.     end,60)
  304.  
  305. vicious.register(dy, vicious.widgets.fs, -- Y
  306. function(widget, args)
  307.     if tonumber(args["{/home/balalaika/Y avail_gb}"]) < 5 then
  308.         return "Y: " .. "<span color='#FA9E40'>" .. args['{/home/balalaika/Y avail_gb}'] .." </span>"
  309.     else
  310.         return "Y: " ..  args["{/home/balalaika/Y avail_gb}"]
  311.     end
  312.     end,60)
  313.  
  314. vicious.register(dd, vicious.widgets.fs, -- D
  315. function(widget, args)
  316.     if tonumber(args["{/home/balalaika/D avail_gb}"]) < 5 then
  317.         return "D: " .. "<span color='#FA9E40'>" .. args['{/home/balalaika/Y avail_gb}'] .." </span>"
  318.     else
  319.         return "D: " ..  args["{/home/balalaika/D avail_gb}"]
  320.     end
  321.     end,60)
  322. --------------------------------------------------------------------------------------------------------------
  323.  
  324. -- Create a wibox
  325. mywibox = {}
  326. mytopwibox = {}
  327. mypromptbox = {}
  328. mylayoutbox = {}
  329. mytaglist = {}
  330. mytaglist.buttons = awful.util.table.join(
  331.                     awful.button({ }, 1, awful.tag.viewonly),
  332.                     awful.button({ modkey }, 1, awful.client.movetotag),
  333.                     awful.button({ }, 3, awful.tag.viewtoggle),
  334.                     awful.button({ modkey }, 3, awful.client.toggletag),
  335.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  336.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  337.                     )
  338. mytasklist = {}
  339. mytasklist.buttons = awful.util.table.join(
  340.                      awful.button({ }, 1, function (c)
  341.                                               if c == client.focus then
  342.                                                   c.minimized = true
  343.                                               else
  344.                                                   -- Without this, the following
  345.                                                   -- :isvisible() makes no sense
  346.                                                   c.minimized = false
  347.                                                   if not c:isvisible() then
  348.                                                       awful.tag.viewonly(c:tags()[1])
  349.                                                   end
  350.                                                   -- This will also un-minimize
  351.                                                   -- the client, if needed
  352.                                                   client.focus = c
  353.                                                   c:raise()
  354.                                               end
  355.                                           end),
  356.                      awful.button({ }, 2, function (c) c:kill() end),
  357.                      awful.button({ }, 3, function ()
  358.                                               if instance then
  359.                                                   instance:hide()
  360.                                                   instance = nil
  361.                                               else
  362.                                                   instance = awful.menu.clients({ width=250 })
  363.                                               end
  364.                                           end),
  365.                      awful.button({ }, 4, function ()
  366.                                               awful.client.focus.byidx(1)
  367.                                               if client.focus then client.focus:raise() end
  368.                                           end),
  369.                      awful.button({ }, 5, function ()
  370.                                               awful.client.focus.byidx(-1)
  371.                                               if client.focus then client.focus:raise() end
  372.                                           end))
  373.  
  374. for s = 1, screen.count() do
  375.     mypromptbox[s] = awful.widget.prompt()
  376.     mylayoutbox[s] = awful.widget.layoutbox(s)
  377.     mylayoutbox[s]:buttons(awful.util.table.join(
  378.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  379.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  380.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  381.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  382.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  383.  
  384.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  385.  
  386.     mywibox[s] = awful.wibox({ position = "bottom", height = "16", screen = s })
  387.     mytopwibox[s] = awful.wibox({ position = "top", height = "16", screen = s })
  388.  
  389.     local left_layout = wibox.layout.fixed.horizontal()
  390.     left_layout:add(mylauncher)
  391.     left_layout:add(spacer)
  392.     left_layout:add(mytaglist[s])
  393.     left_layout:add(mypromptbox[s])
  394.  
  395.     local right_layout = wibox.layout.fixed.horizontal()
  396.  
  397.     right_layout:add(mailicon)
  398.     right_layout:add(mailwidget)
  399.     right_layout:add(spacer)
  400.     right_layout:add(diskicon)
  401.     right_layout:add(spacer)
  402.     right_layout:add(colormark3)
  403.     right_layout:add(droot)
  404.     right_layout:add(colormark4)
  405.     right_layout:add(spacer)
  406.     right_layout:add(colormark3)
  407.     right_layout:add(dusr)
  408.     right_layout:add(colormark4)
  409.     right_layout:add(spacer)
  410.     right_layout:add(colormark3)
  411.     right_layout:add(dhome)
  412.     right_layout:add(colormark4)
  413.     right_layout:add(spacer)
  414.     right_layout:add(colormark3)
  415.     right_layout:add(dy)
  416.     right_layout:add(colormark4)
  417.     right_layout:add(spacer)
  418.     -- right_layout:add(colormark3)
  419.     -- right_layout:add(dw)
  420.     -- right_layout:add(colormark4)
  421.     -- right_layout:add(spacer)
  422.     right_layout:add(colormark3)
  423.     right_layout:add(dd)
  424.     right_layout:add(colormark4)
  425.     right_layout:add(spacer)
  426.     right_layout:add(spacer1)
  427.     right_layout:add(spacer)
  428.     right_layout:add(cpuicon)
  429.     right_layout:add(mark1)
  430.     right_layout:add(lawidget)
  431.     right_layout:add(mark2)
  432.     right_layout:add(spacer)
  433.     right_layout:add(cpugraph)
  434.     right_layout:add(spacer)
  435.     right_layout:add(music)
  436.     right_layout:add(spacer)
  437.     right_layout:add(volumewidget)
  438.     right_layout:add(spacer)
  439.     right_layout:add(spacer1)
  440.     right_layout:add(spacer)
  441.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  442.     right_layout:add(spacer)
  443.     right_layout:add(spacer1)
  444.     right_layout:add(spacer)
  445.     right_layout:add(mytextclock)
  446.     right_layout:add(spacer)
  447.     -- right_layout:add(mylayoutbox[s])
  448.     right_layout:add(turnoff_image)
  449.  
  450.     local layout = wibox.layout.align.horizontal()
  451.     local layout_top = wibox.layout.align.horizontal()
  452.  
  453.     layout:set_left(left_layout)
  454.     layout:set_right(right_layout)
  455.  
  456.     layout_top:set_middle(mytasklist[s])                                                            
  457.     layout_top:set_right(mylayoutbox[s])
  458.  
  459.  
  460.     mytopwibox[s]:set_widget(layout_top)
  461.     mywibox[s]:set_widget(layout)
  462. end
  463. ---------------------------------------------------------------------------------------------------------------------------
  464.  
  465. -- Run or rise
  466. function run_or_raise(cmd, properties)
  467.    local clients = client.get()
  468.    local focused = awful.client.next(0)
  469.    local findex = 0
  470.    local matched_clients = {}
  471.    local n = 0
  472.    for i, c in pairs(clients) do
  473.       if match(properties, c) then
  474.          n = n + 1
  475.          matched_clients[n] = c
  476.          if c == focused then
  477.             findex = n
  478.          end
  479.       end
  480.    end
  481.    if n > 0 then
  482.       local c = matched_clients[1]
  483.       if 0 < findex and findex < n then
  484.          c = matched_clients[findex+1]
  485.       end
  486.       local ctags = c:tags()
  487.       if #ctags == 0 then
  488.          local curtag = awful.tag.selected()
  489.          awful.client.movetotag(curtag, c)
  490.       else
  491.          awful.tag.viewonly(ctags[1])
  492.       end
  493.       client.focus = c
  494.       c:raise()
  495.       return
  496.    end
  497.    awful.util.spawn(cmd)
  498. end
  499.  
  500. function match (table1, table2)
  501.    for k, v in pairs(table1) do
  502.       if table2[k] ~= v and not table2[k]:find(v) then
  503.          return false
  504.       end
  505.    end
  506.    return true
  507. end
  508. ------------------------------------------------------------------------------------------------------------------------
  509.  
  510. -- Mouse bindings
  511. root.buttons(awful.util.table.join(
  512.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  513.     awful.button({ }, 4, awful.tag.viewnext),
  514.     awful.button({ }, 5, awful.tag.viewprev)
  515. ))
  516.  
  517. -- Key bindings
  518. globalkeys = awful.util.table.join(
  519.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  520.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  521.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  522.  
  523.     awful.key({ modkey,           }, "j",
  524.         function ()
  525.             awful.client.focus.byidx( 1)
  526.             if client.focus then client.focus:raise() end
  527.         end),
  528.     awful.key({ modkey,           }, "k",
  529.         function ()
  530.             awful.client.focus.byidx(-1)
  531.             if client.focus then client.focus:raise() end
  532.         end),
  533.     -- awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  534.  
  535.     -- Layout manipulation
  536.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  537.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  538.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  539.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  540.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  541.     awful.key({ modkey1,           }, "Tab",
  542.         function ()
  543.         awful.client.focus.byidx(1)
  544.             if client.focus then
  545.                 client.focus:raise()
  546.             end
  547.         end),
  548.  
  549.     -- Standard program
  550.     awful.key({ modkey, "Control" }, "w",      function () awful.util.spawn_with_shell("/home/balalaika/D/Dropbox/scripts/choose_wall") end),
  551.     awful.key({ modkey, "Control" }, "d",      function () awful.util.spawn_with_shell("/home/balalaika/D/Dropbox/scripts/dmenu_deadbeef") end),
  552.     awful.key({ modkey,           }, "F9",     function () awful.util.spawn_with_shell("/home/balalaika/D/Dropbox/scripts/screenshoter") end),
  553.     awful.key({ modkey,           }, "F8",     function () awful.util.spawn_with_shell("/home/balalaika/D/Dropbox/scripts/screenshoter_full") end),
  554.     awful.key({ modkey, "Shift"   }, "n",      function () awful.util.spawn_with_shell("/home/balalaika/D/Dropbox/development/nowplay") end),
  555.     awful.key({ modkey,           }, "F1",     function () awful.util.spawn("amixer -q set Master 5dB- unmute") end),
  556.     awful.key({ modkey,           }, "F2",     function () awful.util.spawn("amixer -q set Master 5dB+ unmute") end),
  557.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  558.     awful.key({ modkey, "Shift"   }, "Return", function () awful.util.spawn(terminal_large) end),
  559.     awful.key({ modkey,           }, "e",      function () scratch.drop("urxvt -name explorer -e tmux -c 'ranger /home/balalaika/Y'", "center", nil, 0.80, 0.90) end),
  560.     awful.key({ modkey,           }, "w",      function () run_or_raise("chromium", { class = "Chromium-browser" }) end),
  561.     awful.key({ modkey, "Shift"   }, "m",      function () run_or_raise("deadbeef", { class = "Deadbeef" }) end),
  562.     awful.key({ modkey, "Shift"   }, "g",      function () run_or_raise("gimp", { class = "Gimp" }) end),
  563.     awful.key({ modkey,           }, "F4",     function () awful.util.spawn("sudo halt") end),
  564.     awful.key({ modkey,           }, "u",      function () scratch.drop("urxvt", "up", nil, 0.50, 0.30) end),
  565.     awful.key({ modkey,           }, "x",      function () run_or_raise("keepassx", { class = "Keepassx" }) end),
  566.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  567.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  568.  
  569.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  570.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  571.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  572.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  573.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  574.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  575.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  576.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  577.  
  578.     awful.key({ modkey, "Control" }, "n",                 awful.client.restore),
  579.     awful.key({ modkey, "Shift"   }, "t",    
  580.     function ()
  581.         local trs = io.popen("trs {=ru} $(xclip -o)")
  582.         local trs_result = trs:read("*a")
  583.             return naughty.notify({ preset = naughty.config.defaults,
  584.                         text = trs_result })
  585.     end),
  586.  
  587.     -- To Do Prompt
  588.     awful.key({ modkey, "Shift"   }, "o", function ()
  589.               local todo = awful.util.pread("/home/balalaika/soft/todo/todo.sh ls")
  590.               todo = naughty.notify({
  591.                                      text = "<b><u>todo</u></b>\n" .. "\n" .. todo,
  592.                      timeout = 10
  593.                  })
  594.       end),
  595.     awful.key({ modkey },            "r",     function () awful.util.spawn("gmrun") end)
  596. )
  597.  
  598. clientkeys = awful.util.table.join(
  599.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  600.     awful.key({ modkey,           }, "c",      function (c) c:kill()                         end),
  601.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  602.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  603.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  604.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  605.     awful.key({ modkey,           }, "n",
  606.         function (c)
  607.             c.minimized = true
  608.         end),
  609.     awful.key({ modkey,           }, "m",
  610.         function (c)
  611.             c.maximized_horizontal = not c.maximized_horizontal
  612.             c.maximized_vertical   = not c.maximized_vertical
  613.         end)
  614. )
  615.  
  616. keynumber = 0
  617. for s = 1, screen.count() do
  618.    keynumber = math.min(20, math.max(#tags[s], keynumber))
  619. end
  620.  
  621. for i = 1, keynumber do
  622.     globalkeys = awful.util.table.join(globalkeys,
  623.         awful.key({ modkey },           "#" .. tags.keynum[i],
  624.                   function ()
  625.                         local screen = mouse.screen
  626.                         if tags[screen][i] then
  627.                             awful.tag.viewonly(tags[screen][i])
  628.                         end
  629.                   end),
  630.         awful.key({ modkey, "Shift" },  "#" .. tags.keynum[i],
  631.                   function ()
  632.                       if client.focus and tags[client.focus.screen][i] then
  633.                           awful.client.movetotag(tags[client.focus.screen][i])
  634.                       end
  635.                   end))
  636. end
  637.  
  638.  
  639. clientbuttons = awful.util.table.join(
  640.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  641.     awful.button({ modkey }, 1, awful.mouse.client.move),
  642.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  643.  
  644. root.keys(globalkeys)
  645. ------------------------------------------------------------------------------------------------------------------
  646.  
  647. -- Rules
  648. awful.rules.rules = {
  649.     { rule = { },
  650.       properties = { border_width = beautiful.border_width,
  651.                      border_color = beautiful.border_normal,
  652.                      focus = awful.client.focus.filter,
  653.                      keys = clientkeys,
  654.                      buttons = clientbuttons } },
  655.     { rule = { class = "Xephyr" },
  656.       properties = { callback = awful.placement.centered }},
  657.  
  658.     { rule = { class = "Transmission-qt" },
  659.       properties = { floating = true, callback = awful.placement.centered }},
  660.  
  661.     { rule = { class = "Keepassx" },
  662.       properties = { floating = true,
  663.       callback = awful.placement.centered }},
  664.  
  665.     { rule = { class = "Gmrun" },
  666.       properties = { floating = true, callback = function(c) c:geometry({x=600, y=20}) end }},
  667.    
  668.      { rule = { class = "Chromium-browser" },
  669.       properties = { tag = tags[1][4], border_width = 0 } },
  670.  
  671.      { rule = { class = "Firefox" },
  672.       properties = { tag = tags[1][4], border_width = 0 } },
  673.  
  674.     { rule = { class = "feh" },
  675.       properties = { floating = true,
  676.       callback = awful.placement.centered }},
  677.  
  678.     { rule = { class = "MPlayer" },
  679.       properties = { floating = true, ontop = true } },
  680.  
  681.     { rule = { class = "pinentry" },
  682.       properties = { floating = true } },
  683.  
  684.     { rule = { class = "Gimp" },
  685.       properties = { floating = true, tag = tags[1][5], border_width = 0 } },
  686.  
  687.     { rule = { class = "Deadbeef" },
  688.       properties = { border_width = 0, tag = tags[1][6] } },
  689.  
  690.     { rule = { class = "Gcolor2" },
  691.       properties = { floating = true, ontop = true }},
  692.  
  693.      { rule = { class = "Zathura" },
  694.       properties = { maximized_vertical = true, maximized_horizontal = true, border_width = 0 } },
  695.  
  696.      { rule = { class = "URxvt" },
  697.       properties = { border_width = 0 } },
  698.  
  699.      { rule = { class = "URxvt", instance = "explorer" },
  700.       properties = { border_width = 4 } },
  701.  
  702.      { rule = { name = "Save File" },
  703.       properties = { border_width = 4 } },
  704.  
  705.      { rule = { name = "Select a wallpaper" },
  706.       properties = { border_width = 4, callback = awful.placement.centered } },
  707.  
  708.     -- { rule = { class = "Tint2" }, properties = { skip_taskbar = true, skip_taglist = true }},
  709.     -- { rule = { class = "VirtualBox" }, name = { "Oracle VM VirtualBox Manager" },
  710.     -- properties = { floating = true, callback = awful.titlebar.add }},
  711. }
  712. ---------------------------------------------------------------------------------------------------------------------
  713.  
  714. -- Signals
  715. -- Signal function to execute when a new client appears.
  716. client.connect_signal("manage", function (c, startup)
  717.     c.size_hints_honor = false
  718.     c:connect_signal("mouse::enter", function(c)
  719.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  720.             and awful.client.focus.filter(c) then
  721.             client.focus = c
  722.         end
  723.     end)
  724.  
  725.     if not startup then
  726.         -- Set the windows at the slave,
  727.         -- i.e. put it at the end of others instead of setting it master.
  728.         -- awful.client.setslave(c)
  729.  
  730.         -- Put windows in a smart way, only if they does not set an initial position.
  731.         if not c.size_hints.user_position and not c.size_hints.program_position then
  732.             awful.placement.no_overlap(c)
  733.             awful.placement.no_offscreen(c)
  734.         end
  735.     end
  736.  
  737.     local titlebars_enabled = false
  738.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  739.         -- Widgets that are aligned to the left
  740.         local left_layout = wibox.layout.fixed.horizontal()
  741.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  742.  
  743.         -- Widgets that are aligned to the right
  744.         local right_layout = wibox.layout.fixed.horizontal()
  745.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  746.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  747.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  748.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  749.         right_layout:add(awful.titlebar.widget.closebutton(c))
  750.  
  751.         -- The title goes in the middle
  752.         local title = awful.titlebar.widget.titlewidget(c)
  753.         title:buttons(awful.util.table.join(
  754.                 awful.button({ }, 1, function()
  755.                     client.focus = c
  756.                     c:raise()
  757.                     awful.mouse.client.move(c)
  758.                 end),
  759.                 awful.button({ }, 3, function()
  760.                     client.focus = c
  761.                     c:raise()
  762.                     awful.mouse.client.resize(c)
  763.                 end)
  764.                 ))
  765.  
  766.         -- Now bring it all together
  767.         local layout = wibox.layout.align.horizontal()
  768.         layout:set_left(left_layout)
  769.         layout:set_right(right_layout)
  770.         layout:set_middle(title)
  771.  
  772.         awful.titlebar(c):set_widget(layout)
  773.     end
  774. end)
  775.  
  776. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  777. --client.connect_signal("focus",
  778.                           --function(c)
  779.                    --if c.maximized_horizontal and c.maximized_vertical then
  780.                      --c.border_width = "0"
  781.                      --c.border_color = beautiful.border_focus
  782.                    --else
  783.                      --c.border_width = beautiful.border_width
  784.                      --c.border_color = beautiful.border_focus
  785.                    --end
  786. --end)
  787. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  788. -----------------------------------------------------------------------------------------------------------------------
  789. function autostart(dir)
  790.     if not dir then
  791.         do return nil end
  792.     end
  793.     local fd = io.popen("ls -1 -F " .. dir)
  794.     if not fd then
  795.         do return nil end
  796.     end
  797.     for file in fd:lines() do
  798.         local c= string.sub(file,-1)
  799.         if c=='*' then  
  800.             executable = string.sub( file, 1,-2 )
  801.             print("Автозапуск Awesome: Запускается: " .. executable)
  802.             awful.util.spawn_with_shell(dir .. "/" .. executable .. "")
  803.         elseif c=='@' then
  804.             print("Автозапуск Awesome: Игнорируется символьная ссылка: " .. file)
  805.         else
  806.             print ("Автозапуск Awesome: Игнорируется неисполняемый файл " .. file)
  807.         end
  808.     end
  809.     io.close(fd)
  810. end
  811.  
  812. autostart_dir = os.getenv("HOME") .. "/.config/awesome/autorun"
  813. autostart(autostart_dir)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement