Permalink
Browse files

Set window title (close #41)

  • Loading branch information...
1 parent 2da4d4e commit aa5920193453a46641772f52edeab61effebeb83 @sol sol committed Aug 2, 2012
Showing with 11 additions and 0 deletions.
  1. +7 −0 src/Command.hs
  2. +4 −0 src/Util.hs
View
@@ -57,6 +57,7 @@ import Command.Completion
import Tab (Tabs)
import qualified Tab
+import qualified Song
-- | Initial tabs after startup.
tabs :: Tabs AnyWidget
@@ -83,6 +84,12 @@ instance Widget PlaylistWidget where
return $ ListWidget.update l songs
EvCurrentSongChanged song -> do
+ -- set window title
+ let title = case song of
+ Nothing -> "vimus"
+ Just s -> "vimus: " ++ Song.artist s ++ " - " ++ Song.title s
+ liftIO $ setTitle title
+
let mIndex = song >>= MPD.sgIndex
w = l `ListWidget.setMarked` mIndex
View
@@ -80,3 +80,7 @@ clamp :: Int -- ^ lower bound (inclusive)
-> Int
-> Int
clamp lower upper n = max lower $ min (pred upper) n
+
+-- | Emit ANSI sequence to change the console window title.
+setTitle :: String -> IO ()
+setTitle title = putStrLn $ "\ESC]0;" ++ filter (/= '\007') title ++ "\007"

0 comments on commit aa59201

Please sign in to comment.