~nighthawk/sdorfehs-bar

2edf4983bb4e218dc5f0d3ed6d84ad9b3f5fe528 — Frank Brodbeck a month ago 6296938
use emojis as symbols instead of text for identifying modules

i also changed the power module to show time left instead of power consumption
1 files changed, 27 insertions(+), 21 deletions(-)

M sdorfehs-bar.rb
M sdorfehs-bar.rb => sdorfehs-bar.rb +27 -21
@@ 497,20 497,25 @@ class Controller
      o << "^fg(#{color(:disabled)})"
    end

    o << "vol^fg(#{color(:disabled)})/"
    o << "^fg(#{color(:symbol)})"

    if @i3status_data[:volume]["full_text"].match(/mute/)
      o << "---"
    else
      vol = @i3status_data[:volume]["full_text"].gsub(/[^0-9]/, "").to_i

      if vol >= 75
      if vol >= 80
        o << "^fn(noto emoji:size=13)\u{1F50A}^fn(#{config[:font]})"
        o << "^fg(#{color(:emerg)})"
      elsif vol >= 55
        o << "^fn(noto emoji:size=13)\u{1F509}^fn(#{config[:font]})"
        o << "^fg(#{color(:alert)})"
      else
        o << "^fn(noto emoji:size=13)\u{1F508}^fn(#{config[:font]})"
        o << "^fg()"
      end

      o << "#{vol}^fg(#{color(:disabled)})%"
      o << "#{sprintf("%3i", vol)}^fg(#{color(:disabled)})%"
    end

    o << "^fg()"


@@ 622,6 627,7 @@ class Controller
  def network
    wifi_up = false
    wifi_signal = 0
    wifi_essid = "none"

    if @i3status_data[:ethernet] &&
    @i3status_data[:ethernet]["full_text"].to_s.match(/up/)


@@ 629,7 635,7 @@ class Controller
    end

    if @i3status_data[:wireless] &&
    (m = @i3status_data[:wireless]["full_text"].to_s.match(/^up\|(.+)$/))
    (m = @i3status_data[:wireless]["full_text"].to_s.match(/^up\|(.+)\|(.+)$/))
      wifi_up = true

      if m[1] == "?"


@@ 641,12 647,13 @@ class Controller
        elsif n = m[1].match(/(-?\d+) dBm/)
          wifi_signal = [ 2 * (n[1].to_i + 100), 100 ].min
        end
        wifi_essid = m[2].to_s
      end
    else
      return nil
    end

    wi = ""
    wi = "^fn(noto emoji:size=13)^fg(#{color(:symbol)})\u{1F4F6}^fn(#{config[:font]})"
    if wifi_connected && wifi_signal > 0
      if wifi_signal >= 60
        wi << "^fg()"


@@ 656,11 663,11 @@ class Controller
        wi << "^fg(#{color(:warn)})"
      end

      wi << "wifi^fg()"
      wi << wifi_essid << "^fg()"
    elsif wifi_connected
      wi << "^fg()wifi"
      wi << "^fg()" << wifi_essid
    elsif wifi_up
      wi << "^fg(#{color(:disabled)})wifi^fg()"
      wi << "^fg(#{color(:disabled)})" << wifi_essid << "^fg()"
    end

    wi << "^ca()"


@@ 674,6 681,7 @@ class Controller
    batt_max = batt_left = batt_perc = {}, {}, {}
    ac_on = false
    run_rate = 0.0
    run_time = "0:00"

    @i3status_data[:battery]["full_text"].split("|").each_with_index do |d,x|
      case x


@@ 682,16 690,22 @@ class Controller
      when 1
        batt_perc = { 0 => d.to_i }
      when 2
        run_rate = d.to_f
        run_time = d
      end
    end

    out = "^fg(#{ac_on ? "" : color(:disabled)})ac"
    out = "^fg(#{color(:symbol)})"

    if ac_on
        out << "^fn(noto emoji:size=13)\u{1F50C}^fn(#{config[:font]})"
    else
        out << "^fn(noto emoji:size=13)\u{1F50B}^fn(#{config[:font]})"
    end

    total_perc = batt_perc.values.inject{|a,b| a + b }

    batt_perc.keys.each do |i|
      out << "^fg(#{color(:disabled)})/"
      out << "^fg(#{color(:disabled)})"

      blink = false
      if batt_perc[i] <= 10.0


@@ 713,16 727,8 @@ class Controller
      out << "^fg(#{color(:disabled)})/?^fg()"
    end

    if run_rate > 0.0 && !ac_on
      out << "^fg(#{color(:disabled)})/^fg()"

      if run_rate >= 20.0
        out << "^fg(#{color(:emerg)})"
      elsif run_rate >= 10.0
        out << "^fg(#{color(:alert)})"
      end

      out << "#{sprintf("%0.1f", run_rate)}w^fg()"
    if !ac_on
        out << "/" << run_time
    end

    out