diff --git a/README.md b/README.md index e974eb0..30a18d6 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,17 @@ Shows the current date and/or time. | `${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 Shows selected filesystem's used and free space. diff --git a/examples/time_and_date.rb b/examples/time_and_date.rb index 4e4758e..a0de1c0 100755 --- a/examples/time_and_date.rb +++ b/examples/time_and_date.rb @@ -6,7 +6,7 @@ @man = Barr::Manager.new time = Barr::Blocks::Clock.new format: '%H:%M', icon: "\uf017", bgcolor: '#114152', fgcolor: '#DAC1DE', align: :l -date = Barr::Blocks::Clock.new format: '%m of %b %Y', bgcolor: '#570B7A', fgcolor: '#FFFFFF', align: :r, icon: "\uf073" +date = Barr::Blocks::Clock.new format: '%d of %b %Y', bgcolor: '#570B7A', fgcolor: '#FFFFFF', align: :r, icon: "\uf073" @man.add time @man.add date diff --git a/lib/barr.rb b/lib/barr.rb index 57342e3..0ad1f1e 100644 --- a/lib/barr.rb +++ b/lib/barr.rb @@ -9,6 +9,7 @@ require 'barr/blocks/clock' require 'barr/blocks/conky' require 'barr/blocks/cpu' +require 'barr/blocks/free_text' require 'barr/blocks/hdd' require 'barr/blocks/http_grab' require 'barr/blocks/hue_light' diff --git a/lib/barr/blocks/free_text.rb b/lib/barr/blocks/free_text.rb new file mode 100644 index 0000000..8422910 --- /dev/null +++ b/lib/barr/blocks/free_text.rb @@ -0,0 +1,18 @@ +require 'barr/block' + +module Barr + module Blocks + class FreeText < Block + attr_accessor :text + + def initialize(opts = {}) + super + @text = opts[:text] || '' + end + + def update! + @output = @text + end + end + end +end diff --git a/spec/blocks/free_text_spec.rb b/spec/blocks/free_text_spec.rb new file mode 100644 index 0000000..588bab5 --- /dev/null +++ b/spec/blocks/free_text_spec.rb @@ -0,0 +1,14 @@ + +require 'barr/blocks/free_text' + +RSpec.describe Barr::Blocks::FreeText do + describe '#update!' do + + it 'sets the text correctly' do + subject.text = 'Text Test' + subject.update! + expect(subject.output).to eq 'Text Test' + end + + end +end