hbro 0.6.3 → 0.6.4
raw patch · 6 files changed
+66/−18 lines, 6 filesdep +old-localedep +time
Dependencies added: old-locale, time
Files
- Hbro/Extra/Clipboard.hs +1/−1
- Hbro/Extra/History.hs +49/−0
- Hbro/Main.hs +1/−4
- Hbro/Util.hs +3/−0
- examples/hbro.hs +8/−11
- hbro.cabal +4/−2
Hbro/Extra/Clipboard.hs view
@@ -30,7 +30,7 @@ Just t -> clipboardSetText primaryClip t _ -> return () --- | Load URI from clipboard. Does not work for now...+-- | Load URI from clipboard. loadURIFromClipboard :: Browser -> IO () loadURIFromClipboard browser = do primaryClip <- widgetGetClipboard (mWindow $ mGUI browser) selectionPrimary
+ Hbro/Extra/History.hs view
@@ -0,0 +1,49 @@+module Hbro.Extra.History where++-- {{{ Imports+import Hbro.Core+import Hbro.Types++import Data.List+import Data.Time++import System.Environment+import System.Exit+import System.Locale+import System.Process +-- }}} +++-- |+addToHistory :: String -> String -> IO ()+addToHistory uri title = do+ now <- getCurrentTime+ configHome <- getEnv "XDG_CONFIG_HOME"+ let time = formatTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" now+ appendFile (configHome ++ "/hbro/history") $ time ++ " " ++ uri ++ " " ++ title ++ "\n"++-- |+loadFromHistory :: Browser -> IO ()+loadFromHistory browser = do+ configHome <- getEnv "XDG_CONFIG_HOME"+ file <- readFile $ configHome ++ "/hbro/history"++ let file' = unlines . sort . nub $ map reformat (lines file)++ (code, result, e) <- readProcessWithExitCode "dmenu" ["-l", "10"] file'+ return ()+ case (code, result) of+ (ExitSuccess, r) -> + let+ _:_:uri:_ = words $ r+ in+ loadURL uri browser+ _ -> putStrLn e++ where+ reformat line =+ let+ date:time:uri:title = words line + in + unwords $ [uri] ++ title+
Hbro/Main.hs view
@@ -4,15 +4,12 @@ import Hbro.Config import Hbro.Types -import System.Environment- import Paths_hbro -- }}} main :: IO () main = do- uiFile <- getDataFileName "examples/ui.xml"- configHome <- getEnv "XDG_CONFIG_HOME"+ uiFile <- getDataFileName "examples/ui.xml" -- putStrLn "[WARNING] You are running the default configuration which provides hardly no feature." -- putStrLn $ "[WARNING] You should copy the example configuration files hbro.hs and ui.xml in " ++ configHome ++ "/hbro and start hacking them."
Hbro/Util.hs view
@@ -10,9 +10,11 @@ import System.Process -- }}} + instance Ord Modifier where m <= m' = fromEnum m <= fromEnum m' + -- {{{ Keys-related functions -- | Converts a keyVal to a String. -- For printable characters, the corresponding String is returned, except for the space character for which "<Space>" is returned.@@ -50,6 +52,7 @@ importKeyBindings' (((a, b), c):t) = ((Set.fromList a, b), c):(importKeyBindings' t) importKeyBindings' _ = [] -- }}}+ -- {{{ Run commands -- | Like run `runCommand`, but return IO ()
examples/hbro.hs view
@@ -5,6 +5,7 @@ import Hbro.Core import Hbro.Extra.Bookmarks import Hbro.Extra.Clipboard+import Hbro.Extra.History import Hbro.Extra.Misc import Hbro.Extra.Prompt import Hbro.Extra.StatusBar@@ -49,7 +50,7 @@ -- {{{ Keys myKeys :: KeysList-myKeys = generalKeys ++ bookmarksKeys+myKeys = generalKeys ++ bookmarksKeys ++ historyKeys generalKeys :: KeysList generalKeys = [@@ -109,6 +110,10 @@ (([Control, Shift], "L"), loadTagFromBookmarks) ] +historyKeys :: KeysList+historyKeys = [+ (([Control], "h"), loadFromHistory)+ ] -- }}} @@ -205,10 +210,10 @@ -- History handler _ <- on webView loadFinished $ \_ -> do- getUri <- webViewGetUri webView+ getUri <- webViewGetUri webView getTitle <- webViewGetTitle webView case (getUri, getTitle) of- (Just uri, Just title) -> historyHandler uri title+ (Just uri, Just title) -> addToHistory uri title _ -> return () @@ -248,16 +253,8 @@ -- }}} --- {{{ Handlers downloadHandler :: String -> IO () downloadHandler uri = runExternalCommand $ "wget \"" ++ uri ++ "\""--historyHandler :: String -> String -> IO ()-historyHandler uri title = do- configHome <- getEnv "XDG_CONFIG_HOME"- runCommand (configHome ++ "/hbro/scripts/historyHandler.sh \"" ++ uri ++ "\" \"" ++ title ++ "\"") >> return ()--- }}}- promptGoogle :: Browser -> IO () promptGoogle browser =
hbro.cabal view
@@ -1,5 +1,5 @@ Name: hbro-Version: 0.6.3+Version: 0.6.4 Synopsis: A suckless minimal KISSy browser -- Description: Homepage: http://projects.haskell.org/hbro/@@ -31,8 +31,10 @@ glib, gtk, mtl,+ old-locale, pango, process,+ time, url, webkit, unix,@@ -42,6 +44,7 @@ Hbro.Core, Hbro.Extra.Bookmarks, Hbro.Extra.Clipboard,+ Hbro.Extra.History, Hbro.Extra.Misc, Hbro.Extra.Prompt, Hbro.Extra.StatusBar,@@ -59,7 +62,6 @@ glib, gtk, mtl,- pango, process, unix, webkit