diff options
author | Erik Sandström <erik@kyriasis.com> | 2015-08-26 18:21:42 +0200 |
---|---|---|
committer | Erik Sandström <erik@kyriasis.com> | 2015-08-26 18:21:42 +0200 |
commit | b6cadf65e5e91c5f26ce7dd4c3a20330de560bec (patch) | |
tree | 8e5791ac11e3b0235b0b5b81f23e2a3772a77db2 | |
parent | 56e61d3abf2be52f48ca39035e9968edf600f740 (diff) | |
download | dotfiles-b6cadf65e5e91c5f26ce7dd4c3a20330de560bec.tar.xz |
81 files changed, 1019 insertions, 0 deletions
diff --git a/awesome/layouts/init.lua b/awesome/layouts/init.lua new file mode 100644 index 0000000..4cfbddb --- /dev/null +++ b/awesome/layouts/init.lua @@ -0,0 +1,7 @@ +package.loaded.layouts = nil + +local layouts = { + twily = require("layouts.twily") +} + +return layouts diff --git a/awesome/layouts/twily.lua b/awesome/layouts/twily.lua new file mode 100644 index 0000000..3544afe --- /dev/null +++ b/awesome/layouts/twily.lua @@ -0,0 +1,91 @@ +--------------------------------------------------------------- +-- Author: DWV aka Twily 2013 +-- Awesome -v 3.5 +--------------------------------------------------------------- +-- Grab environment +local tonumber = tonumber +local beautiful = require('beautiful') +local awful = awful +local math = math + +module("layouts.twily") + +name = "twily" + + +bottom_left = 0 +bottom_right = 1 + +function arrange(p) + -- Screen + local wa = p.workarea + local cls = p.clients + + local border = tonumber(beautiful.border_width) + --local gap = tonumber(beautiful.useless_gap_width) + local gap = 8 -- px (pixels normal gap (between windows)) + local fixed_gap = 10 -- px (pixels large gap (top/bottom)) + + local main_wid = 98 -- % (percent of screen width (main window width)) + local main_hei = 60 -- % (percent of screen height (main window height)) + + if #cls > 0 then + -- Center window + local c = cls[#cls] + local g = {} + local mainwid = math.floor((main_wid * wa.width) / 100) + local mainhei = math.floor((main_hei * (wa.height + wa.y)) / 100) + wa.y + local slavewid = math.floor((mainwid / 2) - (gap / 2)) - border + local slavehei = math.floor(wa.height - mainhei - (fixed_gap * 2) - gap - (border * 4)) + + g.width = mainwid + g.height = mainhei + g.x = math.floor(wa.width / 2 - (mainwid / 2)) - border + g.y = wa.y + fixed_gap + + --g.width = g.width + (fixed_gap * 2) + --g.x = g.x - fixed_gap + + c:geometry(g) + + -- Auxiliary windows + if #cls > 1 then + local at = 0 + for i = (#cls - 1),1,-1 do + if at == 3 then + break + end + + c = cls[i] + g = {} + + local cw_scale = 20 + + if at == bottom_left then + --g.x = math.floor((wa.width / 2) - (slavewid + border) - gap + (gap / 2)) - border - 1 + g.x = math.floor(wa.width - ((main_wid * wa.width) / 100) - ((((100 - main_wid) * wa.width) / 100) / 2)) - border + g.width = slavewid + elseif at == bottom_right then + --g.x = math.floor((wa.width / 2) + border + gap - (gap / 2)) - border + g.x = math.floor(wa.width - ((((100 - main_wid) * wa.width) / 100) / 2) - slavewid) - border + g.width = slavewid + end + + g.height = slavehei + + g.y = math.floor(wa.y + fixed_gap + gap + mainhei + (border * 2)) + + c:geometry(g) + + at = at + 1 + end + + -- Set remaining client to floating + for i = (#cls - 1 - 2),1,-1 do + c = cls[i] + awful.client.floating.set(c, true) + end + end + end +end + diff --git a/awesome/net_widgets/icons/wired.png b/awesome/net_widgets/icons/wired.png Binary files differnew file mode 100644 index 0000000..af47696 --- /dev/null +++ b/awesome/net_widgets/icons/wired.png diff --git a/awesome/net_widgets/icons/wired_na.png b/awesome/net_widgets/icons/wired_na.png Binary files differnew file mode 100644 index 0000000..9314217 --- /dev/null +++ b/awesome/net_widgets/icons/wired_na.png diff --git a/awesome/net_widgets/icons/wireless_0.png b/awesome/net_widgets/icons/wireless_0.png Binary files differnew file mode 100644 index 0000000..ef42a4a --- /dev/null +++ b/awesome/net_widgets/icons/wireless_0.png diff --git a/awesome/net_widgets/icons/wireless_1.png b/awesome/net_widgets/icons/wireless_1.png Binary files differnew file mode 100644 index 0000000..8b64b8f --- /dev/null +++ b/awesome/net_widgets/icons/wireless_1.png diff --git a/awesome/net_widgets/icons/wireless_2.png b/awesome/net_widgets/icons/wireless_2.png Binary files differnew file mode 100644 index 0000000..bd9d163 --- /dev/null +++ b/awesome/net_widgets/icons/wireless_2.png diff --git a/awesome/net_widgets/icons/wireless_3.png b/awesome/net_widgets/icons/wireless_3.png Binary files differnew file mode 100644 index 0000000..6cb0ed1 --- /dev/null +++ b/awesome/net_widgets/icons/wireless_3.png diff --git a/awesome/net_widgets/icons/wireless_na.png b/awesome/net_widgets/icons/wireless_na.png Binary files differnew file mode 100644 index 0000000..712a032 --- /dev/null +++ b/awesome/net_widgets/icons/wireless_na.png diff --git a/awesome/net_widgets/indicator.lua b/awesome/net_widgets/indicator.lua new file mode 100644 index 0000000..3e9ba33 --- /dev/null +++ b/awesome/net_widgets/indicator.lua @@ -0,0 +1,87 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local naughty = require("naughty") + +local indicator = {} +local function worker(args) + local args = args or {} + local widget = wibox.widget.imagebox() + + local interfaces = args.interfaces or {"enp2s0"} + local ICON_DIR = awful.util.getdir("config").."/net_widgets/icons/" + local timeout = args.timeout or 5 + local font = args.font or beautiful.font + + local connected = false + local function text_grabber() + local msg = "" + if connected then + for _, i in pairs(interfaces) do + f = io.popen("ifconfig "..i) + + line = f:read() -- wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 + line = f:read() -- inet 192.168.1.15 netmask 255.255.255.0 broadcast 192.168.1.255 + inet = string.match(line, "inet (%d+%.%d+%.%d+%.%d+)") or " N/A " + line = f:read() -- ether 50:b7:c3:08:37:b7 txqueuelen 1000 (Ethernet) + mac = string.match(line, "(%x*:%x*:%x*:%x*:%x*:%x*)") or "N/A" + + f:close() + msg = "<span font_desc=\""..font.."\">".. + "┌["..i.."]\n".. + "├IP:\t"..inet.."\n".. + "└MAC:\t"..mac.."</span>" + end + else + msg = "<span font_desc=\""..font.."\">Wired network is disconnected</span>" + end + + return msg + end + + + widget:set_image(ICON_DIR.."wired_na.png") + local function net_update() + connected = false + for _, i in pairs(interfaces) do + state = awful.util.pread("ip link show "..i.." | awk 'NR==1 {printf \"%s\", $9}'") + if (state == "UP") then + connected = true + end + if connected then + widget:set_image(ICON_DIR.."wired.png") + else + widget:set_image(ICON_DIR.."wired_na.png") + end + end + end + + net_update() + + local net_timer = timer({ timeout = timeout }) + net_timer:connect_signal("timeout", net_update) + net_timer:start() + + local notification = nil + function widget:hide() + if notification ~= nil then + naughty.destroy(notification) + notification = nil + end + end + + function widget:show(t_out) + widget:hide() + + notification = naughty.notify({ + preset = fs_notification_preset, + text = text_grabber(), + timeout = t_out, + }) + end + + widget:connect_signal('mouse::enter', function () widget:show(0) end) + widget:connect_signal('mouse::leave', function () widget:hide() end) + return widget +end +return setmetatable(indicator, {__call = function(_,...) return worker(...) end}) diff --git a/awesome/net_widgets/init.lua b/awesome/net_widgets/init.lua new file mode 100644 index 0000000..83cd5e5 --- /dev/null +++ b/awesome/net_widgets/init.lua @@ -0,0 +1,8 @@ +package.loaded.net_widgets = nil + +local net_widgets = { + indicator = require("net_widgets.indicator"), + wireless = require("net_widgets.wireless") +} + +return net_widgets diff --git a/awesome/net_widgets/wireless.lua b/awesome/net_widgets/wireless.lua new file mode 100644 index 0000000..627274a --- /dev/null +++ b/awesome/net_widgets/wireless.lua @@ -0,0 +1,121 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local naughty = require("naughty") + +local wireless = {} +local function worker(args) + local args = args or {} + + local widget = wibox.layout.fixed.horizontal() + local connected = false + + -- Settings + local ICON_DIR = awful.util.getdir("config").."/net_widgets/icons/" + local interface = args.interface or "wlan0" + local timeout = args.timeout or 5 + local font = args.font or beautiful.font + local popup_signal = args.popup_signal or false + + local net_icon = wibox.widget.imagebox() + net_icon:set_image(ICON_DIR.."wireless_na.png") + local net_text = wibox.widget.textbox() + net_text:set_text(" N/A ") + local net_timer = timer({ timeout = timeout }) + local signal_level = 0 + local function net_update() + signal_level = tonumber(awful.util.pread("awk 'NR==3 {printf \"%3.0f\" ,($3/70)*100}' /proc/net/wireless")) + if signal_level == nil then + connected = false + net_text:set_text(" N/A ") + net_icon:set_image(ICON_DIR.."wireless_na.png") + else + connected = true + net_text:set_text(string.format("%3d%%", signal_level)) + if signal_level < 25 then + net_icon:set_image(ICON_DIR.."wireless_0.png") + elseif signal_level < 50 then + net_icon:set_image(ICON_DIR.."wireless_1.png") + elseif signal_level < 75 then + net_icon:set_image(ICON_DIR.."wireless_2.png") + else + net_icon:set_image(ICON_DIR.."wireless_3.png") + end + end + end + + net_update() + net_timer:connect_signal("timeout", net_update) + net_timer:start() + + widget:add(net_icon) + -- Hide the text when we want to popup the signal instead + if not popup_signal then + widget:add(net_text) + end + + local function text_grabber() + local msg = "" + if connected then + f = io.popen("iwconfig "..interface) + line = f:read() or "" -- wlp1s0 IEEE 802.11abgn ESSID:"ESSID" + essid = string.match(line, "ESSID:\"(.+)\"") or " N/A " + line = f:read() or "" -- Mode:Managed Frequency:2.437 GHz Access Point: aa:bb:cc:dd:ee:ff + mac = string.match(line, "Access Point: (.+)") or " N/A " + line = f:read() or "" -- Bit Rate=36 Mb/s Tx-Power=15 dBm + bitrate = string.match(line, "Bit Rate=(.+/s)") or " N/A " + + f:close() + f = io.popen("ifconfig "..interface) + + line = f:read() or "" -- wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 + line = f:read() or "" -- inet 192.168.1.15 netmask 255.255.255.0 broadcast 192.168.1.255 + inet = string.match(line, "inet (%d+%.%d+%.%d+%.%d+)") or " N/A " + + f:close() + + signal = "" + if popup_signal then + signal = "├Strength\t"..signal_level.."\n" + end + msg = + "<span font_desc=\""..font.."\">".. + ""..interface.."\n".. + "├─ESSID:\t"..essid.."\n".. + "├─IP:\t\t"..inet.."\n".. + "├─BSSID:\t"..mac.."\n".. + ""..signal.. + "└─Bit rate:\t"..bitrate.."</span>" + + + else + msg = "Wireless network is disconnected" + end + + return msg + end + + local notification = nil + function widget:hide() + if notification ~= nil then + naughty.destroy(notification) + notification = nil + end + end + + function widget:show(t_out) + widget:hide() + + notification = naughty.notify({ + preset = fs_notification_preset, + text = text_grabber(), + timeout = t_out, + }) + end + + widget:connect_signal('mouse::enter', function () widget:show(0) end) + widget:connect_signal('mouse::leave', function () widget:hide() end) + return widget +end + +return setmetatable(wireless, {__call = function(_,...) return worker(...) end}) diff --git a/awesome/rc.lua b/awesome/rc.lua new file mode 100644 index 0000000..2abb7e5 --- /dev/null +++ b/awesome/rc.lua @@ -0,0 +1,619 @@ +-- Standard awesome library +local gears = require("gears") +local awful = require("awful") +awful.rules = require("awful.rules") +require("awful.autofocus") +-- Widget and layout library +local wibox = require("wibox") +-- Theme handling library +local beautiful = require("beautiful") +-- Notification library +local naughty = require("naughty") +local menubar = require("menubar") +local vicious = require("vicious") +local net_widgets = require("net_widgets") +-- Custom Layouts +local layouts = require("layouts") + +-- Compton window compositing for shadows and effects +--awful.util.spawn_with_shell("compton -cGf --config $HOME/.config/compton.conf") + +-- {{{ Error handling +-- 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 + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) +end + +-- Handle runtime errors after startup +do + local in_error = false + awesome.connect_signal("debug::error", function (err) + -- Make sure we don't go into an endless error loop + if in_error then return end + in_error = true + + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = err }) + in_error = false + end) +end +-- }}} + +-- {{{ Variable definitions +-- Themes define colours, icons, and wallpapers +beautiful.init("/home/zephcom/.config/awesome/themes/darkappa/theme.lua") +-- }}} + +-- {{{ Wallpaper rotation +function scandir(directory, filter) + local i, t, popen = 0, {}, io.popen + if not filter then + filter = function(s) return true end + end + print(filter) + for filename in popen('ls -a "'..directory..'"'):lines() do + if filter(filename) then + i = i + 1 + t[i] = filename + end + end + return t +end +-- }}} +-- {{{ configure wallpaper rotate +--wp_index = 1 +--wp_timeout = 60 +--wp_path = "/home/zephcom/Pictures/Wallpapers/Awesome/" +--wp_filter = function(s) return string.match(s,"%.png$") or string.match(s,"%.jpg$") end +--wp_files = scandir(wp_path, wp_filter) +-- wallpaper timer +--wp_timer = timer { timeout = wp_timeout } +--wp_timer:connect_signal("timeout", function() + -- set wallpaper +-- for s = 1, screen.count() do +-- gears.wallpaper.maximized(wp_path .. wp_files[wp_index], s, true) +-- end +-- -- stop the timer +-- wp_timer:stop() +-- -- random index +-- wp_index = math.random( 1, #wp_files) +-- -- restart timer +--- wp_timer.timeout = wp_timeout +-- wp_timer:start() +--end) +-- initial start +--wp_timer:start() + +-- Default Terminal Applications +terminal = "urxvt" +terminal2 = "termite" +editor = os.getenv("EDITOR") or "nano" +editor_cmd = terminal .. " -e " .. editor + +-- 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" + +-- Table of layouts to cover with awful.layout.inc, order matters. +local layouts = +{ + awful.layout.suit.floating, + awful.layout.suit.tile, + awful.layout.suit.tile.top, + layouts.twily +} +-- }}} + +-- {{{ Tags +tags = {} +for s = 1, screen.count() do + tags[s] = awful.tag({ "irc", "web", "term", "soc", "game", "read", "video", "other"}, s, layouts[1]) +end +-- }}} + +-- {{{ Menu +-- Create a laucher widget and a main menu +myawesomemenu = { + { "Manual", terminal .. " -e man awesome" }, + { "Edit Config", editor_cmd .. " " .. awesome.conffile }, + { "Restart", awesome.restart }, + { "Quit", awesome.quit } +} +gamesmenu = { + { "Steam", "steam"}, + { "Cataclysm DDA", "cataclysm-tiles"} +} +mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu }, + { "System", sysmenu, nil }, + { "Games", gamesmenu, nil }, + { "Terminal", terminal }, + { "File Browser", terminal .. " -e ranger" }, + { "&Firefox", "firefox" }, + { "&Mail", "thunderbird"}, + { "&Gimp", "gimp"}, + { "&Ncmpcpp", terminal .. " -e ncmpcpp" } + } + }) + + +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, + menu = mymainmenu }) +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it +app_folders = { "/usr/share/applications/", "~/.local/share/applications/" } +-- }}} + +-- Create a widget to place between other widgets +separator = wibox.widget.textbox(" |") + +-- Create a textclock widget +mytextclock = awful.widget.textclock() + +-- Keyboard widget, changes between ansi and shitty iso swe layout +kbdcfg = {} +kbdcfg.cmd = "setxkbmap" +kbdcfg.layout = { { "us", "" }, { "se", "" } } +kbdcfg.current = 1 -- us is our default layout +kbdcfg.widget = wibox.widget.textbox() +kbdcfg.widget:set_text(" " .. kbdcfg.layout[kbdcfg.current][1] .. "") +kbdcfg.switch = function () + kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1 + local t = kbdcfg.layout[kbdcfg.current] + kbdcfg.widget:set_text(" " .. t[1] .. "") + os.execute( kbdcfg.cmd .. " " .. t[1] .. "" .. t[2] ) + end + +-- mouse bindings for keyboard widget +kbdcfg.widget:buttons( + awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch() end)) + ) + +-- Create a battery monitor widget and configure +batimage = wibox.widget.imagebox() +batimage:set_image (beautiful.widget_battery) +batwidget = wibox.widget.textbox() +vicious.register(batwidget, vicious.widgets.bat, "$1$2% $3", 3, "BAT0") + +-- Create a widget for the clock icon +clockimage = wibox.widget.imagebox() +clockimage:set_image (beautiful.widget_clock) + +-- Create a widget for thermal monitoring and configure +thermalwidget = wibox.widget.textbox() +vicious.register(thermalwidget, vicious.widgets.thermal, "$1°С",4,"thermal_zone0") +thermalimage = wibox.widget.imagebox() +thermalimage:set_image (beautiful.widget_temp) + +-- Create a disk usage widget and configure +fsh = wibox.widget.textbox() +vicious.register(fsh, vicious.widgets.fs, '${/ used_gb}/${/ size_gb} GB (${/ used_p}%)', 5) +-- disk usage widget icon +fsh_icon = wibox.widget.imagebox() +fsh_icon:set_image (beautiful.widget_hdd) + +-- Create a volume widget +volwidget = wibox.widget.textbox() +vicious.register(volwidget, vicious.widgets.volume, " $1%", 1, "Master") +volimage = wibox.widget.imagebox() +volimage:set_image (beautiful.widget_volume) + +-- Create a memory usage widget +memimage = wibox.widget.imagebox() +memimage:set_image (beautiful.widget_mem) +memwidget = wibox.widget.textbox() +vicious.register(memwidget, vicious.widgets.mem, "$2MB") + +-- Configure externally created wireless NIC widget +net_wireless = net_widgets.wireless({interface="wlp3s0"}) + +-- Configure externally created wired NIC widget +net_wired = net_widgets.indicator({ + interfaces = {"enp0s25"}, + timeout = 5 +}) + +-- Create icon widget for mpd monitor +mpdimage = wibox.widget.imagebox() +mpdimage:set_image (beautiful.widget_music) +mpdwidget = wibox.widget.textbox() +vicious.register(mpdwidget, vicious.widgets.mpd, +function (mpdwidget, args) + if args["{state}"] == "Stop" then + return " - " + else + return args["{Artist}"]..' - '.. args["{Title}"] + |