awesome/my.lua
changeset 11 7226709dc4c4
parent 9 56e80afa3e1c
child 12 ffc02bf394cb
equal deleted inserted replaced
10:449bcf8e92c2 11:7226709dc4c4
     1 require("naughty")
     1 local naughty = require("naughty")
     2 require("awful")
     2 local awful = require("awful")
     3 require("debug")
     3 local debug = require("debug")
     4 require("vicious")
     4 local vicious = require("vicious")
     5 require("wicked")
     5 local wicked = require("wicked")
     6 require("beautiful")
     6 local beautiful = require("beautiful")
     7 require("timer")
     7 local timer = require("timer")
       
     8 local wibox = require("wibox")
     8 
     9 
     9 local ipairs = ipairs
    10 local ipairs = ipairs
    10 local pairs = pairs
    11 local pairs = pairs
    11 local naughty = naughty
       
    12 local awful = awful
       
    13 local debug = debug
       
    14 local vicious = vicious
       
    15 local wicked = wicked
       
    16 local beautiful = beautiful
       
    17 local timer = timer
       
    18 
    12 
    19 local capi = {
    13 local capi = {
    20    keygrabber = keygrabber,
    14    keygrabber = keygrabber,
    21    client = client,
    15    client = client,
    22    string = string,
    16    string = string,
    23    widget = widget,
    17    widget = widget,
    24 }
    18 }
    25 
    19 
    26 module("my")
    20 module("my")
       
    21 
       
    22 local function get_gradient_colors(c1, c2, c3)
       
    23    return { type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, c1 }, { 0.5, c2 }, { 1, c3 } }}
       
    24 end
    27 
    25 
    28 local in_error = false
    26 local in_error = false
    29 function notify_error(err)
    27 function notify_error(err)
    30    -- Make sure we don't go into an endless error loop
    28    -- Make sure we don't go into an endless error loop
    31    if in_error then return end
    29    if in_error then return end
    73 local function widgets_cpu()
    71 local function widgets_cpu()
    74    local w = awful.widget.graph()
    72    local w = awful.widget.graph()
    75    -- Graph properties
    73    -- Graph properties
    76    w:set_width(30)
    74    w:set_width(30)
    77    w:set_background_color("#729fcf")
    75    w:set_background_color("#729fcf")
    78    w:set_gradient_colors({ "#729fcf", "LightBlue", "white" })
    76    w:set_color(get_gradient_colors("#729fcf", "LightBlue", "white"))
    79 -- Register widget
    77 -- Register widget
    80    vicious.register(w, vicious.widgets.cpu, "$1", 1)
    78    vicious.register(w, vicious.widgets.cpu, "$1", 1)
    81    return w
    79    return w
    82 end
    80 end
    83 
    81 
    84 local function widgets_mdp()
    82 local function widgets_mdp()
    85    -- Initialize widget
    83    -- Initialize widget
    86    local w = capi.widget({ type = "textbox" })
    84    local w = wibox.widget.textbox()
    87    -- Register widget
    85    -- Register widget
    88    vicious.register(w, vicious.widgets.mpd,
    86    vicious.register(w, vicious.widgets.mpd,
    89                     function (widget, args)
    87                     function (widget, args)
    90                        if args["{state}"] == "Stop" then 
    88                        if args["{state}"] == "Stop" then 
    91                           return " - "
    89                           return " - "
   101    local w = awful.widget.progressbar()
    99    local w = awful.widget.progressbar()
   102 -- Progressbar properties
   100 -- Progressbar properties
   103    w:set_width(10)
   101    w:set_width(10)
   104    w:set_vertical(true)
   102    w:set_vertical(true)
   105    w:set_background_color("#729fcf")
   103    w:set_background_color("#729fcf")
   106    w:set_gradient_colors({ "#729fcf", "LightBlue", "white" })
   104    w:set_color(get_gradient_colors("#729fcf", "LightBlue", "white"))
   107 -- Register widget
   105 -- Register widget
   108    vicious.register(w, vicious.widgets.mem, "$1", 5)
   106    vicious.register(w, vicious.widgets.mem, "$1", 5)
   109    return w
   107    return w
   110 end
   108 end
   111 
   109 
   112 local function widgets_net(device)
   110 local function widgets_net(device)
   113    local w = capi.widget({ type = "textbox"})
   111    local w = wibox.widget.textbox()
   114    -- w:set_vertical(true)
   112    -- w:set_vertical(true)
   115    w.width = 150
   113    w.width = 150
   116    w.align = 'center'
   114    w.align = 'center'
   117    vicious.register(w, wicked.widgets.net,
   115    vicious.register(w, wicked.widgets.net,
   118                     '${' .. device .. ' up} / ${' .. device .. ' down}',
   116                     '${' .. device .. ' up} / ${' .. device .. ' down}',
   119                    1)
   117                    1)
   120    return w
   118    return w
   121 end
   119 end
   122 
   120 
   123 local function widgets_mode()
   121 local function widgets_mode()
   124    local w = capi.widget({ type = "textbox"})
   122    local w = wibox.widget.textbox()
   125    widgets.mode_widget = w
   123    widgets.mode_widget = w
   126    return w
   124    return w
   127 end
   125 end
   128 
   126 
   129 local function widgets_keyboard()
   127 local function widgets_keyboard()
   130    local w = capi.widget({ type = "textbox"})
   128    local w = wibox.widget.textbox()
   131    widgets.keyboard_widget = w
   129    widgets.keyboard_widget = w
   132    return w
   130    return w
   133 end
   131 end
   134 
   132 
   135 local function widgets_decorated(w, onclick)
   133 local function widgets_decorated(w, onclick)
   309 sloppy_last_client = nil
   307 sloppy_last_client = nil
   310 sloppy_timer = nil
   308 sloppy_timer = nil
   311 
   309 
   312 function sloppy_install(delay)
   310 function sloppy_install(delay)
   313    sloppy_timer = timer({ timeout = delay })
   311    sloppy_timer = timer({ timeout = delay })
   314    sloppy_timer:add_signal("timeout", sloppy_on_timeout)
   312    sloppy_timer:connect_signal("timeout", sloppy_on_timeout)
   315    sloppy_timer:start()
   313    sloppy_timer:start()
   316    capi.client.add_signal("manage", function (c)
   314    capi.client.connect_signal("manage", function (c)
   317                              c:add_signal("mouse::enter", sloppy_mouse_enter)
   315                              c:connect_signal("mouse::enter", sloppy_mouse_enter)
   318    end)
   316    end)
   319    capi.client.add_signal("focus", function () sloppy_timer:stop() end)
   317    capi.client.connect_signal("focus", function () sloppy_timer:stop() end)
   320 end
   318 end