├── .gitmodules ├── themes └── default │ ├── wallpapers │ ├── background.png │ └── background_white.png │ └── theme.lua ├── README.md ├── helpers.lua ├── adlight.sh ├── volume.lua ├── wifi.lua ├── battery.lua └── rc.lua /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lain"] 2 | path = lain 3 | url = https://github.com/copycat-killer/lain 4 | -------------------------------------------------------------------------------- /themes/default/wallpapers/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolidFaker/awesomerc/HEAD/themes/default/wallpapers/background.png -------------------------------------------------------------------------------- /themes/default/wallpapers/background_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolidFaker/awesomerc/HEAD/themes/default/wallpapers/background_white.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Screenshot 2 | 3 | ![screenshot](http://ww1.sinaimg.cn/large/005Nt2Qyjw1f23cfgm7mij311y0lcdw3.jpg) 4 | 5 | ## How to install 6 | 7 | Change directory to ` ~/.config ` then 8 | 9 | ```bash 10 | mv awesome{,.bk} 11 | git clone https://github.com/soildfaker/awesomerc.git awesome 12 | cd awesome 13 | ``` 14 | 15 | And ` vi ./light.sh ` replace ` yourpassword `. This shell script used to adjust the brightness. 16 | 17 | Submodule "lain" may not downloaded when you finished above commands 18 | 19 | Run ` git submodule update --init --recursive ` to download it. 20 | 21 | ## About the "icon" 22 | 23 | Those icons in the status bar above picture are provided by a [special font](https://github.com/FortAwesome/Font-Awesome/), please download and install it. 24 | -------------------------------------------------------------------------------- /helpers.lua: -------------------------------------------------------------------------------- 1 | local helpers = {} 2 | 3 | function helpers:delay(func, time) 4 | local timer = timer({timeout = time or 0}) 5 | 6 | timer:connect_signal("timeout", function() 7 | func() 8 | timer:stop() 9 | end) 10 | 11 | timer:start() 12 | end 13 | 14 | function helpers:listen(widget, interval) 15 | widget:update() 16 | 17 | -- Timer 18 | local timer = timer({timeout = interval or 30}) 19 | 20 | timer:connect_signal("timeout", function() 21 | widget:update() 22 | end) 23 | 24 | timer:start() 25 | end 26 | 27 | function helpers:test(cmd) 28 | local test = io.popen(cmd) 29 | local result = test:read() ~= nil 30 | 31 | test:close() 32 | 33 | return result 34 | end 35 | 36 | return helpers 37 | -------------------------------------------------------------------------------- /adlight.sh: -------------------------------------------------------------------------------- 1 | arg=$1 2 | dx=$2 3 | 4 | if [ $arg = "-aq" ]; then 5 | if [ ! -w /sys/class/backlight/intel_backlight/brightness ];then 6 | echo "password" | sudo -S chmod 777 /sys/class/backlight/intel_backlight/brightness 7 | fi 8 | read bright < '/sys/class/backlight/intel_backlight/brightness' 9 | 10 | v=$(($bright + $dx )) 11 | 12 | if [ $v -lt 900 ]; then 13 | echo $v > /sys/class/backlight/intel_backlight/brightness 14 | fi 15 | elif [ $arg = "-sq" ]; then 16 | if [ ! -w /sys/class/backlight/intel_backlight/brightness ];then 17 | echo "password" | sudo -S chmod 777 /sys/class/backlight/intel_backlight/brightness 18 | fi 19 | read bright < '/sys/class/backlight/intel_backlight/brightness' 20 | 21 | v=$(($bright - $dx)) 22 | 23 | if [ $v -gt 0 ]; then 24 | echo $v > /sys/class/backlight/intel_backlight/brightness 25 | fi 26 | fi 27 | -------------------------------------------------------------------------------- /volume.lua: -------------------------------------------------------------------------------- 1 | local wibox = require("wibox") 2 | local awful = require("awful") 3 | local helpers = require("./helpers") 4 | local lain = require("lain") 5 | markup = lain.util.markup 6 | 7 | local widget = {} 8 | 9 | -- {{{ Define subwidgets 10 | widget.text = wibox.widget.textbox() 11 | 12 | -- Change the draw method so icons can be drawn smaller 13 | --helpers:set_draw_method(widget.text) 14 | -- }}} 15 | 16 | -- {{{ Define interactive behaviour 17 | --widget.text:buttons(awful.util.table.join( 18 | --awful.button({ }, 1, function () awful.util.spawn("gnome-control-center sound") end) 19 | --)) 20 | -- }}} 21 | 22 | -- {{{ Update method 23 | function widget:update() 24 | local fd = io.popen("amixer sget Master") 25 | local status = fd:read("*all") 26 | fd:close() 27 | 28 | local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) or 0 29 | if string.find(status, "[off]", 1, true) or volume <= 0.0 then 30 | if string.find(status, "[off]", 1, true) then 31 | widget.text:set_markup(markup("#ff0000","  mute")) 32 | end 33 | 34 | elseif volume < 25 then 35 | widget.text:set_markup(markup("#00ff00","  " .. volume .. "%")) 36 | 37 | elseif volume > 45 then 38 | widget.text:set_markup(markup("#00ff00","  " .. volume .. "%")) 39 | 40 | else 41 | widget.text:set_markup(markup("#00ff00","  " .. volume .. "%")) 42 | 43 | end 44 | 45 | end 46 | -- }}} 47 | 48 | -- {{{ Listen 49 | helpers:listen(widget) 50 | -- }}} 51 | 52 | return widget 53 | -------------------------------------------------------------------------------- /wifi.lua: -------------------------------------------------------------------------------- 1 | local wibox = require("wibox") 2 | local awful = require("awful") 3 | local helpers = require("./helpers") 4 | local lain = require("lain") 5 | markup = lain.util.markup 6 | local widget = {} 7 | 8 | -- {{{ Define the adapter 9 | local adapter = "wlo1" 10 | 11 | -- Test adapter 12 | widget.haswifi = helpers:test("iwconfig " .. adapter) 13 | 14 | -- Try another adapter name 15 | if not widget.haswifi then 16 | adapter = "wlo1" 17 | widget.haswifi = helpers:test("iwconfig " .. adapter) 18 | end 19 | -- }}} 20 | 21 | -- {{{ Define subwidgets 22 | widget.text = wibox.widget.textbox() 23 | -- }}} 24 | 25 | -- {{{ Update method 26 | function widget:update() 27 | spacer = " " 28 | 29 | local f = io.popen("iwconfig " .. adapter) 30 | local wifi = f:read("*all") 31 | local connected = string.match(wifi, "ESSID:\"(%w*)\"") 32 | local wifiMin, wifiMax = string.match(wifi, "(%d?%d)/(%d?%d)") 33 | 34 | wifiMin = tonumber(wifiMin) or 0 35 | wifiMax = tonumber(wifiMax) or 70 36 | 37 | local quality = math.floor(wifiMin / wifiMax * 100) 38 | local text = quality .. "%" 39 | 40 | if connected then 41 | text = text .. " (" .. connected .. ")" 42 | end 43 | 44 | 45 | if quality <= 0 then 46 | widget.text:set_markup(markup("#ffffff","  " .. "N/A")) 47 | 48 | elseif quality < 25 then 49 | widget.text:set_markup(markup("#ff0000","  " .. text)) 50 | 51 | elseif quality < 50 then 52 | widget.text:set_markup(markup("#ffff00","  " .. text)) 53 | 54 | elseif quality < 75 then 55 | widget.text:set_markup(markup("#66ff00","  " .. text)) 56 | 57 | else 58 | widget.text:set_markup(markup("#00ff00","  " .. text)) 59 | 60 | end 61 | 62 | f:close() 63 | end 64 | -- }}} 65 | 66 | -- {{{ Listen if signal was found 67 | if widget.haswifi then 68 | helpers:listen(widget) 69 | end 70 | -- }}} 71 | 72 | return widget; 73 | -------------------------------------------------------------------------------- /battery.lua: -------------------------------------------------------------------------------- 1 | local wibox = require("wibox") 2 | local awful = require("awful") 3 | local naughty = require("naughty") 4 | local helpers = require("./helpers") 5 | local lain = require("lain") 6 | 7 | markup = lain.util.markup 8 | local widget = {} 9 | 10 | -- {{{ Define adapter 11 | local adapter = "BAT0" 12 | local charge = "charge" 13 | 14 | -- Test identifier 15 | widget.hasbattery = helpers:test("cat /sys/class/power_supply/" .. adapter .. "/" .. charge .. "_now") 16 | 17 | -- Try another identifier 18 | if not widget.hasbattery then 19 | charge = "energy" 20 | widget.hasbattery = helpers:test("cat /sys/class/power_supply/" .. adapter .. "/" .. charge .. "_now") 21 | end 22 | -- }}} 23 | 24 | -- {{{ Define subwidgets 25 | widget.text = wibox.widget.textbox() 26 | 27 | -- {{{ Update method 28 | function widget:update() 29 | local fcur = io.popen("cat /sys/class/power_supply/" ..adapter .. "/" .. charge .. "_now") 30 | local fcap = io.popen("cat /sys/class/power_supply/" ..adapter .. "/" .. charge .. "_full") 31 | local fsta = io.popen("cat /sys/class/power_supply/" ..adapter .. "/status") 32 | local cur = fcur:read() 33 | local cap = fcap:read() 34 | local sta = fsta:read() 35 | 36 | if cur and cap then 37 | local battery = math.floor(cur * 100 / cap) 38 | 39 | if(battery < 10) then 40 | widget.text:set_markup(markup("#ff0000","  " .. battery .. "%")) 41 | if sta:match("Charging") then 42 | widget.text:set_markup(markup("#00ff00", "  " .. "Charging")) 43 | end 44 | elseif(battery < 25) then 45 | widget.text:set_markup(markup("#ff6600","  " .. battery .. "%")) 46 | if sta:match("Charging") then 47 | widget.text:set_markup(markup("#00ff00", "  " .. "Charging")) 48 | end 49 | elseif(battery < 50) then 50 | widget.text:set_markup(markup("#ffff00","  " .. battery .. "%")) 51 | if sta:match("Charging") then 52 | widget.text:set_markup(markup("#00ff00", "  " .. "Charging")) 53 | end 54 | elseif(battery < 75) then 55 | widget.text:set_markup(markup("#66ff00","  " .. battery .. "%")) 56 | if sta:match("Charging") then 57 | widget.text:set_markup(markup("#00ff00", "  " .. "Charging")) 58 | end 59 | else 60 | widget.text:set_markup(markup("#00ff00","  " .. battery .. "%")) 61 | if sta:match("Charging") then 62 | widget.text:set_markup(markup("#00ff00", "  " .. "Charging")) 63 | end 64 | end 65 | 66 | if(battery >= 100) then 67 | widget.text:set_markup(markup("#00ff00", "  " .. "full")) 68 | end 69 | 70 | else 71 | widget.text:set_markup("N/A") 72 | 73 | end 74 | 75 | fcur:close() 76 | fcap:close() 77 | fsta:close() 78 | end 79 | -- }}} 80 | 81 | -- {{{ Listen if signal was found 82 | if widget.hasbattery then 83 | helpers:listen(widget) 84 | end 85 | -- }}} 86 | 87 | return widget 88 | -------------------------------------------------------------------------------- /themes/default/theme.lua: -------------------------------------------------------------------------------- 1 | --------------------------- 2 | -- Default awesome theme -- 3 | --------------------------- 4 | 5 | green = "#7fb219" 6 | cyan = "#7f4de6" 7 | red = "#e04613" 8 | lblue = "#6c9eab" 9 | dblue = "#00ccff" 10 | black = "#3f3f3f" 11 | lgrey = "#d2d2d2" 12 | dgrey = "#333333" 13 | white = "#ffffff" 14 | 15 | 16 | theme = {} 17 | 18 | themes_dir = "~/.config/awesome/themes" 19 | theme.wallpaper = themes_dir .. "/default/wallpapers/background.png" 20 | theme.icon_theme = nil 21 | theme.tasklist_disable_icon = true 22 | theme.font = "sans 8" 23 | theme.fg_normal = "#AAAAAA" 24 | theme.fg_focus = "#F0DFAF" 25 | theme.fg_urgent = "#CC9393" 26 | theme.bg_normal = "#00000090" 27 | theme.bg_focus = "#00000090" 28 | theme.bg_urgent = "#3F3F3F" 29 | theme.border_width = "1" 30 | theme.border_normal = "#226688" 31 | theme.border_focus = "#227799" 32 | theme.border_marked = "#CC9393" 33 | theme.titlebar_bg_focus = "#3F3F3F" 34 | theme.titlebar_bg_normal = "#3F3F3F" 35 | theme.binclock_bg = "#777e76" 36 | theme.binclock_fga = "#CCCCCC" 37 | theme.binclock_fgi = "#444444" 38 | -- theme.taglist_bg_focus = black 39 | theme.taglist_fg_focus = dblue 40 | theme.tasklist_bg_focus = "#000000d0" 41 | theme.tasklist_fg_focus = dblue 42 | theme.textbox_widget_as_label_font_color = white 43 | theme.textbox_widget_margin_top = 1 44 | theme.text_font_color_1 = green 45 | theme.text_font_color_2 = dblue 46 | theme.text_font_color_3 = white 47 | theme.notify_font_color_1 = green 48 | theme.notify_font_color_2 = dblue 49 | theme.notify_font_color_3 = black 50 | theme.notify_font_color_4 = white 51 | theme.notify_font = "Monaco 7" 52 | theme.notify_fg = theme.fg_normal 53 | theme.notify_bg = "#222222" 54 | theme.notify_border = theme.border_focus 55 | theme.awful_widget_bckgrd_color = dgrey 56 | theme.awful_widget_border_color = dgrey 57 | theme.awful_widget_color = dblue 58 | theme.awful_widget_gradien_color_1 = orange 59 | theme.awful_widget_gradien_color_2 = orange 60 | theme.awful_widget_gradien_color_3 = orange 61 | theme.awful_widget_height = 14 62 | theme.awful_widget_margin_top = 2 63 | 64 | -- There are other variable sets 65 | -- overriding the default one when 66 | -- defined, the sets are: 67 | -- [taglist|tasklist]_[bg|fg]_[focus|urgent] 68 | -- titlebar_[normal|focus] 69 | -- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color] 70 | -- Example: 71 | -- theme.taglist_bg_focus = "#CC9393" 72 | -- }}} 73 | 74 | -- {{{ Widgets 75 | -- You can add as many variables as 76 | -- you wish and access them by using 77 | -- beautiful.variable in your rc.lua 78 | -- theme.fg_widget = "#AECF96" 79 | -- theme.fg_center_widget = "#88A175" 80 | -- theme.fg_end_widget = "#FF5656" 81 | -- theme.bg_widget = "#494B4F" 82 | -- theme.border_widget = "#3F3F3F" 83 | 84 | theme.mouse_finder_color = "#CC9393" 85 | -- mouse_finder_[timeout|animate_timeout|radius|factor] 86 | 87 | theme.menu_bg_normal = "#222222" 88 | -- theme.menu_bg_focus = "" 89 | --theme.menu_fg_normal = "" 90 | -- theme.menu_fg_focus = "" 91 | -- theme.menu_border_color = "" 92 | -- theme.menu_border_width = "" 93 | theme.menu_height = "16" 94 | theme.menu_width = "140" 95 | 96 | return theme 97 | -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 98 | -------------------------------------------------------------------------------- /rc.lua: -------------------------------------------------------------------------------- 1 | -- Standard awesome library 2 | local gears = require("gears") 3 | local awful = require("awful") 4 | local common = require("awful.widget.common") 5 | awful.rules = require("awful.rules") 6 | require("awful.autofocus") 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 lain = require("lain") 15 | -- Custom libraries 16 | local helpers = require("helpers") 17 | -- Custom widgets 18 | local myvolume = require("volume") 19 | local mybattery = require("battery") 20 | local mywifi = require("wifi") 21 | -- {{{ Error handling 22 | -- Check if awesome encountered an error during startup and fell back to 23 | -- another config (This code will only ever execute for the fallback config) 24 | if awesome.startup_errors then 25 | naughty.notify({ preset = naughty.config.presets.critical, 26 | title = "Oops, there were errors during startup!", 27 | text = awesome.startup_errors }) 28 | end 29 | 30 | -- Handle runtime errors after startup 31 | do 32 | local in_error = false 33 | awesome.connect_signal("debug::error", function (err) 34 | -- Make sure we don't go into an endless error loop 35 | if in_error then return end 36 | in_error = true 37 | 38 | naughty.notify({ preset = naughty.config.presets.critical, 39 | title = "Oops, an error happened!", 40 | text = err }) 41 | in_error = false 42 | end) 43 | end 44 | -- }}} 45 | 46 | -- {{{ Variable definitions 47 | -- This is used later as the default terminal and editor to run. 48 | terminal = "urxvt" 49 | markup = lain.util.markup 50 | 51 | configd = "~/.config/awesome/" 52 | editor = os.getenv("EDITOR") or "vim" 53 | editor_cmd = terminal .. " -e " .. editor 54 | 55 | -- Themes define colours, icons, font and wallpapers. 56 | beautiful.init(configd .. "/themes/default/theme.lua") 57 | 58 | -- Default modkey. 59 | -- Usually, Mod4 is the key with a logo between Control and Alt. 60 | -- If you do not like this or do not have such a key, 61 | -- I suggest you to remap Mod4 to another key using xmodmap or other tools. 62 | -- However, you can use another modifier like Mod1, but it may interact with others. 63 | modkey = "Mod4" 64 | 65 | -- Table of layouts to cover with awful.layout.inc, order matters. 66 | local layouts = 67 | { 68 | awful.layout.suit.tile, 69 | --awful.layout.suit.tile.left, 70 | --awful.layout.suit.tile.bottom, 71 | --awful.layout.suit.tile.top, 72 | --awful.layout.suit.fair, 73 | --awful.layout.suit.fair.horizontal, 74 | --awful.layout.suit.spiral, 75 | --awful.layout.suit.spiral.dwindle, 76 | awful.layout.suit.max, 77 | awful.layout.suit.max.fullscreen, 78 | --awful.layout.suit.floating, 79 | awful.layout.suit.magnifier 80 | } 81 | -- }}} 82 | 83 | -- {{{AutoRun 84 | --awful.util.spawn_with_shell("xcompmgr -c") 85 | -- }}} 86 | 87 | -- {{{ Wallpaper 88 | if beautiful.wallpaper then 89 | for s = 1, screen.count() do 90 | gears.wallpaper.maximized(beautiful.wallpaper, s, true) 91 | end 92 | end 93 | -- }}} 94 | 95 | -- {{{ Tags 96 | -- Define a tag table which hold all screen tags. 97 | tags = {} 98 | tag_name={"","","","",""} 99 | for s = 1, screen.count() do 100 | -- Each screen has its own tag table. 101 | tags[s] = awful.tag(tag_name, s, layouts[1]) 102 | end 103 | -- }}} 104 | 105 | -- {{{Menu 106 | -- Create a laucher widget and a main menu 107 | myawesomemenu = { 108 | { "manual", terminal .. " -e man awesome" }, 109 | { "edit config", editor_cmd .. " " .. awesome.conffile }, 110 | { "restart", awesome.restart }, 111 | { "quit", awesome.quit } 112 | } 113 | 114 | applicationsmenu = { 115 | { "Chromium", "chromium"}, 116 | { "Gvim", "gvim" } 117 | -- { "cairo-dock", "cairo-dock" } 118 | } 119 | mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, 120 | { "applications", applicationsmenu }, 121 | { "open terminal", terminal } 122 | } 123 | }) 124 | -- Menubar configuration 125 | menubar.utils.terminal = terminal -- Set the terminal for applications that require it 126 | -- }}} 127 | 128 | -- {{{ Wibox 129 | -- Textclock 130 | mytextclock = lain.widgets.abase({ 131 | timeout = 60, 132 | cmd = "date +'%A %d %B %R'", 133 | settings = function() 134 | local t_output = "" 135 | local o_it = string.gmatch(output, "%S+") 136 | 137 | for i=1,3 do t_output = t_output .. " " .. o_it(i) end 138 | 139 | widget:set_markup(markup("#a5ef00","   " .. t_output) .. " " .. markup("#bef73e","  " .. o_it(1)) .. markup("#a5ef00","  ")) 140 | end 141 | }) 142 | 143 | -- Calendar 144 | lain.widgets.calendar:attach(mytextclock, { font_size = 10 }) 145 | 146 | -- Weather 147 | myweather = lain.widgets.weather({ 148 | city_id = 1793511, -- placeholder 149 | settings = function() 150 | descr = weather_now["weather"][1]["description"]:lower() 151 | units = math.floor(weather_now["main"]["temp"]) 152 | widget:set_markup(markup("#eca4c4", descr .. " @ " .. units .. "°C ")) 153 | end 154 | }) 155 | 156 | -- / fs 157 | fswidget = lain.widgets.fs({ 158 | settings = function() 159 | widget:set_markup(markup("#b9f73e", "  " .. fs_now.used .. "% ") .. markup("#67e323","")) 160 | end 161 | }) 162 | 163 | -- CPU 164 | cpuwidget = lain.widgets.cpu({ 165 | settings = function() 166 | widget:set_markup(markup("#cdf76f", "  " .. cpu_now.usage .. "% ")) 167 | end 168 | }) 169 | 170 | -- Coretemp 171 | tempwidget = lain.widgets.temp({ 172 | settings = function() 173 | widget:set_markup(markup("#f1af5f", coretemp_now .. "°C ")) 174 | end 175 | }) 176 | 177 | 178 | -- Net 179 | netdowninfo = wibox.widget.textbox() 180 | netupinfo = lain.widgets.net({ 181 | settings = function() 182 | if iface ~= "network off" and 183 | string.match(myweather._layout.text, "N/A") 184 | then 185 | myweather.update() 186 | end 187 | 188 | widget:set_markup(markup("#bef13c", "  " .. net_now.sent .. " ")) 189 | netdowninfo:set_markup(markup("#67e300", "  " .. net_now.received .. " ")) 190 | end 191 | }) 192 | 193 | -- MEM 194 | memwidget = lain.widgets.mem({ 195 | settings = function() 196 | widget:set_markup(markup("#a9f16c", "  " .. mem_now.used .. "M ")) 197 | end 198 | }) 199 | 200 | -- MPD 201 | mpdwidget = lain.widgets.mpd({ 202 | settings = function() 203 | mpd_notification_preset = { 204 | text = string.format("%s [%s] - %s\n%s", mpd_now.artist, 205 | mpd_now.album, mpd_now.date, mpd_now.title) 206 | } 207 | 208 | if mpd_now.state == "play" then 209 | artist = mpd_now.artist .. " > " 210 | title = mpd_now.title .. " " 211 | mpdicon:set_image(beautiful.widget_note_on) 212 | elseif mpd_now.state == "pause" then 213 | artist = "mpd " 214 | title = "paused " 215 | else 216 | artist = "" 217 | title = "" 218 | --mpdicon:set_image(nil) 219 | end 220 | widget:set_markup(markup("#e54c62", artist) .. markup("#b2b2b2", title)) 221 | end 222 | }) 223 | -- Create a wibox for each screen and add it 224 | mywibox = {} 225 | mypromptbox = {} 226 | mylayoutbox = {} 227 | mytaglist = {} 228 | mytaglist.buttons = awful.util.table.join( 229 | awful.button({ }, 1, awful.tag.viewonly), 230 | awful.button({ modkey }, 1, awful.client.movetotag), 231 | awful.button({ }, 3, awful.tag.viewtoggle), 232 | awful.button({ modkey }, 3, awful.client.toggletag), 233 | awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end), 234 | awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) 235 | ) 236 | mytasklist = {} 237 | mytasklist.buttons = awful.util.table.join( 238 | awful.button({ }, 1, function (c) 239 | if c == client.focus then 240 | c.minimized = true 241 | else 242 | -- Without this, the following 243 | -- :isvisible() makes no sense 244 | c.minimized = false 245 | if not c:isvisible() then 246 | awful.tag.viewonly(c:tags()[1]) 247 | end 248 | -- This will also un-minimize 249 | -- the client, if needed 250 | client.focus = c 251 | c:raise() 252 | end 253 | end), 254 | awful.button({ }, 3, function () 255 | if instance then 256 | instance:hide() 257 | instance = nil 258 | else 259 | instance = awful.menu.clients({ 260 | theme = { width = 250 } 261 | }) 262 | end 263 | end), 264 | awful.button({ }, 4, function () 265 | awful.client.focus.byidx(1) 266 | if client.focus then client.focus:raise() end 267 | end), 268 | awful.button({ }, 5, function () 269 | awful.client.focus.byidx(-1) 270 | if client.focus then client.focus:raise() end 271 | end)) 272 | -- Widgets 273 | local separator = wibox.widget.textbox() 274 | separator:set_markup(markup("#fff273","  ")) 275 | 276 | for s = 1, screen.count() do 277 | -- Create a promptbox for each screen 278 | mypromptbox[s] = awful.widget.prompt() 279 | -- Create an imagebox widget which will contains an icon indicating which layout we're using. 280 | -- We need one layoutbox per screen. 281 | mylayoutbox[s] = awful.widget.layoutbox(s) 282 | mylayoutbox[s]:buttons(awful.util.table.join( 283 | awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), 284 | awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), 285 | awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), 286 | awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) 287 | 288 | -- Create a taglist widget 289 | mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) 290 | 291 | -- Create a tasklist widget 292 | mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) 293 | 294 | -- Create the wibox 295 | mywibox[s] = awful.wibox({ position = "top",height = 16, screen = s }) 296 | 297 | -- Widgets that are aligned to the left 298 | local left_layout = wibox.layout.fixed.horizontal() 299 | left_layout:add(mytaglist[s]) 300 | left_layout:add(separator) 301 | left_layout:add(mypromptbox[s]) 302 | 303 | -- Widgets that are aligned to the right 304 | local right_layout = wibox.layout.fixed.horizontal() 305 | if s == 1 then 306 | 307 | right_layout:add(netdowninfo) 308 | right_layout:add(netupinfo) 309 | right_layout:add(memwidget) 310 | right_layout:add(cpuwidget) 311 | right_layout:add(fswidget) 312 | right_layout:add(myvolume.text) 313 | if mybattery.hasbattery then 314 | right_layout:add(mybattery.text) 315 | end 316 | 317 | if mywifi.haswifi then 318 | right_layout:add(mywifi.text) 319 | end 320 | 321 | right_layout:add(mytextclock) 322 | end 323 | 324 | right_layout:add(wibox.widget.systray()) 325 | -- Now bring it all together (with the tasklist in the middle) 326 | local layout = wibox.layout.align.horizontal() 327 | layout:set_left(left_layout) 328 | layout:set_middle(mytasklist[s]) 329 | layout:set_right(right_layout) 330 | 331 | mywibox[s]:set_widget(layout) 332 | 333 | end 334 | -- }}} 335 | 336 | -- {{{ Mouse bindings 337 | root.buttons(awful.util.table.join( 338 | --awful.button({ }, 3, function () mymainmenu:toggle() end) 339 | --awful.button({ }, 4, awful.tag.viewnext), 340 | --awful.button({ }, 5, awful.tag.viewprev) 341 | )) 342 | -- }}} 343 | 344 | -- {{{ Key bindings 345 | globalkeys = awful.util.table.join( 346 | awful.key({ modkey, }, "Left", awful.tag.viewprev ), 347 | awful.key({ modkey, }, "Right", awful.tag.viewnext ), 348 | awful.key({ modkey, }, "Escape", awful.tag.history.restore), 349 | 350 | awful.key({ modkey, }, "j", 351 | function () 352 | awful.client.focus.byidx( 1) 353 | if client.focus then client.focus:raise() end 354 | end), 355 | awful.key({ modkey, }, "k", 356 | function () 357 | awful.client.focus.byidx(-1) 358 | if client.focus then client.focus:raise() end 359 | end), 360 | awful.key({ modkey, }, "w", function () mymainmenu:show() end), 361 | 362 | -- launch app 363 | awful.key({ modkey, "Control" }, "t", function () awful.util.spawn_with_shell(terminal) end), 364 | awful.key({ modkey, "Control" }, "g", function () awful.util.spawn_with_shell("gvim") end), 365 | -- {{{Fn control 366 | -- light control 367 | awful.key({ }, "XF86MonBrightnessUp", function() awful.util.spawn_with_shell("~/.config/awesome/light.sh -aq 50") end), 368 | awful.key({ }, "XF86MonBrightnessDown", function() awful.util.spawn_with_shell("~/.config/awesome/light.sh -sq 50") end), 369 | -- {{ Volume Control }} -- 370 | awful.key({ }, "XF86AudioRaiseVolume", function() 371 | awful.util.spawn("amixer set Master 9%+", false) 372 | helpers:delay(myvolume.update, 0.1) 373 | end), 374 | awful.key({ }, "XF86AudioLowerVolume", function() 375 | awful.util.spawn("amixer set Master 9%-", false) 376 | helpers:delay(myvolume.update, 0.1) end), 377 | 378 | -- CHECK THIS OUT... amixer get "Master" will tell you the state of master 379 | awful.key({ }, "XF86AudioMute", function() 380 | awful.util.spawn("amixer -D pulse set Master 1+ toggle", false) 381 | helpers:delay(myvolume.update, 0.1) end), 382 | -- }}} 383 | -- Layout manipulation 384 | awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), 385 | awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), 386 | awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), 387 | awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), 388 | awful.key({ modkey, }, "u", awful.client.urgent.jumpto), 389 | awful.key({ modkey, }, "Tab", 390 | function () 391 | awful.client.focus.history.previous() 392 | if client.focus then 393 | client.focus:raise() 394 | end 395 | end), 396 | 397 | -- Standard program 398 | awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), 399 | awful.key({ modkey, "Control" }, "r", awesome.restart), 400 | awful.key({ modkey, "Shift" }, "q", awesome.quit), 401 | 402 | awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), 403 | awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), 404 | awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), 405 | awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), 406 | awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), 407 | awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), 408 | awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), 409 | awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), 410 | 411 | awful.key({ modkey, "Control" }, "n", awful.client.restore), 412 | 413 | -- Prompt 414 | awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), 415 | 416 | awful.key({ modkey }, "x", 417 | function () 418 | awful.prompt.run({ prompt = "Run Lua code: " }, 419 | mypromptbox[mouse.screen].widget, 420 | awful.util.eval, nil, 421 | awful.util.getdir("cache") .. "/history_eval") 422 | end), 423 | -- Menubar 424 | awful.key({ modkey }, "p", function() menubar.show() end) 425 | ) 426 | 427 | clientkeys = awful.util.table.join( 428 | awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), 429 | awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), 430 | awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), 431 | awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), 432 | awful.key({ modkey, }, "o", awful.client.movetoscreen ), 433 | awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), 434 | awful.key({ modkey, }, "n", 435 | function (c) 436 | -- The client currently has the input focus, so it cannot be 437 | -- minimized, since minimized clients can't have the focus. 438 | c.minimized = true 439 | end), 440 | awful.key({ modkey, }, "m", 441 | function (c) 442 | c.maximized_horizontal = not c.maximized_horizontal 443 | c.maximized_vertical = not c.maximized_vertical 444 | end) 445 | ) 446 | 447 | -- Bind all key numbers to tags. 448 | -- Be careful: we use keycodes to make it works on any keyboard layout. 449 | -- This should map on the top row of your keyboard, usually 1 to 5. 450 | for i = 1, 5 do 451 | globalkeys = awful.util.table.join(globalkeys, 452 | -- View tag only. 453 | awful.key({ modkey }, "#" .. i + 9, 454 | function () 455 | local screen = mouse.screen 456 | local tag = awful.tag.gettags(screen)[i] 457 | if tag then 458 | awful.tag.viewonly(tag) 459 | end 460 | end), 461 | -- Toggle tag. 462 | awful.key({ modkey, "Control" }, "#" .. i + 9, 463 | function () 464 | local screen = mouse.screen 465 | local tag = awful.tag.gettags(screen)[i] 466 | if tag then 467 | awful.tag.viewtoggle(tag) 468 | end 469 | end), 470 | -- Move client to tag. 471 | awful.key({ modkey, "Shift" }, "#" .. i + 9, 472 | function () 473 | if client.focus then 474 | local tag = awful.tag.gettags(client.focus.screen)[i] 475 | if tag then 476 | awful.client.movetotag(tag) 477 | end 478 | end 479 | end), 480 | -- Toggle tag. 481 | awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, 482 | function () 483 | if client.focus then 484 | local tag = awful.tag.gettags(client.focus.screen)[i] 485 | if tag then 486 | awful.client.toggletag(tag) 487 | end 488 | end 489 | end)) 490 | end 491 | 492 | clientbuttons = awful.util.table.join( 493 | awful.button({ }, 1, function (c) client.focus = c; c:raise() end), 494 | awful.button({ modkey }, 1, awful.mouse.client.move), 495 | awful.button({ modkey }, 3, awful.mouse.client.resize)) 496 | 497 | -- Set keys 498 | root.keys(globalkeys) 499 | -- }}} 500 | 501 | -- {{{ Rules 502 | -- Rules to apply to new clients (through the "manage" signal). 503 | awful.rules.rules = { 504 | -- All clients will match this rule. 505 | { rule = { }, 506 | properties = { border_width = beautiful.border_width, 507 | border_color = beautiful.border_normal, 508 | focus = awful.client.focus.filter, 509 | raise = true, 510 | keys = clientkeys, 511 | buttons = clientbuttons } }, 512 | { rule = { class = "MPlayer" }, 513 | properties = { floating = true } }, 514 | { rule = { class = "pinentry" }, 515 | properties = { floating = true } }, 516 | { rule = { class = "gimp" }, 517 | properties = { floating = true } }, 518 | -- Set Firefox to always map on tags number 2 of screen 1. 519 | -- { rule = { class = "Firefox" }, 520 | -- properties = { tag = tags[1][2] } }, 521 | } 522 | -- }}} 523 | 524 | -- {{{ Signals 525 | -- Signal function to execute when a new client appears. 526 | client.connect_signal("manage", function (c, startup) 527 | -- Enable sloppy focus 528 | c:connect_signal("mouse::enter", function(c) 529 | if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier 530 | and awful.client.focus.filter(c) then 531 | client.focus = c 532 | end 533 | end) 534 | 535 | if not startup then 536 | -- Set the windows at the slave, 537 | -- i.e. put it at the end of others instead of setting it master. 538 | -- awful.client.setslave(c) 539 | 540 | -- Put windows in a smart way, only if they does not set an initial position. 541 | if not c.size_hints.user_position and not c.size_hints.program_position then 542 | awful.placement.no_overlap(c) 543 | awful.placement.no_offscreen(c) 544 | end 545 | end 546 | 547 | local titlebars_enabled = false 548 | if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then 549 | -- buttons for the titlebar 550 | local buttons = awful.util.table.join( 551 | awful.button({ }, 1, function() 552 | client.focus = c 553 | c:raise() 554 | awful.mouse.client.move(c) 555 | end), 556 | awful.button({ }, 3, function() 557 | client.focus = c 558 | c:raise() 559 | awful.mouse.client.resize(c) 560 | end) 561 | ) 562 | 563 | -- Widgets that are aligned to the left 564 | local left_layout = wibox.layout.fixed.horizontal() 565 | left_layout:add(awful.titlebar.widget.iconwidget(c)) 566 | left_layout:buttons(buttons) 567 | 568 | -- Widgets that are aligned to the right 569 | local right_layout = wibox.layout.fixed.horizontal() 570 | right_layout:add(awful.titlebar.widget.floatingbutton(c)) 571 | right_layout:add(awful.titlebar.widget.maximizedbutton(c)) 572 | right_layout:add(awful.titlebar.widget.stickybutton(c)) 573 | right_layout:add(awful.titlebar.widget.ontopbutton(c)) 574 | right_layout:add(awful.titlebar.widget.closebutton(c)) 575 | 576 | -- The title goes in the middle 577 | local middle_layout = wibox.layout.flex.horizontal() 578 | local title = awful.titlebar.widget.titlewidget(c) 579 | title:set_align("center") 580 | middle_layout:add(title) 581 | middle_layout:buttons(buttons) 582 | 583 | -- Now bring it all together 584 | local layout = wibox.layout.align.horizontal() 585 | layout:set_left(left_layout) 586 | layout:set_right(right_layout) 587 | layout:set_middle(middle_layout) 588 | 589 | awful.titlebar(c):set_widget(layout) 590 | end 591 | end) 592 | 593 | client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) 594 | client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) 595 | -- }}} 596 | --------------------------------------------------------------------------------