From: Samir Benmendil Date: Wed, 8 Oct 2014 07:18:22 +0000 (+0100) Subject: awesome: some cleanup X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/4666dc1fa2364cb7628ef70d17f40b29189dbacf?ds=sidebyside awesome: some cleanup --- diff --git a/awesome/bindings.lua b/awesome/bindings.lua index 41a6236..db5f7c9 100644 --- a/awesome/bindings.lua +++ b/awesome/bindings.lua @@ -1,11 +1,8 @@ -- Default modkey. --- Usually, Mod4 is the key with a logo between Control and Alt. --- If you do not like this or do not have such a key, --- I suggest you to remap Mod4 to another key using xmodmap or other tools. --- However, you can use another modifier like Mod1, but it may interact with others. modkey = "Mod4" +altkey = "Mod1" --- {{{1 Mouse bindings +-- Mouse bindings {{{1 root.buttons(awful.util.table.join( awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), @@ -17,9 +14,9 @@ clientbuttons = awful.util.table.join( awful.button({ modkey }, 1, awful.mouse.client.move), awful.button({ modkey }, 3, awful.mouse.client.resize)) --- {{{1 Global Keys +-- Global Keys {{{1 globalkeys = awful.util.table.join(globalkeys, - -- {{{2 Awesome Keys + -- Awesome Keys {{{2 awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), @@ -69,7 +66,7 @@ globalkeys = awful.util.table.join(globalkeys, -- Menubar awful.key({ modkey }, "p", function() menubar.show() end), - -- {{{2 My Keys + -- My Keys {{{2 -- Menu awful.key({ modkey }, "w", function () mymainmenu:show({ coords = { x = 0, y = 0}}) end), -- Prompt @@ -95,9 +92,9 @@ globalkeys = awful.util.table.join(globalkeys, awful.key({ }, "XF86AudioMute", function () awful.util.spawn("ponymix toggle") end) ) --- {{{1 Client keys +-- Client keys {{{1 clientkeys = awful.util.table.join( - -- {{{2 Awesome Client Keys + -- Awesome Client Keys {{{2 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 ), @@ -114,7 +111,7 @@ clientkeys = awful.util.table.join( c.maximized_vertical = not c.maximized_vertical end), - -- {{{2 My Client Keys + -- My Client Keys {{{2 -- Move client to screen awful.key({ modkey, "Shift" }, "#94", awful.client.movetoscreen ), awful.key({ modkey, "Shift" }, "#49", awful.client.movetoscreen ), @@ -124,7 +121,7 @@ clientkeys = awful.util.table.join( -- }}} ) --- {{{1 Tags +-- Tags {{{1 -- 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. diff --git a/awesome/conky.lua b/awesome/conky.lua index 0f9eca9..71996cf 100644 --- a/awesome/conky.lua +++ b/awesome/conky.lua @@ -2,60 +2,53 @@ local utils = require("utils") local function get_conky() - local clients = client.get() - local conky = nil - local i = 1 - while clients[i] - do - if clients[i].class == "Conky" - then - conky = clients[i] - end - i = i + 1 + local clients = client.get() + local conky = nil + local i = 1 + while clients[i] do + if clients[i].class == "Conky" then + conky = clients[i] end - return conky + i = i + 1 + end + return conky end local function raise_conky() - local conky = get_conky() - if conky - then - conky.ontop = true - conky.hidden = false - end + local conky = get_conky() + if conky then + conky.ontop = true + conky.hidden = false + end end local function lower_conky() - local conky = get_conky() - if conky - then - conky.ontop = false - conky.hidden = true - end + local conky = get_conky() + if conky then + conky.ontop = false + conky.hidden = true + end end local function toggle_conky() - local conky = get_conky() - if conky - then - if conky.ontop - then - conky.ontop = false - else - conky.ontop = true - end + local conky = get_conky() + if conky then + if conky.ontop then + conky.ontop = false + else + conky.ontop = true end + end end utils.rules.append({ - { rule = { class = "Conky" }, - properties = { floating = true, - sticky = true, - ontop = false, - hidden = true, - focusable = true, - size_hints = {"program_position", "program_size"} - } }, + { rule = { class = "Conky" }, + properties = { floating = true, + sticky = true, + ontop = false, + hidden = true, + focusable = true, + size_hints = {"program_position", "program_size"} } }, }) -- add global key diff --git a/awesome/menu.lua b/awesome/menu.lua index 2c3a208..54a30e3 100644 --- a/awesome/menu.lua +++ b/awesome/menu.lua @@ -4,7 +4,6 @@ require('freedesktop.menu') freedesktopmenu = freedesktop.menu.new() --- {{{ Menu -- Setup global menu keys awful.menu.menu_keys.up = { "k", "Up"} awful.menu.menu_keys.down = { "j", "Down"} @@ -35,4 +34,3 @@ mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, -- Menubar configuration menubar.utils.terminal = terminal -- Set the terminal for applications that require it --- }}} diff --git a/awesome/rc.lua b/awesome/rc.lua index 9cd4481..826b908 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -1,15 +1,13 @@ --- Standard awesome library +-- Standard awesome library {{{1 gears = require("gears") awful = require("awful") awful.rules = require("awful.rules") require("awful.autofocus") --- Theme handling library beautiful = require("beautiful") --- Notification library naughty = require("naughty") menubar = require("menubar") --- {{{ Error handling +-- Error handling {{{1 -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then @@ -32,9 +30,8 @@ do in_error = false end) end --- }}} --- {{{ Variable definitions +-- Variable definitions {{{1 -- Themes define colours, icons, and wallpapers beautiful.init(awful.util.getdir("config").."/themes/mlp/theme.lua") @@ -43,34 +40,23 @@ terminal = "urxvtc" editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor --- Tags -require("tags") --- }}} - --- {{{ Wallpaper +-- Wallpaper {{{1 if beautiful.wallpaper then for s = 1, screen.count() do gears.wallpaper.maximized(beautiful.wallpaper, s, true) end end --- }}} ---Menu +-- Require files {{{1 +require("tags") require("menu") - --- Topbar require("topbar") - --- Mouse/Key Bindings require("bindings") - --- Rules require("rules") - --- conky require("conky") +require("autostart") --- {{{ Signals +-- Signals {{{1 -- Signal function to execute when a new client appears. client.connect_signal("manage", function (c, startup) -- Enable sloppy focus @@ -96,10 +82,6 @@ end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) --- }}} -- Set keys root.keys(globalkeys) - --- Autostart applications -require("autostart") diff --git a/awesome/rules.lua b/awesome/rules.lua index b167ec2..3fe2c9f 100644 --- a/awesome/rules.lua +++ b/awesome/rules.lua @@ -1,6 +1,5 @@ local utils = require("utils") --- {{{ Rules if utils.host == "shada" then mediatag = tags[2][3] end if utils.host == "chronos" then mediatag = tags[1][4] end @@ -34,7 +33,7 @@ awful.rules.rules = { skip_taskbar = true, ontop = true, x = 1920 - 310, y = mywibox[mouse.screen].height, - height = 100, width = 100 } }, + width = 100, height = 100 } }, { rule = { class = "URxvt", instance = "mutt" }, properties = { tag = wwwtag, function (c) awful.client.setslave(c) end } }, @@ -55,4 +54,3 @@ awful.rules.rules = { { rule = { class = "Steam" }, properties = { tag = tags[1][9] } }, } --- }}} diff --git a/awesome/tags.lua b/awesome/tags.lua index fcbb159..cefc22a 100644 --- a/awesome/tags.lua +++ b/awesome/tags.lua @@ -1,4 +1,4 @@ --- {{{ Layouts +-- Layouts {{{1 -- Table of layouts to cover with awful.layout.inc, order matters. layouts = { @@ -15,14 +15,13 @@ layouts = awful.layout.suit.max.fullscreen, --awful.layout.suit.magnifier } --- }}} --- {{{ Tags +-- Tags {{{1 local mytags = {} local path = beautiful.path local icon_only = true --- {{{ single screen +-- single screen {{{2 mytags[1] = {} mytags[1][1] = { { name = "1", layout = awful.layout.suit.tile.left, mwfact=0.50, icon = path.."/cutiemarks/pinkie_pie.png"}, @@ -35,9 +34,8 @@ mytags[1][1] = { { name = "8", layout = awful.layout.suit.max, mwfact=0.50, icon = path.."/cutiemarks/princess_celestia.png"}, { name = "9", layout = awful.layout.suit.floating, mwfact=0.50, icon = path.."/cutiemarks/princess_luna.png"}, } --- }}} --- {{{ Dual screen +-- Dual screen {{{2 mytags[2] = {} mytags[2][1] = { { name = "1", layout = awful.layout.suit.tile.left, mwfact=0.50, icon = path.."/cutiemarks/pinkie_pie.png"}, @@ -62,8 +60,8 @@ mytags[2][2] = { { name = "8", layout = awful.layout.suit.tile, mwfact=0.50, icon = path.."/cutiemarks/thunderlane.png"}, { name = "9", layout = awful.layout.suit.max, mwfact=0.50, icon = path.."/cutiemarks/bon_bon.png"}, } --- }}} +-- Tags {{{2 tags = {} local sc = screen.count() for s = 1, sc do @@ -79,4 +77,3 @@ for s = 1, sc do end tags[s][1].selected = true end --- }}} diff --git a/awesome/topbar.lua b/awesome/topbar.lua index e40b474..b945d80 100644 --- a/awesome/topbar.lua +++ b/awesome/topbar.lua @@ -9,7 +9,7 @@ mytextclock = awful.widget.textclock(" %a %b %d, %k:%M ", 10) separator = wibox.widget.textbox() separator:set_markup('│') --- {{{ Wibox +-- Wibox {{{1 -- Create a wibox for each screen and add it mywibox = {} mypromptbox = {} @@ -108,4 +108,3 @@ for s = 1, screen.count() do mywibox[s]:set_widget(layout) end --- }}} diff --git a/awesome/widgets/battery_widget.lua b/awesome/widgets/battery_widget.lua index e1be687..3cea2f8 100644 --- a/awesome/widgets/battery_widget.lua +++ b/awesome/widgets/battery_widget.lua @@ -39,8 +39,7 @@ local function batclosure () prefix = "Bat:" if charge <= nextlim then naughty.notify({title = "⚡ Warning! ⚡", - text = "Battery has leaked most of its power ( ⚡ " - ..charge.."%)!", + text = "Battery has leaked most of its power ( ⚡ "..charge.."%)!", timeout = 7, position = "top_right", fg = beautiful.fg_focus, @@ -60,7 +59,6 @@ local function batclosure () end batterywidget = wibox.widget.textbox() -vicious.register(batterywidget, vicious.widgets.bat, batclosure(), - 31, "BAT0") +vicious.register(batterywidget, vicious.widgets.bat, batclosure(), 31, "BAT0") return batterywidget diff --git a/awesome/widgets/volume_widget.lua b/awesome/widgets/volume_widget.lua index 957236e..9156af8 100644 --- a/awesome/widgets/volume_widget.lua +++ b/awesome/widgets/volume_widget.lua @@ -4,7 +4,7 @@ vicious.contrib = require("vicious.contrib") local utils = require("utils") local volwidget = { } ---{{{ Volume progressbar +-- Volume Widget {{{1 -- Select device local device = "" if utils.host == "chronos" then device = "alsa_output.pci-0000_00_1b.0.analog-stereo" end