Karabiner-elements: Status message

Created on 5 Aug 2018  路  5Comments  路  Source: pqrs-org/Karabiner-Elements

I stayed on El Capitan as long as I could to not loose Karabiner functionality. After updating to High Sierra/Karabiner-Elements I now miss the status messages very much (I mainly used them to color the menu bar red, whenever vim_emu was activated, which has become essential to me). Are there any plans to re-introduce this feature?

stale

Most helpful comment

@calvinwyoung No, actually I now use a Hammerspoon to display a bar on top of the menu bar, just like the original Karabiner used to do!

In my .hammerspoon/init.lua file I used adapted code from the spoon MenubarFlag:

--- display colored bar on menubar

local prevlayout = nil
local ind = nil

-- Initialize the empty indicator table
local draw = require "hs.drawing"
local col = draw.color.x11
local ind = nil

function initIndicator()
   if ind ~= nil then
      deleteIndicator()
   end
   ind = {}
end

function deleteIndicator()
   if ind ~= nil then
      for i,v in ipairs(ind) do
         if v ~= nil then
            v:delete()
         end
      end
      ind = nil
   end
end

function drawIndicator(mode_color)
    initIndicator()

    if mode_color == 'normal' then ind_color = col.green
    elseif mode_color == 'visual' then ind_color = col.orange
    elseif mode_color == 'command' then ind_color = col.red
    end

    screens = hs.screen.allScreens() -- color all screens
    for i,screen in ipairs(screens) do
        local screeng = screen:fullFrame()
        local width = screeng.w
        local height = screen:frame().y - screeng.y
        c = draw.rectangle(hs.geometry.rect(screeng.x+(width*(i-1)), screeng.y,
                                            width, height))
        c:setFillColor(ind_color)
        c:setFill(true)
        c:setAlpha(0.4)
        c:setLevel(draw.windowLevels.overlay)
        c:setStroke(false)
        c:setBehavior(draw.windowBehaviors.canJoinAllSpaces)
        c:show()
        table.insert(ind, c)
    end
end

--- allow Applescript access to Hammerspoon
hs.allowAppleScript(true)

Then AppleScript can be used to execute code like

tell application "Hammerspoon" to execute lua code "drawIndicator('command')"

All 5 comments

For anyone interested: As an interim solution, I now use BitBar and KE's "shell_command" to display the mode in the menu bar. Not perfect in all situations (e.g., when apps are in full screen mode), but good enough for the moment. Still hoping that Karabiner's original functionality will be implemented again!

@januz I'm running into this problem right now. Is BitBar still the best solution you've found for this?

@calvinwyoung No, actually I now use a Hammerspoon to display a bar on top of the menu bar, just like the original Karabiner used to do!

In my .hammerspoon/init.lua file I used adapted code from the spoon MenubarFlag:

--- display colored bar on menubar

local prevlayout = nil
local ind = nil

-- Initialize the empty indicator table
local draw = require "hs.drawing"
local col = draw.color.x11
local ind = nil

function initIndicator()
   if ind ~= nil then
      deleteIndicator()
   end
   ind = {}
end

function deleteIndicator()
   if ind ~= nil then
      for i,v in ipairs(ind) do
         if v ~= nil then
            v:delete()
         end
      end
      ind = nil
   end
end

function drawIndicator(mode_color)
    initIndicator()

    if mode_color == 'normal' then ind_color = col.green
    elseif mode_color == 'visual' then ind_color = col.orange
    elseif mode_color == 'command' then ind_color = col.red
    end

    screens = hs.screen.allScreens() -- color all screens
    for i,screen in ipairs(screens) do
        local screeng = screen:fullFrame()
        local width = screeng.w
        local height = screen:frame().y - screeng.y
        c = draw.rectangle(hs.geometry.rect(screeng.x+(width*(i-1)), screeng.y,
                                            width, height))
        c:setFillColor(ind_color)
        c:setFill(true)
        c:setAlpha(0.4)
        c:setLevel(draw.windowLevels.overlay)
        c:setStroke(false)
        c:setBehavior(draw.windowBehaviors.canJoinAllSpaces)
        c:show()
        table.insert(ind, c)
    end
end

--- allow Applescript access to Hammerspoon
hs.allowAppleScript(true)

Then AppleScript can be used to execute code like

tell application "Hammerspoon" to execute lua code "drawIndicator('command')"

@januz Brilliant, this solutions works perfectly. Thank you!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings