Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("awful")
- require("awful.autofocus")
- require("awful.rules")
- require("beautiful")
- require("naughty")
- require("vicious")
- require("debian.menu")
- require("awesompd")
- require("obvious.popup_run_prompt")
- require("orglendar")
- require("org-awesome")
- -- Useful functions and tools
- function run_once(program)
- local bin = program
- --local _, _, bin = string.find(program, "([^ ]+).*")
- local bus = io.popen("ps aux | grep '" .. bin .. "' | wc -l")
- local pcount = bus:read("*line")
- print("Pcount : " .. pcount)
- bus:close()
- if tonumber(pcount) < 3 then
- awful.util.spawn(program)
- end
- end
- function repeat_every(func, seconds)
- func()
- local t = timer({ timeout = seconds })
- t:add_signal("timeout", func)
- t:start()
- end
- function pop_spaces(s1,s2,maxsize)
- local sps = ""
- for i = 1, maxsize-string.len(s1)-string.len(s2) do
- sps = sps .. " "
- end
- return s1 .. sps .. s2
- end
- -- Autorun programs
- autorun = true
- autorunApps =
- {
- "setxkbmap -layout 'us,ua,ru' -variant ',winkeys,winkeys' -option grp:alt_shift_toggle -option compose:ralt -option terminate:ctrl_alt_bksp",
- "kbdd"
- }
- runOnceApps = {
- "emacs --daemon",
- "thunderbird",
- "xscreensaver -nosplash"
- }
- if autorun then
- for app = 1, #autorunApps do
- awful.util.spawn(autorunApps[app])
- end
- for app = 1, #runOnceApps do
- run_once(runOnceApps[app])
- end
- end
- -- {{{ Variable definitions
- -- Themes define colours, icons, and wallpapers
- beautiful.init("/home/unlogic/.config/awesome/themes/nice-and-clean-theme/theme.lua")
- -- This is used later as the default terminal and editor to run.
- --terminal = "urxvt -fn 'xft:droid sans mono:pixelsize=14'"
- terminal = "urxvt"
- editor = os.getenv("EDITOR") or "editor"
- editor_cmd = terminal .. " -e " .. editor
- -- Default modkey.
- modkey = "Mod4"
- -- Table of layouts to cover with awful.layout.inc, order matters.
- layouts =
- {
- awful.layout.suit.floating, -- 1
- awful.layout.suit.tile, -- 2
- awful.layout.suit.tile.bottom, -- 3
- awful.layout.suit.spiral, -- 4
- awful.layout.suit.max, -- 5
- awful.layout.suit.magnifier -- 6
- }
- -- }}}
- -- {{{ Tags
- -- Define a tag table which hold all screen tags.
- tags = {}
- for s = 1, screen.count() do
- -- -- Each screen has its own tag table.
- tags[s] = awful.tag({ "☯", "⚑", "☎", "☉", "☻", "⌥"}, s, {layouts[1], layouts[5], layouts[1], layouts[2], layouts[1], layouts[1]})
- end--
- -- }}}
- -- {{{ Menu
- -- Create a laucher widget and a main menu
- myawesomemenu = {
- { "restart", awesome.restart },
- { "quit", awesome.quit }
- }
- sshmenu = {
- { "ssh delice", terminal .. " -e conserv" },
- { "ssh emera", terminal .. " -e conwork" }
- }
- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
- { "software", debian.menu.Debian_menu.Debian },
- { "connect to", sshmenu}
- }
- })
- mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
- menu = mymainmenu })
- -- }}}
- -- {{{ Wibox
- -- *** MyMPDWidget Init ***
- musicwidget = awesompd:create() -- Create awesompd widget
- musicwidget.font = "Liberation Mono" -- Set widget font
- musicwidget.scrolling = true -- If true, the text in the widget will be scrolled
- musicwidget.output_size = 30 -- Set the size of widget in symbols
- musicwidget.update_interval = 10 -- Set the update interval in seconds
- musicwidget.path_to_icons = "/home/unlogic/.config/awesome/iconsg"
- musicwidget.debug_mode = true
- musicwidget.jamendo_format = awesompd.FORMAT_MP3 -- or you can use FORMAT_MP3
- instance.show_jamendo_album_covers = true
- instance.album_cover_size = 50
- musicwidget.ldecorator = "| "
- musicwidget.rdecorator = " |"
- -- Set all the servers to work with
- musicwidget.servers = {
- { server = "localhost",
- port = 6600 },
- { server = "192.168.0.72",
- port = 6600 }
- }
- --Set the buttons of the widget
- musicwidget:register_buttons({ { "", awesompd.MOUSE_LEFT, musicwidget:command_toggle() },
- { "Control", awesompd.MOUSE_SCROLL_UP, musicwidget:command_prev_track() },
- { "Control", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_next_track() },
- { "", awesompd.MOUSE_SCROLL_UP, musicwidget:command_volume_up() },
- { "", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_volume_down() },
- { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() } })
- musicwidget:run()
- -- *** MyMPDWidget End
- -- Create a textclock widget
- mytextclock = awful.widget.textclock({ align = "right" })
- -- Create a systray
- mysystray = widget({ type = "systray" })
- -- MEMWIDGET
- memwidget = widget({ type = "textbox" })
- vicious.register(memwidget, vicious.widgets.mem, function (widget, args)
- infojets.update_ram(args[2], args[4])
- return " ♻ " ..args[1].."% | "
- end, 13)
- -- CPU WIDGET.TEXT
- cpuwidget = widget({ type = "textbox" })
- vicious.register(cpuwidget, vicious.widgets.cpu,
- function (widget, args)
- infojets.update_cpu(args[1])
- if string.len(args[1]) == 1 then
- return " ☢ " .. args[1] .. "% "
- else
- return " ☢ " .. args[1] .. "% "
- end
- end)
- cpuwidget:buttons(
- awful.util.table.join(awful.button({ }, 1,
- function ()
- awful.util.spawn(terminal .. " -e htop")
- end)))
- -- CPUTEMP WIDGET
- cputempwidget = widget({ type = "textbox" })
- vicious.register(cputempwidget, vicious.widgets.thermal,
- function (widget, args)
- infojets.update_temp(args[1])
- return args[1] .. "°C |"
- end, 19, "thermal_zone0" )
- -- Battery widget
- batwidget = widget({ type = "textbox" })
- function getBattery(widg)
- local fst = io.popen("cat /sys/class/power_supply/BAT0/status")
- local fch = io.popen("cat /sys/class/power_supply/BAT0/energy_now")
- local fmax = io.popen("cat /sys/class/power_supply/BAT0/energy_full")
- local st = fst:read("*all")
- local ch = fch:read("*all")
- local max = fmax:read("*all")
- local battery = math.floor(ch * 100 / max)
- if st:match("Charging") then
- dir = "% ▲"
- elseif st:match("Discharging") then
- dir = "% ▼"
- if tonumber(battery) <= 10 then
- naughty.notify({ title = "Battery Warning"
- , text = "Battery low! " .. battery .."%" .. " left!"
- , timeout = 5
- , position = "top_right"
- })
- end
- else
- dir = "% ◆"
- end
- widg.text = " ⚡ " .. battery .. dir .. " |"
- fst:close()
- fch:close()
- fmax:close()
- end
- getBattery(batwidget)
- repeat_every(function () getBattery(batwidget) end, 10)
- -- Time widget
- timewidget = widget({ type = "textbox", name = "org_widget" })
- repeat_every(function()
- timewidget.text = os.date("%H:%M")
- if infojets and infojets.update_clock then
- infojets.update_clock()
- infojets.update_date()
- end
- end, 10)
- -- function timeUpdate()
- -- local fd = io.popen("date | grep -o -e '..:..'")
- -- local tm = fd:read("*all")
- -- fd:close()
- -- infojets.update_clock()
- -- infojets.update_date()
- -- timewidget.text = tm
- -- end
- --timeUpdate()
- --awful.hooks.timer.register(5, function () timeUpdate() end)
- -- Quick launch bar widget BEGINS
- function getValue(t, key)
- _, _, res = string.find(t, key .. " *= *([^%c]+)%c")
- return res
- end
- function split (s,t)
- local l = {n=0}
- local f = function (s)
- l.n = l.n + 1
- l[l.n] = s
- end
- local p = "%s*(.-)%s*"..t.."%s*"
- s = string.gsub(s,p,f)
- l.n = l.n + 1
- return l
- end
- launchbar = { layout = awful.widget.layout.horizontal.leftright }
- filedir = "/home/unlogic/.config/awesome/launchbar/" -- Specify your folder with shortcuts here
- files = split(io.popen("ls " .. filedir .. "*.desktop"):read("*all"),"\n")
- for i = 1, table.getn(files) do
- local t = io.open(files[i]):read("*all")
- launchbar[i] = { image = image(getValue(t,"Icon")),
- command = getValue(t,"Exec"),
- position = tonumber(getValue(t,"Position")) or 255 }
- end
- table.sort(launchbar, function(a,b) return a.position < b.position end)
- for i = 1, table.getn(launchbar) do
- launchbar[i] = awful.widget.launcher(launchbar[i])
- end
- -- Quick launch bar widget ENDS
- recurse = true
- client.add_signal("new", function(c)
- c:add_signal("property::icon", function()
- -- Make sure we aren't going into an endless loop when changing the icon
- print(c.icon)
- if not recurse then return end
- -- if not client.icon then return end
- -- Here you can do something with c.icon, e.g.:
- c.icon:save("/tmp/icon.png")
- local h =
- io.popen("convert -colorspace Gray /tmp/icon.png /tmp/icon2.png"):read("*all")
- recurse = false
- c.icon = image("/tmp/icon2.png")
- recurse = true
- end)
- end)
- -- *** Internal calc function *** ---
- function calc(result)
- naughty.notify( { title = "Awesome calc",
- text = "Result: " .. result,
- timeout = 5})
- end
- -- *** Debug pring function *** ---
- function nprint(s)
- naughty.notify( { title = "Debug print",
- text = tostring(s),
- timeout = 5})
- end
- -- *** Calendar widget
- orglendar.files = { "/home/unlogic/Documents/Notes/edu.org" }
- orglendar.register(timewidget)
- -- work_file = "/home/unlogic/Documents/Notes/edu.org"
- -- timewidget:add_signal("mouse::enter", function() org.naughty_open(0) end)
- -- timewidget:add_signal("mouse::leave", org.naughty_close)
- -- timewidget:buttons(awful.util.table.join(
- -- awful.button({ }, 1, function () awful.util.spawn("emacs " .. work_file) end),
- -- awful.button({ }, 3, function () org.update() end),
- -- awful.button({ }, 4, function()
- -- org.naughty_open(-1)
- -- end),
- -- awful.button({ }, 5, function()
- -- org.naughty_open(1)
- -- end)))
- -- org.register(timewidget, { work_file })
- -- *** Calendar widget end
- -- *** Keyboard widget
- kbdwidget = widget({type = "textbox", name = "kbdwidget"})
- kbdwidget.text = " ✡ US |"
- dbus.request_name("session", "ru.gentoo.kbdd")
- dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
- dbus.add_signal("ru.gentoo.kbdd", function(...)
- local data = {...}
- local layout = data[2]
- lts = {[0] = "✡ US", [1] = "★ UA", [2] = "☭ RU"}
- kbdwidget.text = " "..lts[layout].." |"
- end
- )
- -- Volume widget
- cardid = 0
- channel = "Master"
- function volume (mode, widget)
- if mode == "update" then
- local fd = io.popen("amixer -c " .. cardid .. " -- sget " .. channel)
- local status = fd:read("*all")
- fd:close()
- local volume = string.match(status, "(%d?%d?%d)%%")
- volume = string.format("% 3d", volume)
- status = string.match(status, "%[(o[^%]]*)%]")
- if string.find(status, "on", 1, true) then
- volume = "♫" .. volume .. "% |"
- else
- volume = "♫" .. volume .. "M |"
- end
- widget.text = volume
- elseif mode == "up" then
- io.popen("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%+"):read("*all")
- volume("update", widget)
- elseif mode == "down" then
- io.popen("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%-"):read("*all")
- volume("update", widget)
- else
- io.popen("amixer -c " .. cardid .. " sset " .. channel .. " toggle"):read("*all")
- volume("update", widget)
- end
- end
- tb_volume = widget({ type = "textbox", name = "tb_volume", align = "right" })
- tb_volume:buttons(awful.util.table.join(
- awful.button({ }, 3, function () awful.util.spawn("gnome-volume-control") end),
- awful.button({ }, 4, function () volume("up", tb_volume) end),
- awful.button({ }, 5, function () volume("down", tb_volume) end),
- awful.button({ }, 1, function () volume("mute", tb_volume) end)
- ))
- repeat_every(function() volume("update", tb_volume) end, 10)
- -- Wierd - wicd widget for awesome
- wierd = {}
- function wierd.update_widget()
- local bus = io.popen("wicd-cli -yd", "r")
- local line = bus:read("*line")
- if not string.find(line,"^Invalid") then
- while line do
- for key, value in pairs(wierd.properties) do
- local _, matches, result = string.find(line, "^" .. value .. "(.*)")
- if matches then
- wierd.values[key] = result
- end
- end
- line = bus:read("*line")
- end
- local text = wierd.format
- for key, value in pairs(wierd.values) do
- text = text.gsub(text,key,value)
- end
- wierd.widget.text = text
- else
- local text = " ⚠ OFF |"
- wierd.widget.text = text
- end
- end
- function wierd.pop_spaces(s1,s2,maxsize)
- local sps = ""
- for i = 1, maxsize-string.len(s1)-string.len(s2) do
- sps = sps .. " "
- end
- return s1 .. sps .. s2
- end
- wierd.widget = widget({ type = "textbox" })
- wierd.format = " ⚚ $QUALITY% |"
- wierd.properties = {}
- wierd.values = {}
- wierd.properties["$ESSID"] = "Essid: "
- wierd.properties["$IP"] = "IP: "
- wierd.properties["$ENC_METHOD"] = "Encryption Method: "
- wierd.properties["$QUALITY"] = "Quality: "
- wierd.properties["$SPEED"] = "Bit Rates: "
- wierd.update_widget_timer = timer({ timeout = 10 })
- wierd.update_widget_timer:add_signal("timeout", function () wierd.update_widget() end)
- wierd.update_widget_timer:start()
- wierd.update_widget()
- wierd.widget:add_signal("mouse::enter",
- function()
- local result = ""
- for key, value in pairs(wierd.values) do
- if key ~= "$ESSID" and key ~= "$QUALITY" then
- result = result .. wierd.pop_spaces(wierd.properties[key],value,23) .. "\n"
- end
- end
- result = '<span font="monospace">' .. string.sub(result,1,string.len(result)-1) .. "</span>"
- wierd.popup = naughty.notify(
- { title = "Connected to " .. wierd.values["$ESSID"]
- .. " at " .. wierd.values["$QUALITY"] .. "%",
- text = result, timeout = 0 })
- end)
- wierd.widget:add_signal("mouse::leave", function()
- if wierd.popup ~= nil then
- naughty.destroy(wierd.popup)
- wierd.popup = nil
- end
- end)
- wierd.widget:buttons(awful.util.table.join(
- awful.button({ }, 1, function () awful.util.spawn(terminal .. " -e wicd-curses") end)))
- -- Mailsome widget
- mailsome_timer = timer({ timeout = 10 })
- mailsome_timer:add_signal("timeout", function ()
- local mailbus = io.open("/tmp/mailsome")
- if mailbus then
- local mailtext = mailbus:read("*all")
- mailtext = string.sub(mailtext,1,string.len(mailtext)-1)
- naughty.notify( { title = "Mailsome notification",
- text = mailtext, timeout = 0 })
- awful.util.spawn("rm /tmp/mailsome")
- end
- end)
- mailsome_timer:start()
- -- Guake-like console
- -- This function is for awesome versions prior to 3.4
- -- This function is for awesome versions prior to 3.4
- dropdown = {}
- function dropdown_toggle(prog, height, s)
- if s == nil then s = mouse.screen end
- if height == nil then height = 0.2 end
- if not dropdown[prog] then
- -- Create table
- dropdown[prog] = {}
- -- Add unmanage hook for dropdown programs
- awful.hooks.unmanage.register(function (c)
- for scr, cl in pairs(dropdown[prog]) do
- if cl == c then
- dropdown[prog][scr] = nil
- end
- end
- end)
- end
- if not dropdown[prog][s] then
- spawnw = function (c)
- -- Store client
- dropdown[prog][s] = c
- -- Float client
- awful.client.floating.set(c, true)
- -- Get screen geometry
- screengeom = screen[s].workarea
- -- Calculate height
- if height < 1 then
- height = screengeom.height*height
- end
- -- I like a different border with for the popup window
- -- So I don't confuse it with terminals in the layout
- bw = 2
- -- Resize client
- c:geometry({
- x = screengeom.x,
- y = screengeom.y - 1000,
- width = screengeom.width - bw,
- height = height - bw
- })
- -- Mark terminal as ontop
- -- c.ontop = true
- -- c.above = true
- c.border_width = bw
- -- Focus and raise client
- c:raise()
- client.focus = c
- -- Remove hook
- awful.hooks.manage.unregister(spawnw)
- end
- -- Add hook
- awful.hooks.manage.register(spawnw)
- -- Spawn program
- awful.util.spawn(prog)
- dropdown.currtag = awful.tag.selected(s)
- else
- -- Get client
- c = dropdown[prog][s]
- -- Switch the client to the current workspace
- -- Focus and raise if not hidden
- if c.hidden then
- awful.client.movetotag(awful.tag.selected(s), c)
- c.hidden = false
- c:raise()
- client.focus = c
- else
- if awful.tag.selected(s) == dropdown.currtag then
- c.hidden = true
- local ctags = c:tags()
- for i, t in pairs(ctags) do
- ctags[i] = nil
- end
- c:tags(ctags)
- else
- awful.client.movetotag(awful.tag.selected(s), c)
- c:raise()
- client.focus = c
- end
- end
- dropdown.currtag = awful.tag.selected(s)
- end
- end
- -- Create a wibox for each screen and add it
- mywibox = {}
- mydownbox = {}
- mypromptbox = {}
- musicwidget.promptbox = mypromptbox
- mylayoutbox = {}
- mytaglist = {}
- mytaglist.buttons = awful.util.table.join(
- awful.button({ }, 1, awful.tag.viewonly),
- awful.button({ modkey }, 1, awful.client.movetotag),
- awful.button({ }, 3, awful.tag.viewtoggle),
- awful.button({ modkey }, 3, awful.client.toggletag),
- awful.button({ }, 4, awful.tag.viewnext),
- awful.button({ }, 5, awful.tag.viewprev)
- )
- mytasklist = {}
- mytasklist.buttons = awful.util.table.join(
- awful.button({ }, 1, function (c)
- if not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
- end
- client.focus = c
- c:raise()
- end),
- awful.button({ }, 3, function ()
- if instance then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({ width=250 })
- end
- end),
- awful.button({ }, 4, function ()
- awful.client.focus.byidx(1)
- if client.focus then client.focus:raise() end
- end),
- awful.button({ }, 5, function ()
- awful.client.focus.byidx(-1)
- if client.focus then client.focus:raise() end
- end))
- for s = 1, screen.count() do
- -- Create a promptbox for each screen
- mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
- -- Create an imagebox widget which will contains an icon indicating which layout we're using.
- -- We need one layoutbox per screen.
- mylayoutbox[s] = awful.widget.layoutbox(s)
- mylayoutbox[s]:buttons(awful.util.table.join(
- awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
- awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
- -- Create a taglist widget
- mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
- -- Create a tasklist widget
- mytasklist[s] = awful.widget.tasklist(function(c)
- return awful.widget.tasklist.label.currenttags(c, s)
- end, mytasklist.buttons)
- -- Create separator
- separator = widget({ type = "textbox" })
- separator.text = " | "
- -- Create the wibox
- mywibox[s] = awful.wibox({ position = "top", screen = s })
- -- Add widgets to the wibox - order matters
- mywibox[s].widgets = {
- {
- mylauncher,
- mytaglist[s],
- separator,
- launchbar,
- separator,
- s == 1 and mysystray or nil,
- separator,
- mypromptbox[s],
- layout = awful.widget.layout.horizontal.leftright
- },
- mylayoutbox[s],
- timewidget,
- batwidget,
- tb_volume,
- memwidget,
- cputempwidget,
- cpuwidget,
- wierd.widget,
- kbdwidget,
- musicwidget.widget,
- mytasklist[s],
- layout = awful.widget.layout.horizontal.rightleft
- }
- end
- function delay_s(delay)
- delay = delay or 1
- local time_to = os.time() + delay
- while os.time() < time_to do end
- end
- --shifty.taglist = mytaglist
- -- }}}
- -- {{{ Mouse bindings
- root.buttons(awful.util.table.join(
- -- awful.button({ }, 3, function () mymainmenu:toggle() end),
- awful.button({ }, 4, awful.tag.viewnext),
- awful.button({ }, 5, awful.tag.viewprev)
- ))
- -- }}}
- ------- MARK FUNCTIONALITY -----------
- -- iterator: cycle over a table starting from the next element
- local function cycle(t, item)
- local index = awful.util.table.hasitem(t, item)
- local size = table.getn(t)
- local count = 0
- return function ()
- index = next(t, index) or 1; count = count + 1
- if not (count > size) then return t[index] end
- end
- end
- -- cycle through marked clients
- function cycle_marked()
- local clients = client.get(mouse.screen)
- local focused = awful.client.next(0)
- cycle(clients,focused)
- for c in cycle(clients, focused) do
- if awful.client.ismarked(c) then
- local ctags = c:tags()
- if table.getn(ctags) == 0 then
- -- not on any tag, show client on current tag
- awful.client.movetotag(awful.tag.selected(), c)
- else
- -- else, pop to first tag client is visible on
- awful.tag.viewonly(ctags[1])
- end
- -- And then focus the client
- client.focus = c
- c:raise()
- return
- end
- end
- end
- -- {{{ Key bindings
- globalkeys = awful.util.table.join(
- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
- awful.key({ modkey, }, "Tab", awful.tag.history.restore),
- awful.key({ modkey, }, "Up",
- function ()
- awful.client.focus.byidx( 1)
- if client.focus then client.focus:raise() end
- end),
- awful.key({ modkey, }, "Down",
- function ()
- awful.client.focus.byidx(-1)
- if client.focus then client.focus:raise() end
- end),
- -- Layout manipulation
- awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
- awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
- awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
- awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
- awful.key({ modkey, }, "a", cycle_marked ),
- awful.key({ modkey, }, "t", function()
- awful.client.togglemarked()
- naughty.notify({text = "placeholder"})
- end),
- awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
- awful.key({ modkey, }, "Tab",
- function ()
- awful.client.focus.history.previous()
- if client.focus then
- client.focus:raise()
- end
- end),
- -- awful.key({ "Shift" }, "Alt_L", function () kbdcfg.switch() end),
- -- Standard program
- awful.key({ modkey, }, "Return", function () dropdown_toggle("urxvt -pe tabbed", 0.5) end),
- awful.key({ modkey }, "l", function ()
- awful.util.spawn("xscreensaver-command -lock")
- delay_s(10)
- awful.util.spawn("xset dpms force off")
- end),
- awful.key({ modkey }, "z", function()
- naughty.notify({ title = "Debug stug",
- text = "Some text may appear here someday",
- timeout = 3, hover_timeout = 0.5,
- width = 160})
- -- obvious.popup_run_prompt.run_prompt()
- end),
- -- awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
- -- awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
- awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
- awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
- awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
- awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
- awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
- awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
- awful.key({ }, "Print", function () awful.util.spawn("gnome-screenshot") end),
- -- awful.key({ modkey }, "q", function () awful.util.spawn("gnome-screenshot -a") end),
- -- Prompt
- awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
- awful.key({ modkey }, "x",
- function ()
- awful.prompt.run({ prompt = "Run Lua code: " },
- mypromptbox[mouse.screen].widget,
- awful.util.eval, nil,
- awful.util.getdir("cache") .. "/history_eval")
- end)
- )
- clientkeys = awful.util.table.join(
- awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
- awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
- awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
- awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
- awful.key({ modkey, }, "o", awful.client.movetoscreen ),
- awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
- awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
- awful.key({ modkey }, "b", function ()
- mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
- end),
- awful.key({ modkey, }, "m",
- function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end)
- )
- -- Compute the maximum number of digit we need, limited to 9
- keynumber = 0
- for s = 1, screen.count() do
- keynumber = math.min(9, math.max(#tags[s], keynumber));
- end
- -- Bind all key numbers to tags.
- -- Be careful: we use keycodes to make it works on any keyboard layout.
- -- This should map on the top row of your keyboard, usually 1 to 9.
- for i = 1, keynumber do
- globalkeys = awful.util.table.join(globalkeys,
- awful.key({ modkey }, "#" .. i + 9,
- function ()
- local screen = mouse.screen
- if tags[screen][i] then
- awful.tag.viewonly(tags[screen][i])
- end
- end),
- awful.key({ modkey, "Control" }, "#" .. i + 9,
- function ()
- local screen = mouse.screen
- if tags[screen][i] then
- awful.tag.viewtoggle(tags[screen][i])
- end
- end),
- awful.key({ modkey, "Shift" }, "#" .. i + 9,
- function ()
- if client.focus and tags[client.focus.screen][i] then
- awful.client.movetotag(tags[client.focus.screen][i])
- end
- end),
- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
- function ()
- if client.focus and tags[client.focus.screen][i] then
- awful.client.toggletag(tags[client.focus.screen][i])
- end
- end))
- end
- clientbuttons = awful.util.table.join(
- awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
- awful.button({ modkey }, 1, awful.mouse.client.move),
- awful.button({ modkey }, 3, awful.mouse.client.resize))
- -- Set keys
- root.keys(globalkeys)
- --shifty.config.globalkeys = globalkeys
- --shifty.config.clientkeys = clientkeys
- -- }}}
- -- {{{ Rules
- awful.rules.rules = {
- -- All clients will match this rule.
- { rule = { },
- properties = { border_width = beautiful.border_width,
- border_color = beautiful.border_normal,
- focus = true,
- keys = clientkeys,
- buttons = clientbuttons } },
- { rule = { class = "MPlayer" },
- properties = { floating = true } },
- { rule = { class = "pinentry" },
- properties = { floating = true } },
- { rule = { class = "gimp" },
- properties = { floating = true } },
- -- Set Firefox to always map on tags number 2 of screen 1.
- { rule = { class = "Firefox" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "Iceweasel" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "FreeMind" },
- properties = { tag = tags[1][1] } },
- { rule = { class = "Thunderbird" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "Pidgin" },
- properties = { tag = tags[1][3], floating = true } },
- }
- -- }}}
- -- {{{ Signals
- -- Signal function to execute when a new client appears.
- client.add_signal("manage", function (c, startup)
- -- Add a titlebar
- -- awful.titlebar.add(c, { modkey = modkey })
- -- Enable sloppy focus
- c:add_signal("mouse::enter", function(c)
- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
- and awful.client.focus.filter(c) then
- client.focus = c
- end
- end)
- if not startup then
- -- Set the windows at the slave,
- -- i.e. put it at the end of others instead of setting it master.
- -- awful.client.setslave(c)
- -- Put windows in a smart way, only if they does not set an initial position.
- if not c.size_hints.user_position and not c.size_hints.program_position then
- awful.placement.no_overlap(c)
- awful.placement.no_offscreen(c)
- end
- end
- c.size_hints_honor = false
- end)
- client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
- client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
- -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement