I'm following the instructions Here to make a program (wicd-gtk) always run in a floating window.
Here are the relevant sections from my xmonad.hs:
myManageHook = composeAll
[ className =? "wicd-gtk" --> doFloat
, className =? "stalonetray" --> doIgnore
, manageDocks
]
main = do
xmproc <- spawnPipe "~/.local/bin/xmobar ~/.xmobarrc"
xmonad $ dynamicProjects projects $ docks def
{ layoutHook = avoidStruts $ myLayoutHook
, manageHook = myManageHook <+> manageHook def
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppLayout = (\x -> drop 10 x)
, ppTitle = xmobarColor "green" "" . shorten 150
}
, modMask = mod4Mask
, keys = myKeys
, workspaces = myWorkspaces
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
}
I don't get any errors when I recompile but wicd-gtk does not load as a floating window. I also previously tried using doShift to force firefox into a specific window but that did not work as well.
Any ideas what I am doing wrong?
If anyone else was stuck on this, it turns out manageHooks takes the xprop classname not the program name. You can read all about it here: https://wiki.haskell.org/Xmonad/Frequently_asked_questions#I_need_to_find_the_class_title_or_some_other_X_property_of_my_program
Related
Xmonad hides xmobar and tabs on tabbed layouts. What is wrong with config?
I am using xmonad with xmobar for long time. But last time when I migrated back to Arch linux all layouts from XMonad.Layout.Tabbed show windows on full screen. No xmobar or any tab on the screen. Windows switching and anything else works as well.
Here is three screenshots from my three layouts:
Grid:
Spiral:
Tabbed:
xmonad.hs:
import XMonad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
import System.Directory (getHomeDirectory)
import System.FilePath.Posix (joinPath)
import Graphics.X11.Xlib
import Graphics.X11.ExtraTypes.XF86
--import IO (Handle, hPutStrLn)
import qualified System.IO
import XMonad.Actions.CycleWS (nextScreen,prevScreen)
import Data.List
-- Prompts
import XMonad.Prompt
import XMonad.Prompt.Shell
-- Actions
import XMonad.Actions.MouseGestures
import XMonad.Actions.UpdatePointer
import XMonad.Actions.GridSelect
import XMonad.Actions.CycleWS
-- Utils
import XMonad.Util.Run (spawnPipe, safeSpawn)
import XMonad.Util.Loggers
import XMonad.Util.EZConfig
import XMonad.Util.Scratchpad
import XMonad.Util.NamedWindows
import qualified XMonad.StackSet as W
-- Hooks
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.Place
import XMonad.Hooks.EwmhDesktops
-- Layouts
import XMonad.Layout.NoBorders
import XMonad.Layout.Fullscreen
import XMonad.Layout.LayoutCombinators hiding ((|||))
import XMonad.Layout.Grid
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import Data.Ratio ((%))
import XMonad.Layout.ToggleLayouts
import XMonad.Layout.Spacing
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.Gaps
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.SetWMName
defaults = defaultConfig {
terminal = "xterm"
, workspaces = myWorkSpaces
, modMask = mod4Mask
, layoutHook = myLayoutHook
-- , manageHook = myManageHook
, startupHook = myStartupHook
, borderWidth = 2
, normalBorderColor = "#303030"
, focusedBorderColor = "#A0A0A0"
} `additionalKeys` myKeys
myKeys = [
((mod4Mask, xK_g), goToSelected defaultGSConfig)
, ((mod4Mask, xK_s), spawnSelected defaultGSConfig ["vivaldi","idea","robo3t","thunderbird","postman","easyhg","renoise","telegram-desktop"])
, ((mod4Mask, xK_c), spawn "ps -eo pcpu,pid,user,args | sort -r | head -5 >> ~/cpu-report")
, ((mod4Mask, xK_grave), nextWS)
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 3%+ && ~/.xmonad/getvolume.sh >> /tmp/.volume-pipe")
, ((0, xF86XK_AudioLowerVolume), spawn "amixer -D pulse sset Master 3%- && ~/.xmonad/getvolume.sh >> /tmp/.volume-pipe")
, ((0, xF86XK_AudioMute), spawn "amixer -D pulse sset Master toggle && ~/.xmonad/getvolume.sh >> /tmp/.volume-pipe")
, ((0, xK_Print), spawn "scrot")
]
myWorkSpaces :: [String]
myWorkSpaces = [
"<action=`xdotool key Super_L+1`> |1| </action>"
, "<action=`xdotool key Super_L+2`> |2| </action>"
, "<action=`xdotool key Super_L+3`> |3| </action>"
, "<action=`xdotool key Super_L+4`> |4| </action>"
, "<action=`xdotool key Super_L+5`> |5| </action>"
, "<action=`xdotool key Super_L+6`> |6| </action>"
, "<action=`xdotool key Super_L+7`> |7| </action>"
, "<action=`xdotool key Super_L+8`> |8| </action>"
, "<action=`xdotool key Super_L+9`> |9| </action>"
]
-- tab theme default
myTabConfig = defaultTheme {
activeColor = "#666666"
, activeBorderColor = "#000000"
, inactiveColor = "#666666"
, inactiveBorderColor = "#000000"
, decoHeight = 10
}
xmobarTitleColor = "#FFB6B0"
xmobarCurrentWorkspaceColor = "#FFB6B0"
xmobarUrgentWorkspaceColor = "#45A5F5"
xmobarHiddenNoWindowsColor = "#A4A19F"
myStartupHook = do
startupHook defaultConfig
setWMName "LG3D"
spawn "~/.xmonad/getvolume.sh >> /tmp/.volume-pipe"
myLayoutHook =
avoidStruts $
spacing 6 $
gaps [(U,15)] $
toggleLayouts (noBorders Full) $
smartBorders $ Grid ||| spiral (6/7) ||| tabbedAlways shrinkText defaultTheme
myManageHook = manageDocks <+> manageHook defaultConfig
data LibNotifyUrgencyHook = LibNotifyUrgencyHook deriving (Read, Show)
instance UrgencyHook LibNotifyUrgencyHook where
urgencyHook LibNotifyUrgencyHook w = do
name <- getName w
safeSpawn "notify-send" [show name]
main = do
xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmonad/xmobar.hs"
xmonad $ withUrgencyHook LibNotifyUrgencyHook $ fullscreenSupport $ defaults {
logHook = dynamicLogWithPP $ defaultPP {
ppOutput = System.IO.hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 65
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor "" . wrap "" ""
, ppUrgent = xmobarColor xmobarUrgentWorkspaceColor "" . wrap "" ""
, ppHiddenNoWindows = xmobarColor xmobarHiddenNoWindowsColor {-"#7e7c7a"-} "" . wrap "" ""
, ppSep = " "
, ppWsSep = ""
, ppLayout = (\ x -> case x of
"Spacing Grid" -> "[ Grid ]"
"Spacing Spiral" -> "[Spiral]"
_ -> x )
}
}
xmobar.hs:
Config {
font = "xft:DejaVu Sans Mono:size=9:bold:antialias=true",
bgColor = "#000000",
fgColor = "#fcf9f4",
alpha = 125,
position = Static { xpos = 0, ypos = 0, width = 1920, height = 18 },
lowerOnStart = True,
commands = [
Run Memory ["-t","mem: <usedbar>", "-n", "#45a5f5", "-L", "0", "-H", "100"] 10
,Run Date "%d.%m.%Y %a %H:%M:%S" "date" 10
,Run MultiCpu [ "--template" , "cpu: <autovbar>"
, "--Low" , "50" -- units: %
, "--High" , "85" -- units: %
, "--low" , "gray"
, "--normal" , "darkorange"
, "--high" , "darkred"
, "-c" , ""
, "-w" , "1"
] 3
,Run Com "/home/laniakea/.xmonad/getinet.sh" [] "inet" 10
,Run UnsafeStdinReader
,Run PipeReader "/tmp/.volume-pipe" "vol"
,Run Kbd [("us", "US"),("ru", "RU")]
,Run Battery ["-t", "<acstatus> <left>%", "--", "-o", "<fc=#f7c2ba>Off</fc>", "-O", "<fc=#45a5f5>On</fc>", "-i", "<fc=#fcf9f4>Idle</fc>"] 10
],
sepChar = "%",
alignSep = "}{",
template = " %UnsafeStdinReader% }{%vol% | %multicpu% | %memory% | %battery% | %inet% | %kbd% | <fc=#f7c2ba>%date%</fc> "
}
I expect on tabbed layout I still can see xmobar with all info and tabs if I have several windows opened on workspace. Thank you.
I might be answering this question late but this happened for me too. For me I tested the same thing using Xephyr this gave me a clue as to what caused the issue. The issue for me was all about the fonts. So I fixed it in this manner.
myLayout = tabs ||| ...
where
tabs = tabbed shrinkText myTabConf
myTabConf :: Theme
myTabConf = def {
fontName = "xft:Source Code Pro:size=8:antialias=true"
}
If you notice the error generated while using xephyr(user error (createFontSet)), and research a bit on it you will find this.
Running Manjaro and trying to get XMonad to work I encountered a parse error on input '{' with the following xmonad.hs:
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, pptitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask -- rebind Mod to the windows key
} `additionalKeys`
[ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock; xset dmps force off")
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]
I have found this solution on su.sx and took my xmonad.hs from readthedocs.io.
For getting started I would like to use that config file, I do not know however how to apply the solution to this. If somebody proficient could explain why that error appears and how to fix it, I'd really appreciate it since I just recently started with Haskell and it's really bending my mind to an unknown extent... :D
Indent everything after the xmonad $ defaultConfig line further to the right (it seems some of the indentation was lost when you pasted the example):
main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask -- Rebind Mod to the Windows key
} `additionalKeys`
[ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock; xset dpms force off")
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]
Lines at the "parent" indentation level in a do-block are parsed as separate statements, which is not appropriate here.
How can I generate this kind of tiling with xmonad?
http://xmonad.org/images/screen-ejt-spiral-dzen.png
I know you can increase/decrease the number of windows in the master pane with mod-comma, and use mod-space mod-h and mod-l to change the layout. But it seems like just those set of commands cannot reproduce the kind of tiling in the above link.
In particular, there are two things I just don't know how to do that the link above does:
The larger tile on the right is not split horizontally in the middle, but is actually longer. I can only increase/decrease the master pane like that using mod-h and mod-l
The smaller tile on the right is split into two subtiles. I have no idea how you would even go about this with xmonad
You need to create a new layout in your .xmonad/xmonad.hs
For this you need to have a little experience with haskell.
I've created a fullscreen Layout which can be used by pressing a specific key combination here's an example:
import the following:
import XMonad.Layout.Spacing
import XMonad.Layout.LayoutCombinators hiding ( (|||) )
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
import XMonad.Layout.Reflect
import XMonad.Layout.Combo
import XMonad.Layout.TwoPane
import XMonad.Layout.Tabbed
import XMonad.Layout.PerWorkspace
import XMonad.Layout.IM
import XMonad.Layout.ThreeColumns
And then you could do something like this:
sPx = 1
verticalLayout = spacing sPx $ avoidStruts $ reflectHoriz $ Tall 1 0.03 0.5
verticalLayoutLargeScreen = spacing sPx $ avoidStruts $ ThreeCol 1 0.03 0.5
horizontalLayout = spacing sPx $ avoidStruts $ Mirror $ Tall 1 0.03 0.5
webdevLayout = spacing sPx $ avoidStruts $ Tall 1 0.03 0.63
fullscreenLayout = noBorders $ fullscreenFull $ Full
myLayout =
onWorkspace "2:web" (webdevLayout ||| fullscreenLayout) $
(verticalLayout ||| horizontalLayout ||| fullscreenLayout)
After this define a mapping for your key combo:
myAdditionalKeys = [
-- Switch to next layout:
((mod4Mask .|. shiftMask, xK_m), sendMessage NextLayout),
]
and then do not forget to add your layout and your key Mapping to the config, could look like this:
main = do
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
I installed XMonad and XMobar with configured settings. When I start XMonad a XMobar on any without first workspace is dock and opened programs have place below XMobar, but on first workspace when I open any program XMobar become hidden.
These are my XMonad and XMobar configs:
--XMonad:
import XMonad
import XMonad.Util.Run(spawnPipe)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
main = do
xmproc <- spawnPipe "xmobar ~/.xmobarrc"
xmonad $ defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, borderWidth = 2
, terminal = "terminator"
, normalBorderColor = "#cccccc"
, focusedBorderColor = "#cd8b00"
}
--XMobar:
Config { font = "-misc-fixed-*-*-*-*-33-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, commands = [ Run Cpu ["-L","3","-H","50",
"--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Swap [] 10
, Run Com "uname" ["-s","-r"] "" 36000
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run Com "~/.xmonad/batt" [] "" 300
, Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %cpu% | %memory% | %.xmonad/batt% | <fc=#ee9a00>%date%</fc>"
}
I had the same issue with xmobar v0.24 and xmonad v0.12. I also experienced the problem on all workspaces when quickly recompiling twice (meta-q). I fixed this by setting overrideRedirect to False in my .xmobarrc.
overrideRedirect
If you're running xmobar in a tiling window manager, you might need to set this option to False so that it behaves as a docked application. Defaults to True.
I recently got into XMonad and unforunately I don't know much Haskell at all. I'm trying to configure my xmonad.hs file such that I can control the volume. However, right now, even though my xmonad.hs file compiles without errors, I cannot control the volume.
I got the volume control code from this link:http://dmwit.com/volume/
Here is my configuration file:
import XMonad
import XMonad.Util.Run(spawnPipe)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Actions.Volume
import XMonad.Util.Dzen
import Data.Map (fromList)
import Data.Monoid (mappend)
import System.IO
alert = dzenConfig centered . show . round
centered =
onCurr (center 150 66)
>=> font "-*-helvetica-*-r-*-*-64-*-*-*-*-*-*-*"
>=> addArgs ["-fg", "#80c0ff"]
>=> addArgs ["-bg", "#000040"]
main = do
xmproc <- spawnPipe "xmobar /home/david/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
, keys =
keys defaultConfig `mappend`
\c -> fromList [
((0, xK_F6), lowerVolume 4 >>= alert),
((0, xK_F7), raiseVolume 4 >>= alert)
]
}
I have changed my code the following, however the volume has not changed:
main = do
xmproc <- spawnPipe "xmobar /home/luren/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
, keys =
keys defaultConfig `mappend`
\c -> fromList [
((0, 0x1008FF11), spawn "amixer -D pulse sset Master 4-"),
((0, 0x1008FF13), spawn "amixer -D pulse sset Master 4+")
]
}
(END)
Those keys are the codes for the volume media keys on my laptop.
I snooped around and saw some other configurations. I decided to do a little test and make the audio lower volume key print Hi ppl! when pressed. Unfortunately, this does not work.
main = do
xmproc <- spawnPipe "xmobar /home/luren/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
}
`additionalKeys`
[
((0, xF86XK_AudioLowerVolume), spawn "echo 'Hi ppl!'"),
((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 15%+")
]
Here is a script that I wrote to control pulse audio volume. Dump it in a file named pulse_control.pl and make sure it is executable and in your PATH. It uses pacmd and pactl which you may have to install with your distro's package manager.
#!/usr/bin/perl
use List::Util qw[min max];
use Getopt::Long;
my $_IS_MUTED;
my $_TOGGLE_MUTE;
my $_VOL;
my $_INC_VOL;
my $_DEC_VOL;
GetOptions(
"is-muted" => \$_IS_MUTED
, "toggle-mute" => \$_TOGGLE_MUTE
, "volume" => \$_VOL
, "inc-vol" => \$_INC_VOL
, "dec-vol" => \$_DEC_VOL
);
my $sink = `pactl info | sed -rn 's/^Default Sink: (.+)\$/\\1/gp'`;
chomp $sink;
sub ismuted {
my $ismuted = `pacmd dump | grep "$sink" | grep sink-mute | grep yes`;
chomp $ismuted;
if ($ismuted ne "") {
return 1;
} else {
0;
}
}
sub curvol {
my $volline = `pacmd dump | grep "$sink" | grep sink-vol`;
if ($volline =~ m/(0x[0-9a-f]+)/ ) {
return hex $1;
} else {
return 0;
}
}
if ($_IS_MUTED) {
print ismuted(), "\n";
}
elsif($_TOGGLE_MUTE) {
if (ismuted()) {
`pactl set-sink-mute $sink 0`;
} else {
`pactl set-sink-mute $sink 1`;
}
}
elsif($_VOL) {
print int(curvol() * 100.0 / hex("0x10000")), "%\n";
}
elsif($_INC_VOL) {
my $newvol = min(hex("0x10000"), curvol() + int((hex("0x10000") * .04)));
`pactl set-sink-volume $sink $newvol`;
}
elsif($_DEC_VOL) {
my $newvol = max(0, curvol() - int((hex("0x10000") * .04)));
`pactl set-sink-volume $sink $newvol`;
}
Then in my xmonad config, I have volume control bound to ctrl+alt+(page up/page down/end).
`additionalKeys`
[
((controlMask .|. mod1Mask, xK_Page_Up), spawn "pulse_control.pl -inc")
, ((controlMask .|. mod1Mask, xK_Page_Down), spawn "pulse_control.pl -dec")
, ((controlMask .|. mod1Mask, xK_End), spawn "pulse_control.pl -toggle")
]
This can also be achieved using the following spawn:
[ ((0, 0x1008FF11), spawn "amixer -q sset Master 2%-"),
((0, 0x1008FF13), spawn "amixer -q sset Master 2%+"),
((0, 0x1008FF12), spawn "amixer set Master toggle")]
These are multimedia keys but you could also use x86Vol binds instead of hex's.