On Wed, 15 Feb 2006, Adam Chodorowski wrote:
On Wed, 15 Feb 2006 16:46:27 +0100, Etan Reisner <[EMAIL PROTECTED]> wrote:

<snip>
3. Quickly see which workspace you're currently in.  This can be helpful
if you tend to have workspaces with similar layouts/appearance (such as
three or four xterms arranged in a grid, as I do)

(I never did manage to get that "workspace indicator" script working --
has anybody made an up-to-date statusbar plugin to do that?)

There is a statusbar workspace script in the ion3 repository I don't know if it works correctly or not since I wrote my own before that one existed.

It's not very good (doesn't support multiple screens and doesn't detect workspace renames).

Yeah, it has it's problems. Like the fact that it hardcodes screen 0 instead of using the screen from the screen_managed_changed_hook event, and the fact that it uses a timer instead of just the hook.

Not noticing workspace renaming is forgivable though because I don't think ion has any way of notifying anything about the change. (This would actually be a reason to use a timer if you really wanted it to catch this, or you could just switch workspaces away and back.) Actually using the existing script if you just moved the find_screen_id line into notify_statusbar it will probably pick up workspace renames after the timeout time.

        -Etan

P.S. My version is attached, if people think is should be in the repository feel free to tell me to submit it or to submit it yourselves. I think it should handle multiple screens better (though I don't really know since I don't have multiple screens, I also don't know that it will handle multiple statusbars (or even if that can be handled at all)
-- wsname.lua
--
-- Author: Etan Reisner <[EMAIL PROTECTED]>
-- Version: 0.5
--
-- Shows the current workspace name in the statusbar, optionally shows all the
-- workspace names with the current one marked off.
--
-- Usage:
-- Add dopath("wsname.lua") to your config files.
-- and
-- Add %wsname (or %wsfull) to your statusbar template.

if not _LOADED["mod_statusbar"] then
        return
end

if not wsname then
        wsname = {
                marker = "*",
                template = "xxxxxxxxx",
        }
end

local function get_ws_name(t)
        local reg = t["reg"]

        if obj_is(reg, "WScreen") then
                mod_statusbar.inform("wsname", reg:lcurrent(1):name())
                mod_statusbar.inform("wsname_template", wsname.template)

                local ws_names = ""
                table.foreach(reg:llist(1), function(k, ws)
                                                    local marker = ""
                                                    if ws == reg:lcurrent(1) 
then
                                                            marker = 
wsname.marker
                                                    end
                                                    ws_names = ws_names .. 
marker .. ws:name() .. marker .. " "
                                            end)
                mod_statusbar.inform("wsfull", ws_names)
                mod_statusbar.inform("wsfull_template", string.len(ws_names))
                ioncore.defer(function() mod_statusbar.update() end)
        end
end

local function setup_hooks()
        local hook

        hook = ioncore.get_hook("screen_managed_changed_hook")
        if hook then
                hook:add(get_ws_name)
        end
end

-- Init
setup_hooks()

Reply via email to