From 72aa10c4b7dd62e95ce9f3bbded184d1b272d345 Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Mon, 20 Jan 2014 09:53:32 -0800 Subject: [PATCH 01/16] Updated imap (markdown) --- imap.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/imap.md b/imap.md index b0d5375..7952c81 100644 --- a/imap.md +++ b/imap.md @@ -46,10 +46,8 @@ and you'll have the same security provided by `~/.netrc`. **Or** you can use a keyring, like [python keyring](https://pypi.python.org/pypi/keyring): myimapcheck = lain.widgets.imap({ - is_plain = true, - password = "myplainpassword", - server = "mail.autistici.org", - mail = "dada@anche.no", + password = "keyring get mymail", + [...] }) When `is_plain == false`, it *executes* `password` before using it, so you can also use whatever password fetching solution you want. -- 2.39.2 From be14ec3ff72d205d6e65380087e9a057be2b6151 Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Mon, 20 Jan 2014 10:14:22 -0800 Subject: [PATCH 02/16] Updated imap (markdown) --- imap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap.md b/imap.md index 7952c81..f754348 100644 --- a/imap.md +++ b/imap.md @@ -31,7 +31,7 @@ Variable | Meaning | Type | Default Let's focus better on `is_plain`. -The reason why it's false by default is to discourage the habit of storing passwords in plain files. +The reason why it's false by default is to discourage the habit of storing passwords in plain. You can set your password in plain like this: -- 2.39.2 From 291910cdb61718058e81d938fb6dc1da7cc9cfff Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Mon, 20 Jan 2014 10:14:42 -0800 Subject: [PATCH 03/16] Updated imap (markdown) --- imap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap.md b/imap.md index f754348..403a61a 100644 --- a/imap.md +++ b/imap.md @@ -33,7 +33,7 @@ Let's focus better on `is_plain`. The reason why it's false by default is to discourage the habit of storing passwords in plain. -You can set your password in plain like this: +So you can set your password in plain like this: myimapcheck = lain.widgets.imap({ is_plain = true, -- 2.39.2 From e31436a3c1059a4c507e5a67dd8e4b35d21f7c3f Mon Sep 17 00:00:00 2001 From: luke bonham Date: Tue, 21 Jan 2014 16:03:04 +0100 Subject: [PATCH 04/16] wiki updated --- Home.md | 34 ------ Layouts.md | 298 -------------------------------------------------- Utilities.md | 163 --------------------------- Widgets.md | 53 --------- alsa.md | 53 --------- alsabar.md | 85 -------------- bat.md | 30 ----- borderbox.md | 49 --------- brightness.md | 40 ------- calendar.md | 31 ------ cpu.md | 18 --- fs.md | 45 -------- imap.md | 68 ------------ maildir.md | 39 ------- mem.md | 18 --- mpd.md | 85 -------------- net.md | 26 ----- sysload.md | 18 --- task.md | 30 ----- temp.md | 20 ---- tpbat.md | 9 -- wiki | 2 +- yawn.md | 93 ---------------- 23 files changed, 1 insertion(+), 1306 deletions(-) delete mode 100644 Home.md delete mode 100644 Layouts.md delete mode 100644 Utilities.md delete mode 100644 Widgets.md delete mode 100644 alsa.md delete mode 100644 alsabar.md delete mode 100644 bat.md delete mode 100644 borderbox.md delete mode 100644 brightness.md delete mode 100644 calendar.md delete mode 100644 cpu.md delete mode 100644 fs.md delete mode 100644 imap.md delete mode 100644 maildir.md delete mode 100644 mem.md delete mode 100644 mpd.md delete mode 100644 net.md delete mode 100644 sysload.md delete mode 100644 task.md delete mode 100644 temp.md delete mode 100644 tpbat.md delete mode 100644 yawn.md diff --git a/Home.md b/Home.md deleted file mode 100644 index 5581a9e..0000000 --- a/Home.md +++ /dev/null @@ -1,34 +0,0 @@ -Welcome to the Lain wiki! - -Dependencies ------------------- - -Package | Requested by | Reason of choice ---- | --- | --- -alsa-utils | [alsa](https://github.com/copycat-killer/lain/wiki/alsa), [alsabar](https://github.com/copycat-killer/lain/wiki/alsabar) | / -curl | widgets accessing network resources | LuaSocket is not a core library, and still not available for Lua 5.2+. LuaSSL is out of date. -imagemagick | album arts in [mpd](https://github.com/copycat-killer/lain/wiki/mpd) notifications | Cairo doesn't do high quality filtering. - -Installation ---------------- - -### Arch Linux - -[AUR package](https://aur.archlinux.org/packages/lain/) - -### Other distributions - - git clone https://github.com/copycat-killer/lain.git ~/.config/awesome/lain - -Usage --------- - -First, include it into your `rc.lua`: - - local lain = require("lain") - -Then check out the submodules you want: - -- [Layouts](https://github.com/copycat-killer/lain/wiki/Layouts) -- [Widgets](https://github.com/copycat-killer/lain/wiki/Widgets) -- [Utilities](https://github.com/copycat-killer/lain/wiki/Utilities) \ No newline at end of file diff --git a/Layouts.md b/Layouts.md deleted file mode 100644 index 045c2c9..0000000 --- a/Layouts.md +++ /dev/null @@ -1,298 +0,0 @@ -Currently, there are **8** layouts. - - lain/layout - . - |-- termfair - |-- centerfair - |-- cascade - |-- cascadetile - |-- centerwork - |-- uselessfair - |-- uselesspiral - `-- uselesstile - -Just add your favourites to ``layouts`` table: - - layouts = - { - ... - lain.layout.termfair, - lain.layout.uselesstile, - ... - } - -Or set them on specific tags like this: - - awful.layout.set(lain.layout.uselessfair, tags[1][7]) - -How do layouts work? -========================= - -termfair --------- - -I do a lot of work on terminals. The common tiling algorithms usually -maximize windows, so you'll end up with a terminal that has about 200 -columns or more. That's way too much. Have you ever read a manpage in a -terminal of this size? - -This layout restricts the size of each window. Each window will have the -same width but is variable in height. Furthermore, windows are -left-aligned. The basic workflow is as follows (the number above the -screen is the number of open windows, the number in a cell is the fixed -number of a client): - - (1) (2) (3) - +---+---+---+ +---+---+---+ +---+---+---+ - | | | | | | | | | | | | - | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | -> - | | | | | | | | | | | | - +---+---+---+ +---+---+---+ +---+---+---+ - - (4) (5) (6) - +---+---+---+ +---+---+---+ +---+---+---+ - | 4 | | | | 5 | 4 | | | 6 | 5 | 4 | - +---+---+---+ -> +---+---+---+ -> +---+---+---+ - | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 | - +---+---+---+ +---+---+---+ +---+---+---+ - -The first client will be located in the left column. When opening -another window, this new window will be placed in the left column while -moving the first window into the middle column. Once a row is full, -another row above it will be created. - -Default number of columns and rows are respectively taken from `nmaster` -and `ncol` values in `awful.tag`, but you can set your own. - -For example, this sets `termfair` to 3 columns and at least 1 row: - - lain.layout.termfair.nmaster = 3 - lain.layout.termfair.ncol = 1 - -centerfair ----------- - -Similar to `termfair`, but with fixed number of vertical columns. Cols are centerded until there are `nmaster` columns, then windows are stacked as slaves, with possibly `ncol` clients per column at most. - - (1) (2) (3) - +---+---+---+ +-+---+---+-+ +---+---+---+ - | | | | | | | | | | | | | - | | 1 | | -> | | 1 | 2 | | -> | 1 | 2 | 3 | -> - | | | | | | | | | | | | | - +---+---+---+ +-+---+---+-+ +---+---+---+ - - (4) (5) - +---+---+---+ +---+---+---+ - | | | 3 | | | 2 | 4 | - + 1 + 2 +---+ -> + 1 +---+---+ - | | | 4 | | | 3 | 5 | - +---+---+---+ +---+---+---+ - -Like `termfair`, default number of columns and rows are respectively taken from `nmaster` -and `ncol` values in `awful.tag`, but you can set your own. - -For example: - - lain.layout.centerfair.nmaster = 3 - lain.layout.centerfair.ncol = 1 - -cascade -------- - -Cascade all windows of a tag. - -You can control the offsets by setting these two variables: - - lain.layout.cascade.cascade_offset_x = 64 - lain.layout.cascade.cascade_offset_y = 16 - -The following reserves space for 5 windows: - - lain.layout.cascade.nmaster = 5 - -That is, no window will get resized upon the creation of a new window, -unless there's more than 5 windows. - -cascadetile ------------ - -Similar to `awful.layout.suit.tile` layout, however, clients in the slave -column are cascaded instead of tiled. - -Left column size can be set, otherwise is controlled by `mwfact` of the -tag. Additional windows will be opened in another column on the right. -New windows are placed above old windows. - -Whether the slave column is placed on top of the master window or not is -controlled by the value of `ncol`. A value of 1 means "overlapping slave column" -and anything else means "don't overlap windows". - -Usage example: - - lain.layout.cascadetile.cascade_offset_x = 2 - lain.layout.cascadetile.cascade_offset_y = 32 - lain.layout.cascadetile.extra_padding = 5 - lain.layout.cascadetile.nmaster = 5 - lain.layout.ncol = 1 - -`extra_padding` reduces the size of the master window if "overlapping -slave column" is activated. This allows you to see if there are any -windows in your slave column. - -Setting `cascade_offset_x` to a very small value or even 0 is reccommended to avoid wasting space. - -centerwork ----------- - -You start with one window, centered horizontally: - - +--------------------------+ - | +----------+ | - | | | | - | | | | - | | | | - | | MAIN | | - | | | | - | | | | - | | | | - | | | | - | +----------+ | - +--------------------------+ - -This is your main working window. You do most of the work right here. -Sometimes, you may want to open up additional windows. They're put in -the following four slots: - - +--------------------------+ - | +---+ +----------+ +---+ | - | | | | | | | | - | | 0 | | | | 1 | | - | | | | | | | | - | +---+ | MAIN | +---+ | - | +---+ | | +---+ | - | | | | | | | | - | | 2 | | | | 3 | | - | | | | | | | | - | +---+ +----------+ +---+ | - +--------------------------+ - -Yes, the number "four" is fixed. In total, you can only have five open -windows with this layout. Additional windows are not managed and set to -floating mode. **This is intentional**. - -You can set the order of the four auxiliary windows. This is the default -configuration: - - lain.layout.centerwork.top_left = 0 - lain.layout.centerwork.top_right = 1 - lain.layout.centerwork.bottom_left = 2 - lain.layout.centerwork.bottom_right = 3 - -This means: The bottom left slot will be occupied by the third window -(not counting the main window). Suppose you want your windows to appear -in this order: - - +--------------------------+ - | +---+ +----------+ +---+ | - | | | | | | | | - | | 3 | | | | 0 | | - | | | | | | | | - | +---+ | MAIN | +---+ | - | +---+ | | +---+ | - | | | | | | | | - | | 2 | | | | 1 | | - | | | | | | | | - | +---+ +----------+ +---+ | - +--------------------------+ - -This would require you to use these settings: - - lain.layout.centerwork.top_left = 3 - lain.layout.centerwork.top_right = 0 - lain.layout.centerwork.bottom_left = 2 - lain.layout.centerwork.bottom_right = 1 - -*Please note:* If you use Awesome's default configuration, navigation in -this layout may be very confusing. How do you get from the main window -to satellite ones depends on the order in which the windows are opened. -Thus, use of `awful.client.focus.bydirection()` is suggested. -Here's an example: - - globalkeys = awful.util.table.join( - ... - awful.key({ modkey }, "j", - function() - awful.client.focus.bydirection("down") - if client.focus then client.focus:raise() end - end), - awful.key({ modkey }, "k", - function() - awful.client.focus.bydirection("up") - if client.focus then client.focus:raise() end - end), - awful.key({ modkey }, "h", - function() - awful.client.focus.bydirection("left") - if client.focus then client.focus:raise() end - end), - awful.key({ modkey }, "l", - function() - awful.client.focus.bydirection("right") - if client.focus then client.focus:raise() end - end), - ... - ) - -uselessfair, uselesspiral & uselesstile ---------------------------------------- -These are duplicates of the stock `fair`, `spiral` and `tile` layouts. - -However, "useless gaps" (see below) have been added. - -Useless gaps -============ - -Useless gaps are gaps between windows. They are "useless" because they -serve no special purpose despite increasing overview. I find it easier -to recognize window boundaries if windows are set apart a little bit. - -The `uselessfair` layout, for example, looks like this: - - +================+ - # # - # +---+ +---+ # - # | 1 | | | # - # +---+ | | # - # | 3 | # - # +---+ | | # - # | 2 | | | # - # +---+ +---+ # - # # - +================+ - -All of lain layouts provide useless gaps. To set the width of the gaps, -you have to add an item called `useless_gap_width` in your `theme.lua`. -If it doesn't exist, the width will default to 0. -Example: - - theme.useless_gap_width = 10 - -What about layout icons? -======================== - -They are located in ``lain/icons/layout``. - -To use them, add lines to your ``theme.lua`` like this: - - theme.lain_icons = os.getenv("HOME") .. "/.config/awesome/lain/icons/layout/default/" - theme.layout_termfair = theme.lain_icons .. "termfairw.png" - theme.layout_cascade = theme.lain_icons .. "cascadew.png" - theme.layout_cascadetile = theme.lain_icons .. "cascadetilew.png" - theme.layout_centerwork = theme.lain_icons .. "centerworkw.png" - -Credits goes to [Nicolas Estibals](https://github.com/nestibal) for creating -layout icons for default theme. - -You can use them as a template for your custom versions. - -[<- home](https://github.com/copycat-killer/lain/wiki) \ No newline at end of file diff --git a/Utilities.md b/Utilities.md deleted file mode 100644 index 99588b9..0000000 --- a/Utilities.md +++ /dev/null @@ -1,163 +0,0 @@ -markup ------- - -Made markup easier! - -First, require it like this: - - local markup = lain.util.markup - -then you can call its functions: - - +-- markup - | - |`-- bold() Set bold. - |`-- italic() Set italicized text. - |`-- strike() Set strikethrough text. - |`-- underline() Set underlined text. - |`-- monospace() Set monospaced text. - |`-- big() Set bigger text. - |`-- small() Set smaller text. - |`-- font() Set the font of the text. - | - |`--+ bg - | | - | |`-- color() Set background color. - | |`-- focus() Set focus background color. - | |`-- normal() Set normal background color. - | `-- urgent() Set urgent background color. - | - |`--+ fg - | | - | |`-- color() Set foreground color. - | |`-- focus() Set focus foreground color. - | |`-- normal() Set normal foreground color. - | `-- urgent() Set urgent foreground color. - | - |`-- focus() Set both foreground and background focus colors. - |`-- normal() Set both foreground and background normal colors. - `-- urgent() Set both foreground and background urgent colors. - -they all take one argument, which is the text to markup, except `fg.color` and `bg.color`: - - markup.fg.color(text, color) - markup.bg.color(text, color) - -dynamic tagging ---------------- - -That is: - -- add a new tag; -- rename current tag; -- move current tag; -- remove current tag. - -If you delete a tag, any rule set on it shall be broken, so be careful. - -Use it with key bindings like these: - - awful.key({ modkey, "Shift" }, "n", function () lain.util.add_tag(mypromptbox) end), - awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag(mypromptbox) end), - awful.key({ modkey, "Shift" }, "Left", function () lain.util.move_tag(1) end), -- move to next tag - awful.key({ modkey, "Shift" }, "Right", function () lain.util.move_tag(-1) end), -- move to previous tag - awful.key({ modkey, "Shift" }, "d", function () lain.util.remove_tag() end), - -**Note** that these function won't work properly with [Copland theme](https://github.com/copycat-killer/awesome-copycats) or any other configuration that already uses a dynamic tagging module like [Eminent](https://github.com/copycat-killer/awesome-copycats/tree/master/eminent). - -useless\_gaps\_resize ---------------------- - -Changes `beautiful.useless_gaps_width` on the fly. - -The function takes an integer argument, being the amount of pixel to add/remove to gaps. - -You could use it with these keybindings: - - -- On the fly useless gaps change - awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end), - awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end), - -where `altkey=Mod1`, or you could use it like this: - - mywidget:buttons(awful.util.table.join ( - awful.button({}, 4, function() lain.util.useless_gaps_resize(-1) end), - awful.button({}, 5, function() lain.util.useless_gaps_resize(1) end) - end) - )) - -so when hovering the mouse over `mywidget`, you can adjust useless gaps size by scrolling with the mouse wheel. - -tag\_view\_nonempty -------------------- - -This function lets you jump to the next/previous non-empty tag. -It takes two arguments: - -* `direction`: `1` for next non-empty tag, `-1` for previous. -* `sc`: Screen which the taglist is in. Default is `mouse.screen` or `1`. This - argument is optional. - -You can use it with key bindings like these: - - -- Non-empty tag browsing - awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end), - awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end), - -where `altkey = "Mod1"`. - -menu\_clients\_current\_tags ----------------------------- - -Similar to `awful.menu.clients`, but this menu only shows the clients -of currently visible tags. Use it with a key binding like this: - - awful.key({ "Mod1" }, "Tab", - function() - awful.menu.menu_keys.down = { "Down", "Alt_L", "Tab", "j" } - awful.menu.menu_keys.up = { "Up", "k" } - lain.util.menu_clients_current_tags({ width = 350 }, { keygrabber = true }) - end), - -magnify\_client ---------------- - -Set a client to floating and resize it in the same way the "magnifier" -layout does it. Place it on the "current" screen (derived from the mouse -position). This allows you to magnify any client you wish, regardless of -the currently used layout. Use it with a client keybinding like this: - - clientkeys = awful.util.table.join( - ... - awful.key({ modkey, "Control" }, "m", lain.util.magnify_client), - ... - ) - -If you want to "de-magnify" it, just retype the keybinding. - -niceborder\_{focus, unfocus} ----------------------------- - -By default, your `rc.lua` contains something like this: - - 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) - -You can change it to this: - - client.connect_signal("focus", lain.util.niceborder_focus(c)) - client.connect_signal("unfocus", lain.util.niceborder_unfocus(c)) - -Now, when a client is focused or unfocused, Awesome will look up its -nice value in `/proc//stat`. If it's less than 0, the client is -classified as "high priority"; if it's greater than 0, the client is -classified as "low priority". If it's equal to 0, nothing special -happens. - -This requires to define additional colors in your `theme.lua`. For example: - - theme.border_focus_highprio = "#FF0000" - theme.border_normal_highprio = "#A03333" - - theme.border_focus_lowprio = "#3333FF" - theme.border_normal_lowprio = "#333366" \ No newline at end of file diff --git a/Widgets.md b/Widgets.md deleted file mode 100644 index 5917aac..0000000 --- a/Widgets.md +++ /dev/null @@ -1,53 +0,0 @@ -General usage -------------- - -Every widget is output by a `function`. - -For some widgets, `function` returns a `wibox.widget.textbox`, for others a table to be used for notification and update purposes. - -Every widget may take either a table or a list of variables as argument. - -If it takes a table, you have to define a function variable called `settings` in it, in order to make your customizations. - -To markup the textbox, call `widget:set_markup(...)` within `settings`. - -You can feed `set_markup` with predefined arguments, see the sections for all the details. - -`widget` is a textbox, so you can threat it like any other `wibox.widget.textbox`. - -Here follows an example: - - mycpu = lain.widgets.cpu({ - timeout = 4, - settings = function() - widget:set_markup("Cpu " .. cpu_now.usage) - end - }) - -If you want to see more complex applications, check [awesome-copycats](https://github.com/copycat-killer/awesome-copycats). - -Index ------ - -- [alsa](https://github.com/copycat-killer/lain/wiki/alsa) -- [alsabar](https://github.com/copycat-killer/lain/wiki/alsabar) -- [bat](https://github.com/copycat-killer/lain/wiki/bat) -- [borderbox](https://github.com/copycat-killer/lain/wiki/borderbox) -- [calendar](https://github.com/copycat-killer/lain/wiki/calendar) -- [cpu](https://github.com/copycat-killer/lain/wiki/cpu) -- [fs](https://github.com/copycat-killer/lain/wiki/fs) -- [imap](https://github.com/copycat-killer/lain/wiki/imap) -- [maildir](https://github.com/copycat-killer/lain/wiki/maildir) -- [mem](https://github.com/copycat-killer/lain/wiki/mem) -- [mpd](https://github.com/copycat-killer/lain/wiki/mpd) -- [net](https://github.com/copycat-killer/lain/wiki/net) -- [sysload](https://github.com/copycat-killer/lain/wiki/sysload) -- [temp](https://github.com/copycat-killer/lain/wiki/temp) -- [yawn](https://github.com/copycat-killer/lain/wiki/yawn) - -Users contributed ----------------- - -- [task](https://github.com/copycat-killer/lain/wiki/task) -- [tpbat](https://github.com/copycat-killer/lain/wiki/tpbat) -- [brightness](https://github.com/copycat-killer/lain/wiki/brightness) \ No newline at end of file diff --git a/alsa.md b/alsa.md deleted file mode 100644 index daf4016..0000000 --- a/alsa.md +++ /dev/null @@ -1,53 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows and controls alsa volume with a textbox. - - volumewidget = lain.widgets.alsa() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 5 -`channel` | Mixer channel | string | "Master" -`settings` | User settings | function | empty function - -`settings` can use the following variables: - -Variable | Meaning | Type | Values ---- | --- | --- | --- -`volume_now.level` | Self explained | int | 0-100 -`volume_now.status` | Device status | string | "on", "off" - -### output table - -Variable | Meaning | Type ---- | --- | --- -`widget` | The widget | `wibox.widget.textbox` -`update` | Update `widget` | function - -You can control the widget with key bindings like these: - - -- Volume control - awful.key({ altkey }, "Up", - function () - awful.util.spawn("amixer set Master 1%+") - volumewidget.update() - end), - awful.key({ altkey }, "Down", - function () - awful.util.spawn("amixer set Master 1%-") - volumewidget.update() - end), - awful.key({ altkey }, "m", - function () - awful.util.spawn("amixer set Master playback toggle") - volumewidget.update() - end), - awful.key({ altkey, "Control" }, "m", - function () - awful.util.spawn("amixer set Master playback 100%", false ) - volumewidget.update() - end), - -where `altkey = "Mod1"`. \ No newline at end of file diff --git a/alsabar.md b/alsabar.md deleted file mode 100644 index 6138f2c..0000000 --- a/alsabar.md +++ /dev/null @@ -1,85 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows and controls alsa volume with a progressbar; provides tooltips, notifications, and color changes at mute/unmute switch. - - volume = lain.widgets.alsabar() - -* Left click: Launch `alsamixer` in your `terminal`. -* Right click: Mute/unmute. -* Scroll wheel: Increase/decrase volume. - -The function takes a table as optional argument, which can contain: - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 4 -`settings` | User settings | function | empty function -`width` | Bar width | int | 63 -`height` | Bar height | int | 1 -`ticks` | Set bar ticks on | boolean | false -`ticks_size` | Ticks size | int | 7 -`vertical` | Set the bar vertical | boolean | false -`channel` | Mixer channel | string | "Master" -`step` | Step at which volume is increased/decreased | string | "5%" -`colors` | Bar colors | table | see **colors** -`notifications` | Notifications settings | table | see **notifications** - -### colors - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`background` | Bar backgrund color | string | `beautiful.bg_normal` -`mute` | Bar mute color | string | "#EB8F8F" -`unmute` | Bar unmute color | string | "#A4CE8A" - -### notifications - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`font` | Notifications font | string | The one defined in `beautiful.font` -`font_size` | Notifications font size | string | "11" -`color` | Notifications color | string | `beautiful.fg_normal` -`bar_size` | Wibox height | int | 18 - -It's **crucial** to set `notifications.bar_size` to your `mywibox[s]` height. - -`settings` can use the following variables: - -Variable | Meaning | Type | Values ---- | --- | --- | --- -`volume_now.level` | Self explained | int | 0-100 -`volume_now.status` | Device status | string | "on", "off" -### output table - -Variable | Meaning | Type ---- | --- | --- -`bar` | The widget | `awful.widget.progressbar` -`channel` | Alsa channel | string -`step` | Increase/decrease step | string -`notify` | The notification | function - -You can control the widget with key bindings like these: - - -- ALSA volume control - awful.key({ altkey }, "Up", - function () - awful.util.spawn("amixer -q set " .. volume.channel .. " " .. volume.step .. "+") - volume.notify() - end), - awful.key({ altkey }, "Down", - function () - awful.util.spawn("amixer -q set " .. volume.channel .. " " .. volume.step .. "-") - volume.notify() - end), - awful.key({ altkey }, "m", - function () - awful.util.spawn("amixer -q set " .. volume.channel .. " playback toggle") - volume.notify() - end), - awful.key({ altkey, "Control" }, "m", - function () - awful.util.spawn("amixer -q set " .. volume.channel .. " playback 100%") - volume.notify() - end), - -where `altkey = "Mod1"`. \ No newline at end of file diff --git a/bat.md b/bat.md deleted file mode 100644 index 6bbb21e..0000000 --- a/bat.md +++ /dev/null @@ -1,30 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows in a textbox the remaining time and percentage capacity of your laptop battery, as well as -the current wattage. - -Displays a notification when battery is low or critical. - - mybattery = lain.widgets.bat() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 30 -`battery` | Identifier of the battery | string | "BAT0" -`notify` | Enable notifications | string | "on" -`settings` | User settings | function | empty function - -`settings` can use the `bat_now` table, which contains the following strings: - -- `status` ("Not present", "Charging", "Discharging"); -- `perc`; -- `time`; -- `watt`. - -To disable warning notifications, set `notify` to `"off"`. - -### output - -A textbox. \ No newline at end of file diff --git a/borderbox.md b/borderbox.md deleted file mode 100644 index a56026a..0000000 --- a/borderbox.md +++ /dev/null @@ -1,49 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Creates a thin wibox at a position relative to another wibox. - -This allows to create "borders" for your wiboxes. - - lain.widget.borderbox(relbox, s, args) - -`relbox` and `s` (an integer being screen number) are required arguments, `args` is an optional table -which can contain: - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`position` | Position of the additional box | string | "above" -`color` | Color of the additional box | string | `#FFFFFF` -`size` | Size in pixels of the additional box | int | 1 - -Possible values for `.position`: `top`, `bottom`, `left` and `right`. - -### Example usage - -Think of this as a wibox: - - [======================] - -If `args.position = "above"`, then you'll get an additional wibox below -the existing one: - - ________________________ - [======================] - -It'll match position and size of the existing wibox. - -If your main wiboxes are stored in a table called `mywibox` (one wibox -for each screen) and are located at the bottom of your screen, then this -adds a borderbox on top of them: - - -- Layout section - for s = 1, screen.count() do - ... - - -- Most likely, you'll want to do this as well: - awful.screen.padding(screen[s], "bottom") - - -- Create the box and place it above the existing box. - lain.widgets.borderbox(mywibox[s], s ) - - ... - end \ No newline at end of file diff --git a/brightness.md b/brightness.md deleted file mode 100644 index 4cd4f8e..0000000 --- a/brightness.md +++ /dev/null @@ -1,40 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows the current level of screen brightness in a textbox. - - brightnesswidget = lain.widgets.contrib.brightness() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 5 -`backlight` | Backlight video | string | "acpi_video0" -`settings` | User settings | function | empty function - -`settings` can use the following variables: - -Variable | Meaning | Type | Values ---- | --- | --- | --- -`brightness_now` | Brightness level | int | 0-100 - -### output table - -Variable | Meaning | Type ---- | --- | --- -`widget` | The widget | `wibox.widget.textbox` -`update` | Update `widget` | function - -You can control the widget with key bindings like these: - - -- Brightness control - awful.key({}, "XF86MonBrightnessUp", - function () - awful.util.spawn("xbacklight -inc 1") - brightnesswidget.update() - end), - awful.key({}, "XF86MonBrightnessDown", - function () - awful.util.spawn("xbacklight -dec 1") - brightnesswidget.update() - end), \ No newline at end of file diff --git a/calendar.md b/calendar.md deleted file mode 100644 index b06c453..0000000 --- a/calendar.md +++ /dev/null @@ -1,31 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Attaches a calendar notification to a widget. - - lain.widgets.calendar:attach(widget, args) - -- Left click: switch to previous month. -- Right click: switch to next month. - -`args` is an optional table which can contain: - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`icons` | Path to calendar icons | string | [lain/icons/cal/white](https://github.com/copycat-killer/lain/tree/master/icons/cal/white) -`font_size` | Calendar font size | int | 12 -`fg` | Calendar foreground color | string | `beautiful.fg_normal` -`bg` | Calendar background color | string | `beautiful.bg_normal` -`position` | Calendar position | string | "top_right" - -`position` possible values are defined [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify). - -Notification will show an icon displaying current day, and formatted output -from ``cal`` with current day highlighted. - -You can call the notification with a key binding like this: - - awful.key({ altkey }, "c", function () lain.widgets.calendar:show(7) end), - -where ``altkey = "Mod1"`` and ``show`` argument is an optional integer, meaning timeout seconds. - -**Note that** this widget exploits ``cal`` to do the alignment, in order to avoid more dozens of code lines, but this requires that your system font is monospaced. \ No newline at end of file diff --git a/cpu.md b/cpu.md deleted file mode 100644 index e42180c..0000000 --- a/cpu.md +++ /dev/null @@ -1,18 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows in a textbox the average CPU usage percent for a given amount of time. - - mycpuusage = lain.widgets.cpu() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 5 -`settings` | User settings | function | empty function - -`settings` can use the string `cpu_now.usage`, which is the cpu use percentage. - -### output - -A textbox. \ No newline at end of file diff --git a/fs.md b/fs.md deleted file mode 100644 index 1e34f86..0000000 --- a/fs.md +++ /dev/null @@ -1,45 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows disk space usage for a set partition. - -Displays a notification when the partition is full or has low space. - - mypartition = lain.widgets.fs() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds -| int | 600 -`partition` | Partition to monitor | string | "/" -`settings` | User settings | function | empty function - -`settings` can use the following `partition` related float values: `fs_now.used`, `fs_now.available`, `fs_now.size_mb`, `fs_now.size_gb`. - -It can also use value strings in these formats: - - fs_info[p .. "used_p"] - fs_info[p .. "avail_p"] - fs_info[p .. "size_mb"] - fs_info[p .. "size_gb"] - -where `p` is the last column of `df` command ("/", "/home", "/boot", ...). - -This means you can set the widget for a certain partition, but you can look up at others too. - -Finally, `settings` can modify `fs_notification_preset` table too. This table will be the preset for the naughty notifications. Check [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify) for the list of variables it can contain. Default definition: - - fs_notification_preset = { fg = beautiful.fg_normal } - -### output table - -Variable | Meaning | Type ---- | --- | --- -`widget` | The widget | `wibox.widget.textbox` -`show` | The notification | function - -You can display the notification with a key binding like this: - - awful.key({ altkey }, "h", function () mypartition.show(7) end), - -where ``altkey = "Mod1"`` and ``show`` argument is an optional integer, meaning timeout seconds. \ No newline at end of file diff --git a/imap.md b/imap.md deleted file mode 100644 index 403a61a..0000000 --- a/imap.md +++ /dev/null @@ -1,68 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows mail count in a textbox fetching over IMAP. - - myimapcheck = lain.widgets.imap(args) - -New mails are notified like this: - - +--------------------------------------------+ - | +---+ | - | |\ /| donald@disney.org has 3 new messages | - | +---+ | - +--------------------------------------------+ - -The function takes a table as argument. Required table parameters are: - -Variable | Meaning | Type ---- | --- | --- -`server` | Mail server | string -`mail` | User mail | string -`password` | User password | string - -while the optional are: - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`port` | IMAP port | int | 993 -`timeout` | Refresh timeout seconds | int | 60 -`is_plain` | Define whether `password` is a plain password (true) or a function that retrieves it (false) | boolean | false -`settings` | User settings | function - -Let's focus better on `is_plain`. - -The reason why it's false by default is to discourage the habit of storing passwords in plain. - -So you can set your password in plain like this: - - myimapcheck = lain.widgets.imap({ - is_plain = true, - password = "myplainpassword", - [...] - }) - -and you'll have the same security provided by `~/.netrc`. - -**Or** you can use a keyring, like [python keyring](https://pypi.python.org/pypi/keyring): - - myimapcheck = lain.widgets.imap({ - password = "keyring get mymail", - [...] - }) - -When `is_plain == false`, it *executes* `password` before using it, so you can also use whatever password fetching solution you want. - -`settings` can use the value `mailcount`, an integer greater or equal to zero, and can modify `mail_notification_preset` table, which will be the preset for the naughty notifications. Check [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify) for the list of variables it can contain. - -Default definition: - - mail_notification _preset = { - icon = lain/icons/mail.png, - position = "top_left" - } - -Note that `mailcount` is 0 either if there are no new mails or credentials are invalid, so make sure you get the right settings. - -### output - -A textbox. \ No newline at end of file diff --git a/maildir.md b/maildir.md deleted file mode 100644 index 355ecdd..0000000 --- a/maildir.md +++ /dev/null @@ -1,39 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows maildirs status in a textbox. - -Maildirs are structured as follows: - - ~/Mail - . - |-- arch - | |-- cur - | |-- new - | `-- tmp - |-- gmail - | |-- cur - | |-- new - | `-- tmp - . - . - . - -therefore the widget checks whether there are files in the `new` directories. -If there's new mails, the textbox will say something like "mail: bugs(3), system(1)", otherwise it says -"no mail". - - mymaildir = lain.widgets.maildir("/path/to/my/maildir") - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 60 -`mailpath` | Path to your maildir | string | "~/Mail" -`settings` | User settings | function | empty function - -`settings` can use the string `newmail`, which format will be something like defined above, or "no mail". - -### output - -A textbox. \ No newline at end of file diff --git a/mem.md b/mem.md deleted file mode 100644 index 84b7ad2..0000000 --- a/mem.md +++ /dev/null @@ -1,18 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows memory status (in MiB) in a textbox. - - mymem = lain.widgets.mem() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 3 -`settings` | User settings | function | empty function - -`settings` can use the strings `mem_now.used` (memory used MB) and `mem_now.swapused` (swap used MB). - -### output - -A textbox. \ No newline at end of file diff --git a/mpd.md b/mpd.md deleted file mode 100644 index 646b690..0000000 --- a/mpd.md +++ /dev/null @@ -1,85 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows MPD status in a textbox. - - mpdwidget = lain.widgets.mpd() - -Now playing songs are notified like this: - - +--------------------------------------------------------+ - | +-------+ | - | |/^\_/^\| Now playing | - | |\ O O /| Cannibal Corpse (Hammer Smashed Face) - 1993 | - | | '.o.' | Hammer Smashed Face (Radio Disney Version) | - | +-------+ | - +--------------------------------------------------------+ - -You need a file like this - - (Front|front|Cover|cover|Art|art|Folder|folder)\.(jpg|jpeg|png|gif) - -in the album folder in order to show album art too. - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 1 -`password` | MPD password | string | "" -`host` | MPD server | string | "127.0.0.1" -`port` | MPD port | string | "6600" -`music_dir` | Music directory | string | "~/Music" -`cover_size` | Album art notification size | int | 100 -`default_art` | Default art | string | "" -`settings` | User settings | function | empty function - -`settings` can use `mpd_now` table, which contains the following string values: - -- state (possible values: "play", "pause", "stop") -- file -- artist -- title -- album -- date - -and can modify `mpd_notification_preset` table, which will be the preset for the naughty notifications. Check [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify) for the list of variables it can contain. Default definition: - - mpd_notification_preset = { - title = "Now playing", - timeout = 6, - text = string.format("%s (%s) - %s\n%s", mpd_now.artist, - mpd_now.album, mpd_now.date, mpd_now.title) - } - -### output table - -Variable | Meaning | Type ---- | --- | --- -`widget` | The textbox | `wibox.widget.textbox` -`update` | The notification | function - -You can control the widget with key bindings like these: - - -- MPD control - awful.key({ altkey, "Control" }, "Up", - function () - awful.util.spawn_with_shell("mpc toggle || ncmpcpp toggle || ncmpc toggle || pms toggle") - mpdwidget.update() - end), - awful.key({ altkey, "Control" }, "Down", - function () - awful.util.spawn_with_shell("mpc stop || ncmpcpp stop || ncmpc stop || pms stop") - mpdwidget.update() - end), - awful.key({ altkey, "Control" }, "Left", - function () - awful.util.spawn_with_shell("mpc prev || ncmpcpp prev || ncmpc prev || pms prev") - mpdwidget.update() - end), - awful.key({ altkey, "Control" }, "Right", - function () - awful.util.spawn_with_shell("mpc next || ncmpcpp next || ncmpc next || pms next") - mpdwidget.update() - end), - -where `altkey = "Mod1"`. \ No newline at end of file diff --git a/net.md b/net.md deleted file mode 100644 index f857239..0000000 --- a/net.md +++ /dev/null @@ -1,26 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Monitors network interfaces and shows current traffic in a textbox. - - mynet = lain.widgets.net() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 2 -`iface` | Network device | string | autodetected -`units` | Units | int | 1024 (kilobytes) -`settings` | User settings | function | empty function - -Possible other values for `units` are 1 (byte) or multiple of 1024: 1024^2 (mb), 1024^3 (gb), and so on. - -`settings` can use the following `iface` related strings: - -- `net_now.carrier` ("0", "1"); -- `net_now.state` ("up", "down"); -- `net_now.sent` and `net_now.received` (numbers). - -### output - -A textbox. \ No newline at end of file diff --git a/sysload.md b/sysload.md deleted file mode 100644 index 3e53881..0000000 --- a/sysload.md +++ /dev/null @@ -1,18 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows the current system load. - - mysysload = lain.widgets.sysload() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 5 -`settings` | User settings | function | empty function - -`settings` can use strings `load_1`, `load_5` and `load_15`, which are loadavg over 1, 5, and 15 minutes. - -### output - -A textbox. \ No newline at end of file diff --git a/task.md b/task.md deleted file mode 100644 index b4bc7f0..0000000 --- a/task.md +++ /dev/null @@ -1,30 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Attaches a [taskwarrior](http://taskwarrior.org/projects/show/taskwarrior) notification to a widget, and lets to add/search tasks from the promptbox. - - lain.widgets.contrib.task:attach(widget, args) - -`args` is an optional table which can contain: - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`font_size` | Calendar font size | int | 12 -`fg` | Calendar foreground color | string | `beautiful.fg_normal` -`bg` | Calendar background color | string | `beautiful.bg_normal` -`position` | Calendar position | string | "top_right" -`timeout` | Notification timeout seconds | int | 7 - -`position` possible values are defined [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify). - -Notification will show the output of `task` command. - -You can call the notification with a key binding like this: - - awful.key({ modkey, altkey }, "t", lain.widgets.contrib.task.show), - -where ``altkey = "Mod1"``. - -And you can prompt to add/search a task with key bindings like these: - - awful.key({ modkey, }, "t", lain.widgets.contrib.task.prompt_add), - awful.key({ modkey, "Shift" }, "t", lain.widgets.contrib.task.prompt_search), \ No newline at end of file diff --git a/temp.md b/temp.md deleted file mode 100644 index 91f3031..0000000 --- a/temp.md +++ /dev/null @@ -1,20 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -Shows the current core temperature in a textbox. - -Reads from `/sys/class/thermal`, so value is expressed in Celsius. - - mytemp = lain.widgets.temp() - -### input table - -Variable | Meaning | Type | Default ---- | --- | --- | --- -`timeout` | Refresh timeout seconds | int | 5 -`settings` | User settings | function | empty function - -`settings` can use the string `coretemp_now`, which means current core temperature, expressed in Celsius (linux standard). - -### output - -A textbox. \ No newline at end of file diff --git a/tpbat.md b/tpbat.md deleted file mode 100644 index 5a7ba0c..0000000 --- a/tpbat.md +++ /dev/null @@ -1,9 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -A battery widget that works with Lenovo ThinkPad laptops using [tp_smapi](http://www.thinkwiki.org/wiki/Tp_smapi). - -Includes hover notification with more details. - - tpbatwidget = lain.widgets.contrib.tpbat() - -Configuration is identical to [standard battery widget's](https://github.com/copycat-killer/lain/wiki/bat). \ No newline at end of file diff --git a/wiki b/wiki index f996cdb..2fe55cb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit f996cdb74e7583534256d82706ef63d2b9811b42 +Subproject commit 2fe55cb50b4192866551d50dce563a52234961c7 diff --git a/yawn.md b/yawn.md deleted file mode 100644 index 30d160c..0000000 --- a/yawn.md +++ /dev/null @@ -1,93 +0,0 @@ -[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets) - -(YAhoo! Weather Notification) - -Yawn provides brief and compact Yahoo! Weather notification. - -Usage ------ - -You can ``register`` Yawn to get a set of widgets, or ``attach`` it to -an existent widget. - -### register - - yawn = lain.widgets.yawn(id, args) - -- ``id`` - - An integer that defines the WOEID code of your city. - To obtain it you can google 'yahoo weather %CITYNAME%' and follow the first link. - It will look like: - - http://weather.yahoo.com/united-states/california/san-diego-2487889/ - - and the last number in that link will be the ID you need. - -- ``args`` - - A required table which can contain: - - Variables | Meaning | Type | Possible values | Default value - --- | --- | --- | --- | --- - `u` | Units | string | "c" (Celsius), "f" (Fahrenheit) | "c" - `timeout` | Refresh timeout seconds | int | integers | 600 - `settings` | User settings | function | function | empty function - - `settings` can use strings `forecast`, `units`, and can modify `yawn_notification_preset` table, which - will be the preset for the naughty notifications. Check [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify) for the list of variables it can contain. - -The function `register` creates an imagebox icon and a textbox widget. Add them to you wibox like this: - - right_layout:add(yawn.icon) - right_layout:add(yawn.widget) - -Hovering over ``yawn.icon`` will display the notification. - -### attach - - lain.widgets.yawn.attach(widget, id, args) - -Arguments: - -- ``widget`` - - The widget which you want to attach Yawn to. - -- ``id`` - - Same as in ``register``. - -- ``args`` - - Same as in ``register``. - -Hovering over ``widget`` will display the notification. - -Popup shortcut --------------- - -You can also create a keybinding for the weather popup like this: - - awful.key( { "Mod1" }, "w", function () yawn.show(5) end ) - -where ``show`` argument is an integer defining timeout seconds. - -Localization ------------- - -Default language is English, but Yawn can be localized. - -Move to `localizations` subdirectory and fill `localization_template`. - -Once you're done, rename it like your locale id. In my case: - - $ lua - Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio - > print(os.getenv("LANG"):match("(%S*$*)[.]")) - it_IT - > - -hence I named my file "it_IT" (Italian localization). - -**NOTE:** If you create a localization, feel free to send me! I will add it. \ No newline at end of file -- 2.39.2 From 89d557638deb75bc3d0e6c8890cb7eec59ab0ce2 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Wed, 29 Jan 2014 11:56:32 +0100 Subject: [PATCH 05/16] new I/O file helper functions --- helpers.lua | 45 ++++++++++++++++++++++++++++++++----------- widgets/maildir.lua | 1 + widgets/yawn/init.lua | 1 + wiki | 2 +- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/helpers.lua b/helpers.lua index c42ce61..08aba0d 100644 --- a/helpers.lua +++ b/helpers.lua @@ -10,7 +10,8 @@ local debug = require("debug") local capi = { timer = timer } -local io = { open = io.open } +local io = { open = io.open, + lines = io.lines } local rawget = rawget -- Lain helper functions for internal use @@ -30,18 +31,40 @@ end -- }}} --- {{{ Read the first line of a file or return nil +-- {{{ File operations -function helpers.first_line(f) - local fp = io.open(f) - if not fp - then - return nil - end +-- see if the file exists +function helpers.file_exists(file) + local f = io.open(file, "rb") + if f then f:close() end + return f ~= nil +end + + +-- get all lines from a file, returns an empty +-- list/table if the file does not exist +function helpers.lines_from(file) + if not helpers.file_exists(file) then return {} end + lines = {} + for line in io.lines(file) do + lines[#lines + 1] = line + end + return lines +end + +-- get first line of a file, return nil if +-- the file does not exist +function helpers.first_line(file) + return helpers.lines_from(file)[1] +end - local content = fp:read("*l") - fp:close() - return content +-- get first non empty line from a file, +-- returns nil otherwise +function helpers.first_nonempty_line(file) + for k,v in pairs(lines_from(file)) do + if #v then return v end + end + return nil end -- }}} diff --git a/widgets/maildir.lua b/widgets/maildir.lua index 5cb6840..d460881 100644 --- a/widgets/maildir.lua +++ b/widgets/maildir.lua @@ -1,3 +1,4 @@ + --[[ Licensed under GNU General Public License v2 diff --git a/widgets/yawn/init.lua b/widgets/yawn/init.lua index 36cdf54..b4d9c05 100644 --- a/widgets/yawn/init.lua +++ b/widgets/yawn/init.lua @@ -1,3 +1,4 @@ + --[[ Licensed under GNU General Public License v2 diff --git a/wiki b/wiki index 2fe55cb..6825e84 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 2fe55cb50b4192866551d50dce563a52234961c7 +Subproject commit 6825e84bb73415c4cbf5fcd903ea4987976e4be3 -- 2.39.2 From 11656d7713b53f30841c5c302d9f1d44f23df439 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Wed, 29 Jan 2014 20:08:16 +0100 Subject: [PATCH 06/16] fixed typo in helpers.lua --- helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.lua b/helpers.lua index 08aba0d..af6443f 100644 --- a/helpers.lua +++ b/helpers.lua @@ -61,7 +61,7 @@ end -- get first non empty line from a file, -- returns nil otherwise function helpers.first_nonempty_line(file) - for k,v in pairs(lines_from(file)) do + for k,v in pairs(helpers.lines_from(file)) do if #v then return v end end return nil -- 2.39.2 From e530ec7fcde3245484a739f077d3f0f907a7d87a Mon Sep 17 00:00:00 2001 From: luke bonham Date: Tue, 4 Feb 2014 08:59:00 +0100 Subject: [PATCH 07/16] bat: little fixes --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 48a14fb..21b5c43 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -59,7 +59,7 @@ local function worker(args) bat_now.status = first_line(bstr .. "/status") or "N/A" - rate = tonumber(rate) + rate = tonumber(rate) or 1 ratev = tonumber(ratev) rem = tonumber(rem) tot = tonumber(tot) -- 2.39.2 From b40a0e83e0a79d587c9390de52c455fca7a8c589 Mon Sep 17 00:00:00 2001 From: Lukas Geis Date: Sun, 2 Feb 2014 14:29:44 +0100 Subject: [PATCH 08/16] Bat.lua: Adding naughty presets for customizable notifications --- widgets/bat.lua | 63 ++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 21b5c43..4526c85 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -32,6 +32,22 @@ local function worker(args) bat.widget = wibox.widget.textbox('') + bat_notification_low_preset = { + title = "Battery low", + text = "Plug the cable!", + timeout = 15, + fg = "#202020", + bg = "#CDCDCD" + } + + bat_notification_critical_preset = { + title = "Battery exhausted", + text = "Shutdown imminent", + timeout = 15, + fg = "#000000", + bg = "#FFFFFF" + } + function update() bat_now = { status = "Not present", @@ -96,39 +112,28 @@ local function worker(args) bat_now.watt = "N/A" end - -- notifications for low and critical states - if bat_now.status == "Discharging" and notify == "on" - then - if tonumber(bat_now.perc) <= 5 - then - bat.id = naughty.notify({ - text = "shutdown imminent", - title = "battery nearly exhausted", - position = "top_right", - timeout = 15, - fg="#000000", - bg="#ffffff", - ontop = true, - replaces_id = bat.id - }).id - elseif tonumber(bat_now.perc) <= 15 - then - bat.id = naughty.notify({ - text = "plug the cable", - title = "battery low", - position = "top_right", - timeout = 15, - fg="#202020", - bg="#cdcdcd", - ontop = true, - replaces_id = bat.id - }).id - end - end end widget = bat.widget settings() + + -- notifications for low and critical states + if bat_now.status == "Discharging" and notify == "on" + then + if tonumber(bat_now.perc) <= 5 + then + bat.id = naughty.notify({ + preset = bat_notification_critical_preset, + replaces_id = bat.id + }).id + elseif tonumber(bat_now.perc) <= 15 + then + bat.id = naughty.notify({ + preset = bat_notification_low_preset, + replaces_id = bat.id + }).id + end + end end newtimer("bat", timeout, update) -- 2.39.2 From 6b91332a38dfd5f8758b170c592faec8b3a544fe Mon Sep 17 00:00:00 2001 From: luke bonham Date: Tue, 4 Feb 2014 09:22:22 +0100 Subject: [PATCH 09/16] calendar: font variable added --- widgets/calendar.lua | 29 +++++++++++++++-------------- wiki | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/widgets/calendar.lua b/widgets/calendar.lua index f684fd7..c9e265a 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -38,9 +38,6 @@ function calendar:show(t_out, inc_offset) local f, c_text local today = tonumber(os.date('%d')) local init_t = '/usr/bin/cal | sed -r -e "s/(^| )( ' - -- let's take font only, font size is set in calendar table - local font = beautiful.font:sub(beautiful.font:find(""), - beautiful.font:find(" ")) if offs == 0 then -- current month showing, today highlighted @@ -86,7 +83,7 @@ function calendar:show(t_out, inc_offset) f = io.popen('/usr/bin/cal ' .. month .. ' ' .. year) end - c_text = "" .. f:read() .. "\n\n" .. f:read() .. "\n" @@ -94,21 +91,25 @@ function calendar:show(t_out, inc_offset) .. "" f:close() - cal_notification = naughty.notify({ text = c_text, - icon = calendar.notify_icon, - position = calendar.position, - fg = calendar.fg, - bg = calendar.bg, - timeout = tims }) + cal_notification = naughty.notify({ + text = c_text, + icon = calendar.notify_icon, + position = calendar.position, + fg = calendar.fg, + bg = calendar.bg, + timeout = tims + }) end function calendar:attach(widget, args) local args = args or {} - calendar.icons = args.icons or icons_dir .. "cal/white/" + calendar.icons = args.icons or icons_dir .. "cal/white/" + calendar.font = args.font or beautiful.font:sub(beautiful.font:find(""), + beautiful.font:find(" ")) calendar.font_size = tonumber(args.font_size) or 11 - calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF" - calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF" - calendar.position = args.position or "top_right" + calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF" + calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF" + calendar.position = args.position or "top_right" calendar.offset = 0 calendar.notify_icon = nil diff --git a/wiki b/wiki index 6825e84..d424887 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 6825e84bb73415c4cbf5fcd903ea4987976e4be3 +Subproject commit d4248875dcd12ceb300c8a876001ce68f5405758 -- 2.39.2 From 96df4b879033f447d494dfc9928d97cc34e5473b Mon Sep 17 00:00:00 2001 From: luke bonham Date: Fri, 7 Feb 2014 12:39:18 +0100 Subject: [PATCH 10/16] #25 fix attempt --- widgets/net.lua | 6 ++---- widgets/yawn/init.lua | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/widgets/net.lua b/widgets/net.lua index d79e117..af97201 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -35,7 +35,7 @@ function net.get_device() if ws ~= nil then return ws:gsub(": UP", "") else - return "" + return "network off" end end @@ -80,10 +80,8 @@ local function worker(args) then if helpers.get_map(iface) then - n_title = iface - if n_title == "" then n_title = "network" end naughty.notify({ - title = n_title, + title = iface, text = "no carrier", timeout = 7, position = "top_left", diff --git a/widgets/yawn/init.lua b/widgets/yawn/init.lua index b4d9c05..af7befc 100644 --- a/widgets/yawn/init.lua +++ b/widgets/yawn/init.lua @@ -58,12 +58,12 @@ local function fetch_weather() yawn.icon:set_image(icon_path .. "na.png") if text == "" then weather_data = "Service not available at the moment." - yawn.widget:set_text(" N/A") + yawn.widget:set_text(" N/A ") else weather_data = "City not found!\n" .. "Are you sure " .. city_id .. " is your Yahoo city ID?" - yawn.widget:set_text(" ?") + yawn.widget:set_text(" ? ") end return end -- 2.39.2 From 940a900b9a74fa2d39b9e05262d74158bd2a0d64 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Sat, 8 Feb 2014 11:44:09 +0100 Subject: [PATCH 11/16] 26# fix attempt --- widgets/bat.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 4526c85..c2a6587 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -97,13 +97,17 @@ local function worker(args) bat_now.time = string.format("%02d:%02d", hrs, min) - local perc = (rem / tot) * 100 - if perc <= 100 then - bat_now.perc = string.format("%d", perc) - elseif perc > 100 then - bat_now.perc = "100" - elseif perc < 0 then - bat_now.perc = "0" + bat_now.perc = first_line(bstr .. "/capacity") + + if not bat_now.perc then + local perc = (rem / tot) * 100 + if perc <= 100 then + bat_now.perc = string.format("%d", perc) + elseif perc > 100 then + bat_now.perc = "100" + elseif perc < 0 then + bat_now.perc = "0" + end end if rate ~= nil and ratev ~= nil then @@ -118,7 +122,7 @@ local function worker(args) settings() -- notifications for low and critical states - if bat_now.status == "Discharging" and notify == "on" + if bat_now.status == "Discharging" and notify == "on" and bat_now.perc ~= nil then if tonumber(bat_now.perc) <= 5 then -- 2.39.2 From 9cd85a25829cc600c05622c1f92a97b257918835 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Sat, 8 Feb 2014 12:10:13 +0100 Subject: [PATCH 12/16] #25 fix attempt 2 --- helpers.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helpers.lua b/helpers.lua index af6443f..f2bd5e4 100644 --- a/helpers.lua +++ b/helpers.lua @@ -35,12 +35,11 @@ end -- see if the file exists function helpers.file_exists(file) - local f = io.open(file, "rb") + local f = io.open(file) if f then f:close() end return f ~= nil end - -- get all lines from a file, returns an empty -- list/table if the file does not exist function helpers.lines_from(file) -- 2.39.2 From 0dfbb462e898605d19d8657505763f6cc3d93d3f Mon Sep 17 00:00:00 2001 From: luke bonham Date: Sun, 9 Feb 2014 10:36:40 +0100 Subject: [PATCH 13/16] #25 blueluke's fix attempt --- helpers.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helpers.lua b/helpers.lua index f2bd5e4..863bb87 100644 --- a/helpers.lua +++ b/helpers.lua @@ -3,7 +3,6 @@ Licensed under GNU General Public License v2 * (c) 2013, Luke Bonham - * (c) 2010-2012, Peter Hofmann --]] @@ -33,10 +32,14 @@ end -- {{{ File operations --- see if the file exists +-- see if the file exists and is readable function helpers.file_exists(file) local f = io.open(file) - if f then f:close() end + if f then + local s = f:read() + f:close() + f = s + end return f ~= nil end -- 2.39.2 From ddeb786a75215efc3bd47b5b7f29a2ac19b06d28 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Sun, 9 Feb 2014 17:44:28 +0100 Subject: [PATCH 14/16] #26 fix attempt 2 --- widgets/bat.lua | 5 +++-- widgets/yawn/init.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index c2a6587..485fd57 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -122,15 +122,16 @@ local function worker(args) settings() -- notifications for low and critical states + bat_now.perc = tonumber(bat_now.perc) if bat_now.status == "Discharging" and notify == "on" and bat_now.perc ~= nil then - if tonumber(bat_now.perc) <= 5 + if bat_now.perc <= 5 then bat.id = naughty.notify({ preset = bat_notification_critical_preset, replaces_id = bat.id }).id - elseif tonumber(bat_now.perc) <= 15 + elseif bat_now.perc <= 15 then bat.id = naughty.notify({ preset = bat_notification_low_preset, diff --git a/widgets/yawn/init.lua b/widgets/yawn/init.lua index af7befc..3f08cd5 100644 --- a/widgets/yawn/init.lua +++ b/widgets/yawn/init.lua @@ -75,7 +75,7 @@ local function fetch_weather() -- may still happens in case of bad connectivity if weather_data == "" then yawn.icon:set_image(icon_path .. "na.png") - yawn.widget:set_text(" ?") + yawn.widget:set_text(" ? ") return end -- 2.39.2 From 5b67a36d52c9d5a8f925ca4d0c02094894198e77 Mon Sep 17 00:00:00 2001 From: aaron-lebo Date: Mon, 10 Feb 2014 03:02:14 -0600 Subject: [PATCH 15/16] Create acw.lua --- widgets/contrib/acw.lua | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 widgets/contrib/acw.lua diff --git a/widgets/contrib/acw.lua b/widgets/contrib/acw.lua new file mode 100644 index 0000000..0c3ae3f --- /dev/null +++ b/widgets/contrib/acw.lua @@ -0,0 +1,69 @@ +-[[ + + Licensed under GNU General Public License v2 + * (c) 2014, Aaron Lebo + +--]] + +local newtimer = require("lain.helpers").newtimer +local wibox = require("wibox") +local json = require("dkjson") + +-- acw (awesome crypto widget) +-- diplays BTC/USD and DOGE/USD using Coinbase and Cryptsy APIs +-- requires http://dkolf.de/src/dkjson-lua.fsl/home +-- based upon http://awesome.naquadah.org/wiki/Bitcoin_Price_Widget +-- lain.widgets.contrib.acw + +acw = {widget=wibox.widget.textbox('')} + +local function get(url) + f = io.popen('curl -m 5 -s "' .. url .. '"') + if (not f) then return 0 end + return f:read("*all") +end + +local function parse(j) + local obj, pos, err = json.decode (j, 1, nil) + if err thenfunction worker(args) + return nil + else + return obj + end +end + +function worker(args) + local args = args or {} + local timeout = args.timeout or 600 + local settings = args.settings or function() end + + + local function update() + btc = parse(get("https://coinbase.com/api/v1/prices/buy")) + if btc then + btc = tonumber(btc["subtotal"]["amount"]) + btc_display = "$" .. btc + else + btc_display = "N/A" + end + doge = parse(get("http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132")) + if doge and btc then + doge = tonumber(doge["return"]["markets"]["DOGE"]["lasttradeprice"]) + doge_display = string.format("$%.4f", btc * doge) + else + doge_display = "N/A" + end + prices = btc_display .. " " .. doge_display + prices_now = {} + prices_now.prices = prices + + widget = acw.widget + settings() + end + + newtimer("acw", timeout, update) + + return acw.widget +end + +return setmetatable(acw, { __call = function(_, ...) return worker(...) end }) -- 2.39.2 From 3e8754c217fa770f86dae53b27bae14663118bae Mon Sep 17 00:00:00 2001 From: aaron-lebo Date: Mon, 10 Feb 2014 03:06:50 -0600 Subject: [PATCH 16/16] Update acw.lua --- widgets/contrib/acw.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/widgets/contrib/acw.lua b/widgets/contrib/acw.lua index 0c3ae3f..c06de57 100644 --- a/widgets/contrib/acw.lua +++ b/widgets/contrib/acw.lua @@ -37,7 +37,6 @@ function worker(args) local timeout = args.timeout or 600 local settings = args.settings or function() end - local function update() btc = parse(get("https://coinbase.com/api/v1/prices/buy")) if btc then -- 2.39.2