I am using xmonad, and wanted a nice way to lock the screen. So I installed slock (apt-get install slock), and it works great.
Then I wanted an easy key sequence to trigger slock, so I defined this new function in xmonad.hs:
import qualified Data.Map as M
myKeys conf#(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((modMask .|. controlMask, xK_l),
spawn "slock")
]
and added keys = myKeys in the main function.
This enabled me to nicely lock the screen using Ctrl+Alt+l, but then none of the other xmonad shortcuts would work!
Is there a way for me to add a single new key binding, but without altering any of the existing bindings?
As you've probably guessed, by setting keys = myKeys in the main function, what you've done is to override the default settings. You can add your keys using the additionalKeys operator, like so:
main =
xmonad $ desktopConfig `additionalKeys` myKeys
Or, if you have some other customisations to desktopConfig,
main =
xmonad $ desktopConfig
{
-- other customisations
} `additionalKeys` myKeys
Related
I'm trying out Xmonad and am building a config file. However I have an issue with the keybindings. Some of my keybindings are working and some aren't. It makes no sense to me why. It compiles just fine, no errors. And to me either all should work or none. Why just some?
For instance I can launch a terminal, lock my screen, launch the file manager but i can't launch firefox or vscode. And the same in the next section. I can launch rofi launcher, rofi window finder but dmenu and rofi exit menu aren't working with this in my config:
terminalCmd = "alacritty"
browserCmd = "firefox"
editorCmd = "code"
fileManagerCmd = "nautilus --new-window"
dmenuCmd = "dmenu_run"
rofiCmd = "rofi -show drun -theme clean"
rofiWinCmd = "rofi -show window -theme clean_window"
rofiExitCmd = "~/.config/rofi/launch.sh powermenu"
screenLockCmd = "slock"
myFocusFollowsMouse = True
myKeybindings conf#XConfig {modMask = modMask} = M.fromList $
--Launch programs
[ ((modMask, xK_Return), spawn terminalCmd) --Launch terminal
, ((modMask, xK_w), spawn browserCmd) --Launch browser
, ((modMask, xK_e), spawn editorCmd) --Launch editor
, ((modMask, xK_a), spawn fileManagerCmd) --Launch file manager
, ((modMask, xK_l), spawn screenLockCmd) --Lock the screen
--Launchers and menus
, ((modMask, xK_r), spawn dmenuCmd) --Launch dmenu launcher
, ((modMask, xK_p), spawn rofiCmd) --Launch rofi launcher
, ((modMask .|. shiftMask, xK_p), spawn rofiWinCmd) --Launch rofi window finder
, ((modMask .|. shiftMask, xK_e), spawn rofiExitCmd) --Launch rofi exit menu
main = xmonad $ def
{ modMask = mod4Mask
, focusFollowsMouse = myFocusFollowsMouse
, borderWidth = 1
, terminal = terminalCmd
, normalBorderColor = "#cccccc"
, focusedBorderColor = "#cd8b00"
, workspaces = myWorkspaces
, keys = myKeybindings
, startupHook = myStartupHook }
Here's how I would debug the problem.
Try typing the raw command in a terminal. If that doesn't work, them you know the problem isn't with your XMonad configuration or XMonad, it's with the command itself.
If the command works in the terminal, try binding it to a different key in your XMonad. If that works, then the issue is with the key bindings. Launch xev, press the key you want to use, and double-check the name of the event that is triggered.
Take one of the commands that are currently working when you use XMonad to launch them, and try also binding it to one of the keys that you're having a problem with.
If it works, then there's something wrong with your original command. If step 1 worked, then the problem may have something to do with launching the command directly in XWindows instead of a terminal.
If it doesn't work, that's more confirmation that you're not using the right key binding.
Also, to rule out any difference between the value of the PATH environment variable that XMonad sees and the one that the terminal sees, try supplying the full path to the command in your configuration.
This is my xmonad config:
import XMonad
import XMonad.Config.Desktop
main = xmonad desktopConfig
{ terminal = "termite"
, modMask = mod4Mask
, borderWidth = 2
, focusedBorderColor = "#0080FF"
, normalBorderColor = "#000000"
}
How to remove borders when only one application is running? When there are already two applications in one window, the borders are needed.
http://hackage.haskell.org/package/xmonad-contrib-0.15/docs/XMonad-Layout-NoBorders.html#v:smartBorders
You need to set that as your layoutHook.
If I understand the question correctly (you say application but I assume you mean window).
In XMonad is there any way to see an overview of all the currently used workspaces including their current windows at a time?
I think it's a very practical piece of software but I have not found any extension that does something like this. Unless you do remember on which workspace you put all your windows, you end up cycling through the workspaces in order to find one particular window.
I'm thinking for instance of one extra workspace (maybe accessed by MOD-0) which gives you the overview. It could maybe even include some thumbnails of the open workspaces. But for the start a text based summary of the window titles would be ok. Does anybody know if this is existing? Or - if not - could anybody give me a rough direction where to start developing an extension/module doing this, maybe another extension that could be used as a point of departure or so.
You could use xmobar for this purpose, if right configured, it shows your current workspace(s) and all workspaces that have open windows or programs in it.
Looks like this:
And this is the config for it:
xmonad.hs:
main = do
xmproc <- spawnPipe "/usr/bin/xmobar /home/svoelkl/.xmobarrc"
status <- spawnPipe myDzenStatus
conky <- spawnPipe myDzenConky
xmonad $ defaultConfig
{ manageHook = manageSpawn <+> myManageHook <+> manageDocks,
layoutHook = myLayout,
logHook = dynamicLogWithPP xmobarPP {
ppOutput = hPutStrLn xmproc,
ppLayout = (\ x -> ""),
ppTitle = xmobarColor "#b2ed00" ""
} >> updatePointer (Relative 0.99 0.99),
modMask = mod4Mask,
borderWidth = 4,
normalBorderColor = "#777777",
focusedBorderColor = "#ccff00",
workspaces = myWorkspaces,
focusFollowsMouse = True,
terminal = "x-terminal-emulator"
}
`removeKeys` myRemoveKeys
`additionalKeys` myAdditionalKeys
.xmobarrc:
Config { position = TopSize L 90 24
, lowerOnStart = True
, bgColor = "black"
, fgColor = "grey"
, commands = [ Run Date "%a %_d %l:%M" "date" 10
, Run StdinReader
, Run BatteryP ["BAT0"]
["-t", "<acstatus><watts> (<left>%)",
"-L", "10", "-H", "80", "-p", "3",
"--", "-O", "<fc=#b2ed00>On</fc> -", "-o", "",
"-L", "-15", "-H", "-5",
"-l", "red", "-m", "blue", "-h", "green"]
600
]
, template = "%StdinReader% }{ %battery% <fc=#ee9a00>%date%</fc>"
}
XMonad is only a windows manager. You'll need something like xmobar/tint2/dzen to display the currently running applications.
An example of tint2:
You can use XMonad.Actions.GridSelect from xmonad-contrib. It will provide you with simple pop-up menu, similar to alt-tab menu in more 'traditional' GUI enviroinments.
Just add that keybinding
((modm, xK_g), goToSelected defaultGSConfig)
as explained in the link above.
Also check out XMonad.Actions.TreeSelect, this might be closer to what you want.
I'm on a Fedora-derived distribution where XMonad plays nicely with the windowing environment. The main assignment within my ~/.xmonad.xmonad.hs looks something like
main = do
session <- getEnv "DESKTOP_SESSION"
xmonad $ maybe desktopConfig desktop session
desktop "gnome" = gnomeConfig
desktop "kde" = kde4Config
desktop "xfce" = xfceConfig
desktop "xmonad-gnome" = gnomeConfig
desktop _ = desktopConfig
I see all these slick modifications I could make a la
xmonad $ desktopConfig {
manageHook = myManageHook <+> manageHook desktopConfig
, layoutHook = simpleTabbed ||| layoutHook desktopConfig
}
at places like http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Desktop.html.
I am a complete Haskell noob. How can I cleanly modify the
xmonad $ maybe desktopConfig desktop session
line to permit adding these goodies in a fashion that doesn't break the windowing environment dispatch?
main = do
session <- getEnv "DESKTOP_SESSION"
let config = maybe desktopConfig desktop session
xmonad $ config{ manageHook = myManageHook <+> manageHook config, ... }
when I use xmonad in ubuntu, I follow the tutorial of Xmonad, but there's no app menubar.
How can I solve this problem?
my configure file is here:
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
--import XMonad.Config.Gnome
import XMonad.Layout.Gaps
myLayouts = gaps [(U, 24)] -- $ layoutHook gnomeConfig
main = do
-- xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmobarrc"
xmonad $ defaultConfig
{manageHook = composeAll [
-- other hooks,
manageDocks
, className =? "Unity-2d-panel" --> doIgnore
--, className =? "Unity-2d-launcher" --> doIgnore
-- more hooks
]
-- for gnome begin
--manageDocks <+> manageHook defaultConfig
-- for gnome end
, layoutHook = avoidStruts $ layoutHook defaultConfig
--, logHook = dynamicLogWithPP xmobarPP
-- { ppOutput = hPutStrLn xmproc
-- , ppTitle = xmobarColor "green" "" . shorten 50
-- }
, modMask = mod4Mask -- Rebind Mod to the Windows key
}
Looks like you want to remove global appmenu bar, indicator-appmenu.
You can remove it using apt-get:
sudo apt-get remove indicator-appmenu
then logout/login. Note that this is global so all accounts will loose the global appmenu.
XMonad does not have a menubar, but there are plenty bar's out there. If you have a Gnome installed, you could use the gnome-panel as a first start.
Other menubar's that work well with XMonad are:
xmobar
dzen
conky