forked from colonelpanic/dotfiles
[XMonad] Add icons to window actions
This commit is contained in:
parent
04f56edf98
commit
0e7fbb76b9
6
dotfiles/config/xmonad/base.nix
Normal file
6
dotfiles/config/xmonad/base.nix
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
(import ../taffybar/taffybar/nixpkgs.nix) {
|
||||||
|
overlays = [
|
||||||
|
(import ../taffybar/taffybar/overlay.nix)
|
||||||
|
(import ./overlay.nix)
|
||||||
|
];
|
||||||
|
}
|
@ -7,5 +7,4 @@ output_file=$1; shift
|
|||||||
cd "$SRC_DIR"
|
cd "$SRC_DIR"
|
||||||
exe_location="$SRC_DIR/result/bin/imalison-xmonad"
|
exe_location="$SRC_DIR/result/bin/imalison-xmonad"
|
||||||
nix-build
|
nix-build
|
||||||
echo "$exe_location" "$output_file" > did_build
|
|
||||||
cp -f "$exe_location" "$output_file"
|
cp -f "$exe_location" "$output_file"
|
||||||
|
1
dotfiles/config/xmonad/cabal.project
Normal file
1
dotfiles/config/xmonad/cabal.project
Normal file
@ -0,0 +1 @@
|
|||||||
|
packages: .
|
@ -1,6 +1 @@
|
|||||||
let
|
(import ./base.nix).haskellPackages.imalison-xmonad
|
||||||
pkgs = import <nixpkgs> { overlays = [ (import ./overlay.nix) ]; };
|
|
||||||
source = pkgs.lib.sourceByRegex ./. [
|
|
||||||
"xmonad.hs" "imalison-xmonad.cabal" "PagerHints.hs" "LICENSE"
|
|
||||||
];
|
|
||||||
in pkgs.haskellPackages.callCabal2nix "imalison-xmonad" source { }
|
|
||||||
|
@ -23,11 +23,12 @@ executable imalison-xmonad
|
|||||||
, multimap>=1.2.1
|
, multimap>=1.2.1
|
||||||
, process>=1.4.3.0
|
, process>=1.4.3.0
|
||||||
, split
|
, split
|
||||||
|
, taffybar
|
||||||
, transformers>=0.5.2.0
|
, transformers>=0.5.2.0
|
||||||
, tuple >= 0.3.0.2
|
, tuple >= 0.3.0.2
|
||||||
, utf8-string
|
, utf8-string
|
||||||
, xmonad-contrib>=0.13
|
, xmonad-contrib
|
||||||
, xmonad>=0.13
|
, xmonad
|
||||||
hs-source-dirs: .
|
hs-source-dirs: .
|
||||||
other-modules: PagerHints
|
other-modules: PagerHints
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
@ -3,6 +3,13 @@ _: pkgs: rec {
|
|||||||
overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: {})) (self: super: rec {
|
overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: {})) (self: super: rec {
|
||||||
xmonad = self.callCabal2nix "xmonad" (fetchGit ./xmonad) { };
|
xmonad = self.callCabal2nix "xmonad" (fetchGit ./xmonad) { };
|
||||||
xmonad-contrib = self.callCabal2nix "xmonad-contrib" (fetchGit ./xmonad-contrib) { };
|
xmonad-contrib = self.callCabal2nix "xmonad-contrib" (fetchGit ./xmonad-contrib) { };
|
||||||
|
imalison-xmonad = self.callCabal2nix "imalison-xmonad" (
|
||||||
|
pkgs.lib.sourceByRegex ./.
|
||||||
|
[
|
||||||
|
"xmonad.hs" "imalison-xmonad.cabal"
|
||||||
|
"PagerHints.hs" "LICENSE"
|
||||||
|
]
|
||||||
|
) { };
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
3
dotfiles/config/xmonad/shell.nix
Normal file
3
dotfiles/config/xmonad/shell.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let
|
||||||
|
pkgs = (import ./base.nix);
|
||||||
|
in pkgs.haskellPackages.shellFor { packages = p: [ p.imalison-xmonad ]; }
|
@ -10,6 +10,8 @@ import Control.Monad.Trans.Class
|
|||||||
import Control.Monad.Trans.Maybe
|
import Control.Monad.Trans.Maybe
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import qualified Data.ByteString.Lazy as B
|
import qualified Data.ByteString.Lazy as B
|
||||||
|
import Data.Char
|
||||||
|
import Data.Foldable
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.List.Split
|
import Data.List.Split
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
@ -24,7 +26,10 @@ import Network.HostName
|
|||||||
import PagerHints
|
import PagerHints
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.FilePath.Posix
|
import System.FilePath.Posix
|
||||||
|
import System.IO.Unsafe
|
||||||
import System.Process
|
import System.Process
|
||||||
|
import System.Taffybar.Hooks
|
||||||
|
import System.Taffybar.Information.XDG.DesktopEntry
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Unsafe.Coerce
|
import Unsafe.Coerce
|
||||||
import XMonad hiding ( (|||) )
|
import XMonad hiding ( (|||) )
|
||||||
@ -173,7 +178,7 @@ followingWindow action = do
|
|||||||
whenJust orig $ windows . W.focusWindow
|
whenJust orig $ windows . W.focusWindow
|
||||||
return res
|
return res
|
||||||
|
|
||||||
myDmenuArgs = ["-dmenu", "-i"]
|
myDmenuArgs = ["-dmenu", "-i", "-show-icons"]
|
||||||
|
|
||||||
myDmenu = DM.menuArgs "rofi" myDmenuArgs
|
myDmenu = DM.menuArgs "rofi" myDmenuArgs
|
||||||
|
|
||||||
@ -330,7 +335,7 @@ deactivateFullAnd action = sequence_ [deactivateFull, action]
|
|||||||
|
|
||||||
andDeactivateFull action = sequence_ [action, deactivateFull]
|
andDeactivateFull action = sequence_ [action, deactivateFull]
|
||||||
|
|
||||||
goFullscreen = sendMessage $ Toggle NBFULL
|
goFullscreen = sendMessage $ JumpToLayout "Tabbed Simplest"
|
||||||
|
|
||||||
-- Layout setup
|
-- Layout setup
|
||||||
|
|
||||||
@ -389,14 +394,28 @@ getVirtualClass = flip findM virtualClasses . classIfMatches
|
|||||||
|
|
||||||
getClass w = fromMaybe <$> getClassRaw w <*> getVirtualClass w
|
getClass w = fromMaybe <$> getClassRaw w <*> getVirtualClass w
|
||||||
|
|
||||||
|
desktopEntriesMap :: MM.MultiMap String DesktopEntry
|
||||||
|
desktopEntriesMap =
|
||||||
|
unsafePerformIO $ do
|
||||||
|
tee id (>>= writeToHomeDirLog . show . MM.keys) $
|
||||||
|
directoryEntriesByClassName <$> getDirectoryEntriesDefault
|
||||||
|
|
||||||
|
lookupIconFromClasses classes =
|
||||||
|
getFirst $ fold $ First . deIcon <$> (classes >>= idAndLower >>= flip MM.lookup desktopEntriesMap)
|
||||||
|
where idAndLower value = [value, map toLower value]
|
||||||
|
|
||||||
myDecorateName ws w = do
|
myDecorateName ws w = do
|
||||||
name <- show <$> getName w
|
name <- show <$> getName w
|
||||||
|
rawClass <- getClassRaw w
|
||||||
classTitle <- getClass w
|
classTitle <- getClass w
|
||||||
workspaceToName <- getWorkspaceNames
|
workspaceToName <- getWorkspaceNames
|
||||||
return $ printf "%-20s%-40s %+30s" classTitle (take 40 name)
|
let iconName = fromMaybe "" $ lookupIconFromClasses [rawClass, classTitle]
|
||||||
"in " ++ workspaceToName (W.tag ws)
|
entryString = printf "%-20s%-40s %+30s in %s \0icon\x1f%s"
|
||||||
|
classTitle (take 40 name) " " (workspaceToName (W.tag ws)) iconName
|
||||||
|
return entryString
|
||||||
|
|
||||||
data ChromeInfo = ChromeInfo { tabId :: Int
|
data ChromeInfo = ChromeInfo
|
||||||
|
{ tabId :: Int
|
||||||
, tabUri :: String
|
, tabUri :: String
|
||||||
, tabTitle :: String
|
, tabTitle :: String
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
@ -434,10 +453,10 @@ chromeTabAction doSplit action selected =
|
|||||||
|
|
||||||
-- This needs access to X in order to unminimize, which means that it can't be
|
-- This needs access to X in order to unminimize, which means that it can't be
|
||||||
-- done with the existing window bringer interface
|
-- done with the existing window bringer interface
|
||||||
myWindowAct c@WindowBringerConfig {menuCommand = cmd, menuArgs = args} filterVisible action = do
|
myWindowAct c@WindowBringerConfig {menuCommand = cmd, menuArgs = args}
|
||||||
|
filterVisible action = do
|
||||||
visible <- visibleWindows
|
visible <- visibleWindows
|
||||||
currentlyFullscreen <- isToggleActiveInCurrent NBFULL
|
currentlyFullscreen <- isToggleActiveInCurrent NBFULL
|
||||||
-- Uncomment filter to remove windows that are visible
|
|
||||||
let actualConfig =
|
let actualConfig =
|
||||||
if fromMaybe False currentlyFullscreen
|
if fromMaybe False currentlyFullscreen
|
||||||
then c
|
then c
|
||||||
@ -446,7 +465,6 @@ myWindowAct c@WindowBringerConfig {menuCommand = cmd, menuArgs = args} filterVis
|
|||||||
then c {windowFilter = not . flip elem visible}
|
then c {windowFilter = not . flip elem visible}
|
||||||
else c
|
else c
|
||||||
ws <- windowMap' actualConfig
|
ws <- windowMap' actualConfig
|
||||||
-- chromeTabs <- liftIO getChromeTabInfo
|
|
||||||
let options = M.union (M.map Left ws) (M.map Right M.empty)
|
let options = M.union (M.map Left ws) (M.map Right M.empty)
|
||||||
selection <- DM.menuMapArgs cmd args options
|
selection <- DM.menuMapArgs cmd args options
|
||||||
whenJust selection action
|
whenJust selection action
|
||||||
|
Loading…
Reference in New Issue
Block a user