HokieGeek / dotfiles

My linux config files
0 stars 0 forks source link

Toggle symbol used for workspaces displayed in dzen #60

Closed HokieGeek closed 8 years ago

HokieGeek commented 10 years ago

I want the default to be the symbols, but it would be nice - at least while I adjust to it - to be able to toggle, with a key binding, between symbols and the workspace names.

HokieGeek commented 10 years ago
dzenWorkspaceSymbol :: WorkspaceId -> String
dzenWorkspaceSymbol x
  | useWorkspaceName = x
  | otherwise = "^i(/home/andres/.xmonad/imgs/workspace.xbm)"
-- "^i(\\$HOME/.xmonad/imgs/workspace.xbm)"

And then, I need something like this:

, ((modm, xK_F1), useWorkspaceName = !useWorkspaceName)
HokieGeek commented 10 years ago

Until I figure out how to use not correctly with this language, the following might suffice:

, ((modm, xK_F1), useWorkspaceName = True)
, ((modm, xK_F2), useWorkspaceName = False)
HokieGeek commented 10 years ago

Toggling

toggle v = do
    t' <- readIORef v
    writeIORef v (not t')

BETTER

toggle v = readIORef v >>= \v' -> (writeIORef v) (not v')

So I need the following snippets:

userWorkspaceName <- newIORef False
, ((0, xK_F2), toggle useWorkspaceName)

An example of calling toggle:

toggleTest = do
    tester <- newIORef False
    readIORef tester >>= print
    toggle tester
    readIORef tester >>= print
HokieGeek commented 10 years ago

The function

Assuming that I figure out a way for useWorkspaceName to be in scope:

  1. This option will work
getDzenWorkspaceSymbol :: Bool -> WorkspaceId -> String
getDzenWorkspaceSymbol wsname id
  | wsname = id
  | otherwise = "^i(/home/andres/.xmonad/imgs/workspace.xbm)"

dzenWorkspaceSymbol id = readIORef useWorkspaceName >>= \uwn' -> getDzenWorkspaceSymbol uwn' id
  1. I prefer this one, if it works.
dzenWorkspaceSymbol :: WorkspaceId -> String
dzenWorkspaceSymbol id
  | useWorkspaceName' = id
  | otherwise = "^i(/home/andres/.xmonad/imgs/workspace.xbm)"
 where useWorkspaceName' <- readIORef useWorkspaceName
HokieGeek commented 9 years ago

This seems very non-idiomatic