From 07c103188703d205d4c0c8f94b5079278d248e80 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 26 May 2018 20:45:51 -0700
Subject: [PATCH 1/2] [WTF-55] Closes #55. Add documentation for the Power
module.
---
_sample_configs/complex_config.yml | 8 +
_site/content/posts/modules.md | 18 +-
_site/content/posts/modules/bamboohr.md | 2 +-
_site/content/posts/modules/power.md | 49 ++++++
_site/content/posts/modules/security.md | 2 +-
.../hyde-hyde/layouts/partials/sidebar.html | 1 +
docs/404.html | 1 +
docs/categories/index.html | 1 +
docs/index.html | 1 +
docs/index.xml | 18 +-
.../posts/configuration/attributes/index.html | 1 +
docs/posts/configuration/index.html | 1 +
docs/posts/configuration/iterm2/index.html | 1 +
docs/posts/glossary/index.html | 1 +
docs/posts/index.html | 8 +
docs/posts/index.xml | 18 +-
docs/posts/installation/index.html | 1 +
docs/posts/modules/bamboohr/index.html | 3 +-
docs/posts/modules/clocks/index.html | 1 +
docs/posts/modules/cmdrunner/index.html | 1 +
docs/posts/modules/gcal/index.html | 1 +
docs/posts/modules/git/index.html | 1 +
docs/posts/modules/github/index.html | 1 +
docs/posts/modules/index.html | 19 +--
docs/posts/modules/jira/index.html | 1 +
docs/posts/modules/newrelic/index.html | 1 +
docs/posts/modules/opsgenie/index.html | 1 +
docs/posts/modules/power/index.html | 160 ++++++++++++++++++
docs/posts/modules/security/index.html | 3 +-
docs/posts/modules/textfile/index.html | 1 +
docs/posts/modules/todo/index.html | 1 +
docs/posts/modules/weather/index.html | 1 +
docs/posts/overview/index.html | 1 +
docs/sitemap.xml | 9 +-
docs/tags/index.html | 1 +
35 files changed, 295 insertions(+), 44 deletions(-)
create mode 100644 _site/content/posts/modules/power.md
create mode 100644 docs/posts/modules/power/index.html
diff --git a/_sample_configs/complex_config.yml b/_sample_configs/complex_config.yml
index df5488ad..b65d2709 100644
--- a/_sample_configs/complex_config.yml
+++ b/_sample_configs/complex_config.yml
@@ -130,6 +130,14 @@ wtf:
height: 2
width: 1
refreshInterval: 21600
+ power:
+ enabled: true
+ position:
+ top: 5
+ left: 0
+ height: 2
+ width: 1
+ refreshInterval: 15
security:
enabled: true
position:
diff --git a/_site/content/posts/modules.md b/_site/content/posts/modules.md
index c9044b04..6dc676b3 100644
--- a/_site/content/posts/modules.md
+++ b/_site/content/posts/modules.md
@@ -17,20 +17,4 @@ The Clocks module takes a list of
timezones and packages that information as a list of city/time pairs for
display in the "Clocks" widget.
-Available modules:
-
-
+See available modules at left.
diff --git a/_site/content/posts/modules/bamboohr.md b/_site/content/posts/modules/bamboohr.md
index fbeded40..6186e6f9 100644
--- a/_site/content/posts/modules/bamboohr.md
+++ b/_site/content/posts/modules/bamboohr.md
@@ -9,7 +9,7 @@ Connects to the BambooHR API and displays who will be Away today.
## Source Code
```bash
-wtf/bamboohr
+wtf/bamboohr/
```
## Required ENV Variables
diff --git a/_site/content/posts/modules/power.md b/_site/content/posts/modules/power.md
new file mode 100644
index 00000000..0bc0c8a1
--- /dev/null
+++ b/_site/content/posts/modules/power.md
@@ -0,0 +1,49 @@
+---
+title: "Modules: Power"
+date: 2018-05-26T19:26:23-07:00
+draft: false
+---
+
+Displays information about the current power source.
+
+For battery, also displays the current charge, estimated time remaining,
+and whether it is charging or discharging.
+
+## Source Code
+```bash
+wtf/power/
+```
+
+## Required ENV Variables
+
+None.
+
+## Keyboard Commands
+
+None.
+
+## Configuration
+
+```yaml
+power:
+ enabled: true
+ position:
+ top: 5
+ left: 0
+ height: 2
+ width: 1
+ refreshInterval: 15
+```
+
+### Attributes
+
+`enabled`
+Determines whether or not this module is executed and if its data displayed onscreen.
+Values: `true`, `false`.
+
+`position`
+Defines where in the grid this module's widget will be displayed.
+
+`refreshInterval`
+How often, in seconds, this module will update its data.
+Values: A positive integer, `0..n`.
diff --git a/_site/content/posts/modules/security.md b/_site/content/posts/modules/security.md
index 5da13a1f..2f4a308e 100644
--- a/_site/content/posts/modules/security.md
+++ b/_site/content/posts/modules/security.md
@@ -39,7 +39,7 @@ show hidden users.
## Source Code
```bash
-wtf/security
+wtf/security/
```
## Required ENV Variables
diff --git a/_site/themes/hyde-hyde/layouts/partials/sidebar.html b/_site/themes/hyde-hyde/layouts/partials/sidebar.html
index 5e4e1238..7922fbc7 100644
--- a/_site/themes/hyde-hyde/layouts/partials/sidebar.html
+++ b/_site/themes/hyde-hyde/layouts/partials/sidebar.html
@@ -31,6 +31,7 @@
+
diff --git a/docs/404.html b/docs/404.html
index ec25c8b4..bb25606d 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/categories/index.html b/docs/categories/index.html
index aaa8254a..9be522a6 100644
--- a/docs/categories/index.html
+++ b/docs/categories/index.html
@@ -74,6 +74,7 @@
+
diff --git a/docs/index.html b/docs/index.html
index 2f3f091a..58b92d4b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -73,6 +73,7 @@
+
diff --git a/docs/index.xml b/docs/index.xml
index ec5a9dbd..e09ddffd 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -6,11 +6,25 @@
Recent content on WTF
Hugo -- gohugo.io
en-us
- Thu, 24 May 2018 09:57:40 -0700
+ Sat, 26 May 2018 19:26:23 -0700
+ -
+
Modules: Power
+ http://wtfutil.com/posts/modules/power/
+ Sat, 26 May 2018 19:26:23 -0700
+
+ http://wtfutil.com/posts/modules/power/
+ Displays information about the current power source.
+For battery, also displays the current charge, estimated time remaining, and whether it is charging or discharging.
+Source Code wtf/power/ Required ENV Variables None.
+Keyboard Commands None.
+Configuration power:enabled:trueposition:top:5left:0height:2width:1refreshInterval:15 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
+position Defines where in the grid this module’s widget will be displayed. refreshInterval How often, in seconds, this module will update its data.
+
+
-
Configuration: iTerm2
http://wtfutil.com/posts/configuration/iterm2/
@@ -218,7 +232,7 @@ Wifi Network The name of the current network Whether or not the network uses enc
http://wtfutil.com/posts/modules/bamboohr/
Connects to the BambooHR API and displays who will be Away today.
-Source Code wtf/bamboohr Required ENV Variables Key: WTF_BAMBOO_HR_TOKEN Value: Your BambooHR API token.
+Source Code wtf/bamboohr/ Required ENV Variables Key: WTF_BAMBOO_HR_TOKEN Value: Your BambooHR API token.
Key: WTF_BAMBOO_HR_SUBDOMAIN Value: Your BambooHR API subdomain name.
Keyboard Commands None.
Configuration bamboohr:enabled:trueposition:top:0left:1height:2width:1refreshInterval:900 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html
index b5accfde..e2981f1c 100644
--- a/docs/posts/configuration/attributes/index.html
+++ b/docs/posts/configuration/attributes/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/configuration/index.html b/docs/posts/configuration/index.html
index a3e4e16d..870c74d7 100644
--- a/docs/posts/configuration/index.html
+++ b/docs/posts/configuration/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/configuration/iterm2/index.html b/docs/posts/configuration/iterm2/index.html
index e310e3fb..f66bf39e 100644
--- a/docs/posts/configuration/iterm2/index.html
+++ b/docs/posts/configuration/iterm2/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/glossary/index.html b/docs/posts/glossary/index.html
index 8cad05b6..35da0dc1 100644
--- a/docs/posts/glossary/index.html
+++ b/docs/posts/glossary/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/index.html b/docs/posts/index.html
index 352e32de..ec8a4980 100644
--- a/docs/posts/index.html
+++ b/docs/posts/index.html
@@ -74,6 +74,7 @@
+
@@ -94,6 +95,13 @@
Posts
+
+ Modules: Power
+
+ May 26, 2018
+
+
+
Configuration: iTerm2
diff --git a/docs/posts/index.xml b/docs/posts/index.xml
index a29f1fb1..787ae72c 100644
--- a/docs/posts/index.xml
+++ b/docs/posts/index.xml
@@ -6,11 +6,25 @@
Recent content in Posts on WTF
Hugo -- gohugo.io
en-us
- Thu, 24 May 2018 09:57:40 -0700
+ Sat, 26 May 2018 19:26:23 -0700
+ -
+
Modules: Power
+ http://wtfutil.com/posts/modules/power/
+ Sat, 26 May 2018 19:26:23 -0700
+
+ http://wtfutil.com/posts/modules/power/
+ Displays information about the current power source.
+For battery, also displays the current charge, estimated time remaining, and whether it is charging or discharging.
+Source Code wtf/power/ Required ENV Variables None.
+Keyboard Commands None.
+Configuration power:enabled:trueposition:top:5left:0height:2width:1refreshInterval:15 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
+position Defines where in the grid this module’s widget will be displayed. refreshInterval How often, in seconds, this module will update its data.
+
+
-
Configuration: iTerm2
http://wtfutil.com/posts/configuration/iterm2/
@@ -218,7 +232,7 @@ Wifi Network The name of the current network Whether or not the network uses enc
http://wtfutil.com/posts/modules/bamboohr/
Connects to the BambooHR API and displays who will be Away today.
-Source Code wtf/bamboohr Required ENV Variables Key: WTF_BAMBOO_HR_TOKEN Value: Your BambooHR API token.
+Source Code wtf/bamboohr/ Required ENV Variables Key: WTF_BAMBOO_HR_TOKEN Value: Your BambooHR API token.
Key: WTF_BAMBOO_HR_SUBDOMAIN Value: Your BambooHR API subdomain name.
Keyboard Commands None.
Configuration bamboohr:enabled:trueposition:top:0left:1height:2width:1refreshInterval:900 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
diff --git a/docs/posts/installation/index.html b/docs/posts/installation/index.html
index 78d91b74..7f058ad7 100644
--- a/docs/posts/installation/index.html
+++ b/docs/posts/installation/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/bamboohr/index.html b/docs/posts/modules/bamboohr/index.html
index 237e962a..7f18c6f6 100644
--- a/docs/posts/modules/bamboohr/index.html
+++ b/docs/posts/modules/bamboohr/index.html
@@ -72,6 +72,7 @@
+
@@ -111,7 +112,7 @@
Connects to the BambooHR API and displays who will be Away today.
Source Code
-
+
Required ENV Variables
Key: WTF_BAMBOO_HR_TOKEN
diff --git a/docs/posts/modules/clocks/index.html b/docs/posts/modules/clocks/index.html
index 66c1df91..cf21c1f4 100644
--- a/docs/posts/modules/clocks/index.html
+++ b/docs/posts/modules/clocks/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/cmdrunner/index.html b/docs/posts/modules/cmdrunner/index.html
index c90fef88..f704d160 100644
--- a/docs/posts/modules/cmdrunner/index.html
+++ b/docs/posts/modules/cmdrunner/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/gcal/index.html b/docs/posts/modules/gcal/index.html
index bc4447eb..eb2b6e11 100644
--- a/docs/posts/modules/gcal/index.html
+++ b/docs/posts/modules/gcal/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/git/index.html b/docs/posts/modules/git/index.html
index 04d993a0..4e332d14 100644
--- a/docs/posts/modules/git/index.html
+++ b/docs/posts/modules/git/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/github/index.html b/docs/posts/modules/github/index.html
index 9befa933..c767e0ea 100644
--- a/docs/posts/modules/github/index.html
+++ b/docs/posts/modules/github/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/index.html b/docs/posts/modules/index.html
index 03ba5802..fe780649 100644
--- a/docs/posts/modules/index.html
+++ b/docs/posts/modules/index.html
@@ -72,6 +72,7 @@
+
@@ -119,23 +120,7 @@ widget.
timezones and packages that information as a list of city/time pairs for
display in the “Clocks” widget.
-Available modules:
-
-
+See available modules at left.
diff --git a/docs/posts/modules/jira/index.html b/docs/posts/modules/jira/index.html
index abcfb637..146e10c3 100644
--- a/docs/posts/modules/jira/index.html
+++ b/docs/posts/modules/jira/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/newrelic/index.html b/docs/posts/modules/newrelic/index.html
index 4b0ea8b5..8b1ee8ff 100644
--- a/docs/posts/modules/newrelic/index.html
+++ b/docs/posts/modules/newrelic/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/opsgenie/index.html b/docs/posts/modules/opsgenie/index.html
index 378c0fea..789ccbda 100644
--- a/docs/posts/modules/opsgenie/index.html
+++ b/docs/posts/modules/opsgenie/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/power/index.html b/docs/posts/modules/power/index.html
new file mode 100644
index 00000000..e86d8af7
--- /dev/null
+++ b/docs/posts/modules/power/index.html
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+
+
+
+
+
+
+Modules: Power | WTF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Modules: Power
+
+
+
+
+
+ May 26, 2018
+
+
+
+
+
+
+
+
+
+
+
+
Displays information about the current power source.
+
+
For battery, also displays the current charge, estimated time remaining,
+and whether it is charging or discharging.
+
+
Source Code
+
+
Required ENV Variables
+
+
None.
+
+
Keyboard Commands
+
+
None.
+
+
Configuration
+
power:
+ enabled: true
+ position:
+ top: 5
+ left: 0
+ height: 2
+ width: 1
+ refreshInterval: 15
+
Attributes
+
+
enabled
+Determines whether or not this module is executed and if its data displayed onscreen.
+Values: true
, false
.
+
+
position
+Defines where in the grid this module’s widget will be displayed.
+
+
refreshInterval
+How often, in seconds, this module will update its data.
+Values: A positive integer, 0..n
.
+
+
+
+
+
+
+
+
+
diff --git a/docs/posts/modules/security/index.html b/docs/posts/modules/security/index.html
index 0205919d..eee4f596 100644
--- a/docs/posts/modules/security/index.html
+++ b/docs/posts/modules/security/index.html
@@ -72,6 +72,7 @@
+
@@ -141,7 +142,7 @@ show hidden users.
Source Code
-
+
Required ENV Variables
None.
diff --git a/docs/posts/modules/textfile/index.html b/docs/posts/modules/textfile/index.html
index dbabc171..6a515ef5 100644
--- a/docs/posts/modules/textfile/index.html
+++ b/docs/posts/modules/textfile/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/todo/index.html b/docs/posts/modules/todo/index.html
index 048cd03a..d3265424 100644
--- a/docs/posts/modules/todo/index.html
+++ b/docs/posts/modules/todo/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/modules/weather/index.html b/docs/posts/modules/weather/index.html
index 34a2f4fd..fe7142ff 100644
--- a/docs/posts/modules/weather/index.html
+++ b/docs/posts/modules/weather/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/posts/overview/index.html b/docs/posts/overview/index.html
index e70a8ddc..019ad667 100644
--- a/docs/posts/overview/index.html
+++ b/docs/posts/overview/index.html
@@ -72,6 +72,7 @@
+
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index 698d0266..b95a8fb2 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -2,6 +2,11 @@
+
+ http://wtfutil.com/posts/modules/power/
+ 2018-05-26T19:26:23-07:00
+
+
http://wtfutil.com/posts/configuration/iterm2/
2018-05-24T09:57:40-07:00
@@ -109,7 +114,7 @@
http://wtfutil.com/posts/
- 2018-05-24T09:57:40-07:00
+ 2018-05-26T19:26:23-07:00
0
@@ -120,7 +125,7 @@
http://wtfutil.com/
- 2018-05-24T09:57:40-07:00
+ 2018-05-26T19:26:23-07:00
0
diff --git a/docs/tags/index.html b/docs/tags/index.html
index 6d799d63..e6c85df8 100644
--- a/docs/tags/index.html
+++ b/docs/tags/index.html
@@ -74,6 +74,7 @@
+
From dcfacd9510cca4ed92c170b35f7e4b3fc28aa8b8 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 26 May 2018 21:18:06 -0700
Subject: [PATCH 2/2] [WTF-53] Closes #53. Todo display properly pads line
lengths.
[WTF-53]
---
todo/display.go | 17 ++++++++++++++++-
wtf/utils.go | 6 ++----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/todo/display.go b/todo/display.go
index 48de99e3..5d784af5 100644
--- a/todo/display.go
+++ b/todo/display.go
@@ -11,6 +11,8 @@ const checkWidth = 4
func (widget *Widget) display() {
widget.View.Clear()
+ maxLen := widget.longestLineLen(widget.list.Items)
+
str := ""
for idx, item := range widget.list.Items {
foreColor, backColor := "white", "black"
@@ -32,8 +34,21 @@ func (widget *Widget) display() {
item.Text,
)
- str = str + wtf.PadRow((4+len(item.Text)), widget.View) + "\n"
+ str = str + wtf.PadRow((4+len(item.Text)), (4+maxLen)) + "\n"
}
fmt.Fprintf(widget.View, "%s", str)
}
+
+// longestLineLen returns the length of the longest todo item line
+func (widget *Widget) longestLineLen(items []*Item) int {
+ maxLen := 0
+
+ for _, item := range items {
+ if len(item.Text) > maxLen {
+ maxLen = len(item.Text)
+ }
+ }
+
+ return maxLen
+}
diff --git a/wtf/utils.go b/wtf/utils.go
index d05f1404..78ec3284 100644
--- a/wtf/utils.go
+++ b/wtf/utils.go
@@ -83,10 +83,8 @@ func OpenFile(path string) {
// PadRow returns a padding for a row to make it the full width of the containing widget.
// Useful for ensurig row highlighting spans the full width (I suspect tcell has a better
// way to do this, but I haven't yet found it)
-func PadRow(offset int, view *tview.TextView) string {
- _, _, w, _ := view.GetInnerRect()
-
- padSize := w - offset
+func PadRow(offset int, max int) string {
+ padSize := max - offset
if padSize < 0 {
padSize = 0
}