Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7617ae8
Added BBCWeather Block
OkayDave Apr 10, 2016
ac1fb9c
release wip[
OkayDave Sep 15, 2016
9659e19
Merge branch 'feature/bbcweather_controller' into rc/0.3.0
OkayDave Sep 15, 2016
1de1f4e
update version
OkayDave Sep 16, 2016
e265e23
Fix bspwm issues
OkayDave Oct 27, 2016
6ff47ce
Merge pull request #34 from OkayDave/develop
OkayDave Oct 27, 2016
b04eb94
Added format options to CPU block
OkayDave Oct 29, 2016
dd86e8e
Merge pull request #35 from OkayDave/feature/enhance-cpu
OkayDave Oct 28, 2016
cd7c461
Remove redundant method and fix typos
OkayDave Oct 29, 2016
e61da80
Merge pull request #36 from OkayDave/fix/weather-docs
OkayDave Oct 29, 2016
7d9ae1c
Added HTTPGrab block
OkayDave Nov 6, 2016
92ff531
Merge pull request #37 from OkayDave/feature/http-grab
OkayDave Nov 6, 2016
e20ce96
Added HueLight Block
OkayDave Nov 8, 2016
7f836dd
Merge pull request #38 from OkayDave/feature/hue
OkayDave Nov 8, 2016
57e5794
Added HueLight Block
OkayDave Nov 8, 2016
c81a58b
Merge pull request #39 from OkayDave/feature/hue
OkayDave Nov 8, 2016
c7d04bd
Added HueGroup block
OkayDave Nov 11, 2016
8d2001b
Merge pull request #40 from OkayDave/feature/hue-group
OkayDave Nov 11, 2016
601d428
Added playerctl block
OkayDave Jul 26, 2017
005a2d4
Merge pull request #44 from OkayDave/feature/playerctl
OkayDave Mar 3, 2018
88cf5f0
Added Rubocop configuration and corrected code as per recommendations
OkayDave Mar 3, 2018
419427c
Merge pull request #48 from OkayDave/feature/rubocop
OkayDave Mar 3, 2018
fa84cef
Fix/update examples
OkayDave Mar 3, 2018
cf125b0
Fix BBCWeather Block to account for changes on BBC weather site
OkayDave Mar 3, 2018
aa5b964
Merge pull request #49 from OkayDave/fix/bbc_weather
OkayDave Mar 3, 2018
5a0c476
Remove rhythmbox client example
OkayDave Mar 4, 2018
7b92377
Build against multiple ruby versions and force rubocop checks
OkayDave Mar 4, 2018
fae07a1
Merge pull request #50 from OkayDave/fix/examples
OkayDave Mar 4, 2018
8dbc4a9
Merge pull request #51 from OkayDave/feature/travis-improvements
OkayDave Mar 4, 2018
2ca2aca
Tweak CPU block usage percentage
OkayDave Mar 4, 2018
ab14b88
Merge pull request #52 from OkayDave/fix/cpu_block
OkayDave Mar 4, 2018
10738b8
Fix time_and_date.rb date example. Issue #45
OkayDave Mar 4, 2018
007bcc0
Create ISSUE_TEMPLATE.md
OkayDave Mar 4, 2018
e98a2f9
Create PULL_REQUEST_TEMPLATE.md
OkayDave Mar 4, 2018
4af07de
Merge pull request #54 from OkayDave/feature/templates
OkayDave Mar 4, 2018
f3306ca
Merge pull request #53 from OkayDave/fix/examples
OkayDave Mar 4, 2018
9d95a56
Add FreeText Block
OkayDave Mar 4, 2018
4f58c1d
Merge pull request #56 from OkayDave/feature/free-text-block
OkayDave Mar 4, 2018
d9318d1
Fix grep for Mem block
OkayDave Mar 4, 2018
6a9cf94
Merge pull request #57 from OkayDave/fix/mem_block
OkayDave Mar 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
[#]*[#]
.\#*
.swp
barr-*.gem
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Metrics/LineLength:
Enabled: false

Style/Documentation:
Enabled: false

Style/FormatStringToken:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Lint/InterpolationCheck:
Enabled: false

Metrics/BlockLength:
Enabled: false

AllCops:
Exclude:
- spec/**/*
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
language: ruby
rvm:
- 2.2.3
- 2.4.0
- 2.5.0
before_install: gem install bundler -v 1.11.2
script:
- bundle exec rubocop
- bundle exec rspec spec
17 changes: 17 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Expected Behaviour


## Actual Behaviour


## Steps or Code to Reproduce the Problem

1.
1.
1.

## Specifications

- Barr Version:
- Lemonbar Version:
- Linux Distro:
21 changes: 21 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
* **Please check if the PR fulfills these requirements**
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)

* **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)



* **What is the current behavior?** (You can also link to an open issue here)



* **What is the new behavior (if this is a feature change)?**



* **Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?)



* **Other information**:
146 changes: 143 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,29 @@ Show battery status.
| --- | --- | --- | --- |
| `show_remaining` | bool | Show the remaining battery time | `true` |

#### BBCWeather

Shows configurable weather information as provided by the BBC. Recommended over the `Temperature` block due to how much more reliable the BBC service is.

`bbc = Barr::Blocks::BBCWeather.new location: "5308655", format: "${TEMPERATURE} wind: ${WINDSPEED} ${WINDDIRECTION}"`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `format` | string | Configurable format for showing which weather information is displayed. See table below for options. | `"${TEMPERATURE} - ${SUMMARY}"` |
| `location` | string | Find your location on the [BBC Weather](http://www.bbc.co.uk/weather) service and use the last part of the URL as the location string. For example, Phoenix Arizona is "5308655". | **REQUIRED** |
| `speed_unit` | "mph" or "kph" | Whether to show speeds in mph or kph | `"mph"`
| `temp_unit` | "c" or "f" | Whether to show temperatures in C or F | `"c"`

| Option | Description |
| --- | --- |
| `${TEMPERATURE}` | Current temperature |
| `${SUMMARY}` | Brief summary of weather, e.g. "Light cloud" |
| `${WINDSPEED}` | Current wind speed |
| `${WINDDIRECTION}` | Current wind direction |
| `${HUMIDITY}` | Current humidity percentage |
| `${VISIBILITY}` | Summary of visbility, e.g. "Excellent" |
| `${PRESSURE}` | Current pressure and trend, e.g. "1000mb, Falling" |

#### Bspwm (Experimental)

**Requires Bspwm**. Shows desktops for selected monitor. and highlights focused one. Unfocused desktops are clickable. Could do with some optimization work and feedback from people that use BSP frequently, especially with multiple monitors.
Expand Down Expand Up @@ -195,11 +218,29 @@ Shows the current date and/or time.

#### CPU

Shows CPU load averaged across all cores.
**Requires mpstat from [sysstat](https://github.com/sysstat/sysstat)**. Shows CPU load averaged across all cores.

`cpu = Barr::Blocks::CPU.new`

There are no `CPU` block specific configurable options.
| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `format` | string | Configurable format for showing which weather information is displayed. See table below for options. | `"${LOAD}"` |

| Option | Description |
| --- | --- |
| `${LOAD}` | Current load in % |
| `${TEMP}` | Current temperature |

#### Free Text

Displays a string of text. Useful for creating a set of clickable areas or creating space.

`free = Barr::Blocks::FreeText.new text: 'Hello'`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `text` | string | The text to display in the block. Supports Lemonbar syntax | `''` |


#### HDD

Expand All @@ -211,6 +252,87 @@ Shows selected filesystem's used and free space.
| --- | --- | --- | --- |
| `device` | String | This is the name of the device for which you'd like to see free/used space. Something like `/dev/sda2`. Run `df -h` in your terminal and look at the first column. | **REQUIRED** |

#### HTTPGrab

Grabs a piece of text from a URL based on a css or xpath selector. Optionally opens the link in a browser when clicked. Makes a reasonable effort at supporting pages controlled by javascript.

`http = Barr::Blocks::HTTPGrab.new url: "http://www.bbc.co.uk/news", selector: "span.most-popular-list-item__headline"`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `link` | Bool | Set to `true` or `false` to set whether or not the block should open the given URL in a browser when clicked. | `false` |
| `selector` | String | The CSS or XPath selector for the DOM node of the text you'd like grabbed | **REQUIRED** |
| `type` | Symbol | Set to `:css` or `:xpath` to set which type of selector you have provided | `:css` |
| `url` | String | URL that you'd like to grab from | **REQUIRED** |

#### HueGroup

**Requires [Hue](https://github.com/soffes/hue) gem to be installed and configured prior to use** Allows you to set buttons for controlling a designated Philips Hue Light group. This sends all options to all lights on the group.

`group = Barr::Blocks::HueGroup.new id: '3', format: "${ON:T-Turn On} ${ON:B-100,T-Dim}", ${OFF}'`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `id` | `hue` group ID | You can list all of your lights and their IDs by running `hue groups`. The ID is the first column, e.g. `1`. | **REQUIRED** |
| `format` | string | Configurable format for choosing the buttons and their behaviours. See table below for options | `"${OFF} ${ON}"`|

| Option | Description |
| `${OFF}` | Adds a button to turn the selected light off. Can be configured with custom text |
| `${ON}` | Adss a button to turn the selected light on. Several buttons can be added with individual behaviours |

Both the `${OFF}` and `${ON}` buttons allow additional button specific behaviours to be configured. The supported options are:

| Option | Description |
| `B` | Brightness. Value between `0` and `255`. |
| `H` | Hue. Value between `0` and `65535`. |
| `A` | Alert. Value of either `select` (for a single flash) or `lselect` (for 30s of flashing) |
| `T` | Button Text. Any character string that will be shown as the button's text. |

These can be applied to the Block's `format` string options by appending them with a colon and passing the option with a hyphen:

`${ON:B-25}` - Sets the light's brightness to 25 (out of 255).

You can add multiple options to a single button by separating the options with a comma:

`${ON:B-255,T-Bright}` - creates a button that looks like `[Bright]` which sets the light to maximum brightness.

See the [hue.rb](https://github.com/OkayDave/barr/blob/develop/examples/hue.rb) file for more examples.

#### HueLight

**Requires [Hue](https://github.com/soffes/hue) gem to be installed and configured prior to use** Allows you to set buttons for controlling a single Philips Hue Light.

`light = Barr::Blocks::HueLight.new id: '3', format: "${ON:T-Turn On} ${ON:B-100,T-Dim}", ${OFF}'`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `id` | `hue` light ID | You can list all of your lights and their IDs by running `hue lights`. The ID is the first column, e.g. `1`. | **REQUIRED** |
| `format` | string | Configurable format for choosing the buttons and their behaviours. See table below for options | `"${OFF} ${ON}"`|

| Option | Description |
| --- | --- |
| `${OFF}` | Adds a button to turn the selected light off. Can be configured with custom text |
| `${ON}` | Adds a button to turn the selected light on. Several buttons can be added with individual behaviours |

Both the `${OFF}` and `${ON}` buttons allow additional button specific behaviours to be configured. The supported options are:

| Option | Description |
| --- | --- |
| `B` | Brightness. Value between `0` and `255`. |
| `H` | Hue. Value between `0` and `65535`. |
| `A` | Alert. Value of either `select` (for a single flash) or `lselect` (for 30s of flashing) |
| `T` | Button Text. Any character string that will be shown as the button's text. |

These can be applied to the Block's `format` string options by appending them with a colon and passing the option with a hyphen:

`${ON:B-25}` - Sets the light's brightness to 25 (out of 255).

You can add multiple options to a single button by separating the options with a comma:

`${ON:B-255,T-Bright}` - creates a button that looks like `[Bright]` which sets the light to maximum brightness.

See the [hue.rb](https://github.com/OkayDave/barr/blob/develop/examples/hue.rb) file for more examples.

#### I3

**Requires i3wm**. Shows the current workspaces and highlights the active one. You can click a workspace name to change to there.
Expand Down Expand Up @@ -241,6 +363,24 @@ Shows current RAM usage.

There are no `Mem` block specific configurable options.

#### Playerctl

**Requires [Playerctl](https://github.com/acrisci/playerctl)**. Shows configurable information about currently playing track on a variety of players. Option to include control buttons.

`pctl = Barr::Blocks::Playerctl.new player: "spotify", format: "${ARTIST} - ${TITLE} - ${BUTTONS}`

| Option | Value | Description | Default |
| --- | --- | --- | --- |
| `format` | string | Configurable format for defining how the information is displayed. See table below for options | `"${ARTIST} - ${TRACK}"` |
| `player` | string | ID of the media app you want to control. Run `playerctl -l` to see what is available | '' |

| Format Option | Description |
| --- | --- |
| `${ARTIST}` | Artist of currently playing track |
| `${ALBUM}` | Album of currently playing track |
| `${TITLE}` | Title of currently playing track |
| `${BUTTONS}` | Buttons to control playback |

#### Processes

Shows the number of currently active processes on your system.
Expand All @@ -250,7 +390,7 @@ Shows the number of currently active processes on your system.
There are no `Processes` block specific configurable options.

#### Rhythmbox

**DEPRECATED** It's reccommended to use the `Playerctl` block instead of this. It's compatible with Rhythmbox and many other players, including Spotify.
**Requires Rhythmbox and rhythmbox-client**. Shows currently playing artist and/or track, as well as control buttons. Control buttons use FontAwesome.

`rb = Barr::Blocks::Rhythmbox.new buttons: false`
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec
58 changes: 33 additions & 25 deletions barr.gemspec
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
# coding: utf-8

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'barr/version'

Gem::Specification.new do |spec|
spec.name = "barr"
spec.name = 'barr'
spec.version = Barr::VERSION
spec.authors = ["Dave Russell"]
spec.email = ["dave.kerr@gmail.com"]
spec.authors = ['Dave Russell']
spec.email = ['dave.kerr@gmail.com']

spec.summary = "Barr is a status line generator for use with Lemonbar"
spec.homepage = "https://github.com/OkayDave/barr"
spec.license = "MIT"
spec.summary = 'Barr is a status line generator for use with Lemonbar'
spec.homepage = 'https://github.com/OkayDave/barr'
spec.license = 'MIT'

# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
if spec.respond_to?(:metadata)
if spec.respond_to?(:metadata) # rubocop:disable Style/GuardClause
else
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
end

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.11"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "timecop", "~> 0.8.0"

spec.add_runtime_dependency "i3ipc", "0.2.0"
spec.add_runtime_dependency "weather-api", "1.2.0"

spec.requirements << "Lemonbar with XFT support (https://github.com/krypt-n/bar)"
spec.requirements << "(Optional) I3 for Workspace support"
spec.requirements << "(Optional) RhythmBox & rhythmbox-client"
spec.requirements << "(Optional) FontAwesome font"
spec.bindir = 'exe'
spec.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'pry-byebug', '~> 3.4'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.52.1'
spec.add_development_dependency 'timecop', '~> 0.8.0'

spec.add_runtime_dependency 'hue', '~> 0.2'
spec.add_runtime_dependency 'i3ipc', '0.2.0'
spec.add_runtime_dependency 'nokogiri', '~> 1.6'
spec.add_runtime_dependency 'poltergeist', '~> 1.11'
spec.add_runtime_dependency 'weather-api', '1.2.0'

spec.requirements << 'Lemonbar with XFT support (https://github.com/krypt-n/bar)'
spec.requirements << '(Optional) I3 for Workspace support'
spec.requirements << '(Optional) Bspwm for Bspwm desktop support'
spec.requirements << '(Optional) RhythmBox & rhythmbox-client'
spec.requirements << '(Optional) FontAwesome font'
spec.requirements << '(Optional) playerctl'
spec.requirements << '(Optional) mpstat from sysstat'
end
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "barr"
require 'bundler/setup'
require 'barr'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -10,5 +10,5 @@ require "barr"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start
Empty file modified bin/setup
100755 → 100644
Empty file.
4 changes: 0 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@

![i3_cpu_mem.rb](http://i.imgur.com/J3qNpw5.png)

## rhythm.rb

![rhythm.rb](http://i.imgur.com/1P05aih.png)

## time_and_date.rb

![time_and_date.rb](http://i.imgur.com/Lg81tSG.png)
Expand Down
Loading