Xmonad安装及入门配置

来自linux中国网wiki
Evan讨论 | 贡献2022年9月6日 (二) 13:32的版本 →‎Use a pre-built binary
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索



Throw away the mouse, and get productive in X!

https://xmonad.org/tour.html#start

依然存在的问题

1. 这个问题我换了个配置就好了,昨天不小心找到的,运气好呢 2019年12月20日 xmobar 会被其它窗口盖住 以前是不会的 ,现在加了 -d 参数,但是启动后reload才行,但是tray又没了 难道要stanltray才行么 这里学习一下 实在不行就 dzen2

2. trye 托盘也是老是不见

https://wiki.archlinux.org/index.php/Xmobar


xmonad折腾小记good

最近有空要搞的的 2019

Haskell简明教程(三):Haskell语法

http://learnyouahaskell.com/chapters



https://github.com/jiajunhuang/dotxmonad

XMonad 配置教程

pre

https://github.com/xmonad/xmonad 官方github 值得细看

https://github.com/evan886/myxmonad/tree/master/4bsd 我现在在freebsd12上用的配置

一直想找个好用的平铺式的桌面 ,今天终于找到了,用了一个多小时安装,配置和学习,总算可以用在办公了 这是在dovo记下的话 my repository

http://xmonad.org/intro.html

Here are some tools we've found work well with xmonad:

dmenu, a program dzen, an extensible status bar

xmobar, an extensible status bar

rxvt-unicode, a better terminal


美化

  • 用了lxappearance什么后 icon变得很好看

默认的 gtk 界面在 XMonad 下相当地丑, 可以安装lxappearance来调整 GTK 的主题.

freebsd12

pre

xmonad.hs20190921-1308 这个是x抄别人的 可以用的 只是功能不够:

xmonad-x86_64-freebsd 有这个bin 文件就是成功的了

install

Use a pre-built binary

 pkg install hs-xmonad hs-xmobar  xcompmgr trayer    hs-xmonad-contrib xcompmgr scrot nitrogen stalonetray moreutils dmenu dzen   libghc-xmonad-dev     #synapse  terminator
   pkg install x11-wm/hs-xmonad
   pkg install hs-xmonad

Launchers

 -- evan 2019 mod+d 
  , ((myModMask, xK_d), spawn "dmenu_run")


或者自启动 Synapse

How to run programs on startupr


cat .xinitrc
#!/bin/bash
#success
/home/evan/.xmonad/autostart.sh

export LC_ALL=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8.UTF-8
export LANG=zh_CN.UTF-8.UTF-8
#run desktop
exec  /usr/local/bin/xmonad
#exec awesome
#. /usr/local/etc/xdg/xfce4/xinitrc


#!/bin/bash
# xmonad "startup hook" script. This gets run after xmonad is initialized,
# via the startupHook facility provided by xmonad. It's useful for 
# running any programs which you want to use within xmonad but
# which don't need to be initialized before xmonad is running. 
#
# Author: David Brewer

# TRAY ICON SOFTWARE  on bsd 

#but not workspa name 
#xmobar -d ~/.xmonad/xmobarrc

stalonetray  &
#stalonetray \
#  --icon-gravity E \
# --geometry 5x1-0+0 \
#  --max-geometry 5x1-0+0 \
#  --background '#000000' \
#  --skip-taskbar \
#  --icon-size 24 \
#  --kludges force_icons_size \
#  --window-strut none \
#  &
#
#  这个在bsd上会被全屏盖住
#  apt install trayer  Set up an icon tray   2016-09-07pm
#trayer --edge top --align right --SetDockType true --SetPartialStrut true \
#      --expand true --width 9 --transparent true --tint 0x191970 --height 26 &

## mouse xmonad默认不设定鼠标光标,因此光标一直呈“X”形可能会让新用户误以为xmonad还没启动完毕或启动出错。将下面的命令添加到启动脚本,就可以将光标设置成常见的左键头形状: 
xsetroot -cursor_name left_ptr

# Empathy chat client (-h: start hidden, -n: don't connect on launch)
if [ -z "$(pgrep xscreensaver)" ] ; then
#    empathy -h -n &
xscreensaver -no-splash &
fi
# redshift
if [ -z "$(pgrep remmina)" ] ; then
    redshift   &
    #redshift  -i &
fi
#  201910 Remmina remote desktop connection client (-i: start hidden)
#if [ -z "$(pgrep remmina)" ] ; then
#    remmina -i &
#fi

# Network manager, so we don't have to configure wifi at the command line.
if [ -z "$(pgrep nm-applet)" ] ; then
    #nm-applet 
    nm-applet --sm-disable &
    /usr/sbin/NetworkManager --no-daemon
fi

# Applet for managing print jobs from the tray.
if [ -z "$(pgrep system-config-printer-applet)" ] ; then
    system-config-printer-applet &
fi

#
# APPLICATION LAUNCHER
#

#http://do.cooperteam.net/
# Use fcitx
#if [ -z "$(pgrep fcitx)" ] ;
#then
#    gnome-do -s &
    fcitx  -r &
#fi

# Use synapse as our app launcher. (-s: don't display until requested) 
#if [ -z "$(pgrep kupfer)" ] ; then
#    kupfer -s 
#    kupfer -s &
#fi

# Use synapse as our app launcher. (-s: don't display until requested) 
if [ -z "$(pgrep synapse)" ] ; then
    synapse -s &
fi

# On login, we unlock the ssh keychain so we're not prompted for 
# passphrases later. We pipe /dev/null to ssh-add to make it realize 
# it's not running in a terminal. Otherwise, it won't launch the prompt.
# 
# If you don't use the ssh keychain you may not want this. Commented
# by default as it is assumed many users will not want this feature.

# export SSH_ASKPASS="/usr/bin/ssh-askpass"
# cat /dev/null | ssh-add &

# I disable the middle mouse button because otherwise I constantly 
# accidentally paste unwanted text in the middle of my code while scrolling. 
# Note that the id of the mouse device may be different depending on 
# which usb port it is plugged into! To find it, use:
# xinput list |grep 'id='
# In the following command, the id is the first argument, the rest is 
# the remapping.

# Commented by default as it is assumed many users will not want this.
# xinput set-button-map 10 1 0 3 4 5 6 7

#关闭touchpad
# I disabled my touchpad because I hate those things. You can find the id
# of a device you want to disable using "xinput list"; unfortunately it can
# change depending on what devices you have plugged into USB. We extract the
# id of the device from the output of xinput, then use it to disable the
# device
#by evan  触摸板 看起来无效的 201910 sysmouse is mouse
#TOUCHPAD_ID=`xinput | grep 'Synaptics TouchPad' | cut -f 2 | cut -f 2 -d =`
#TOUCHPAD_ID=`xinput | grep 'core' | cut -f 2 | cut -f 2 -d =`
#xinput set-prop $TOUCHPAD_ID "Device Enabled" 0


但是在我的freebsd上不生效 

XMonad is launched from the login screen thanks to /usr/share/xsessions/xmonad.desktop. The program executed by this is not xmonad itself, but the bash script xmonad-session (present at /usr/bin/xmonad), which sources .xmonad/xmonad-session-rc and hence the contents of that file will be executed when you first log in to xmonad.

The workaround is slightly dodgy, as I think that the purpose of the xmonad-session-rc file was to set environment variables, not run programs, but I'm not certain.



https://unix.stackexchange.com/questions/482543/ubuntu-with-xmonad-how-to-run-programs-on-startup


https://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen's_Configuration

https://unix.stackexchange.com/questions/175127/xmobar-doesnt-appear

usage

Alt+Q 键盘快捷方式重新加载配置��

trouble

 hs-xmobar   in first not ins  laster serarch  freebsd xmonbar get the name  is  hs-xmobar

see also

一个容易的入门配置 https://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen's_Configuration

http://www.ruanyifeng.com/blog/2017/07/xmonad.html

https://wiki.archlinux.org/index.php/Xmonad_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

https://xmonad.org/download.html

https://github.com/xmonad/xmonad



常用快捷

Once you changed your config file you should compile it and restart XMonad.
user $xmonad --recompile
user $xmonad --restart 

--recompile #这个非常用用


man xmonad

   --mod+p  add run 
  , ((myModMask, xK_p), spawn "synapse")
    -- evan 2019 mod+d 
    , ((myModMask, xK_d), spawn "dmenu_run")



mod+mouse 可以移动窗口

启动 gmrun: mod-Shift-p

xmobar

20191127 今天 sudo ghc-pkg recache 后 xmobar一直强制在最上面 但是会盖住别人的标题啊 怎么搞哟


https://wiki.archlinux.org/index.php/Xmobar


https://beginners-guide-to-xmonad.readthedocs.io/configure_xmobar.html

wallpaper

https://hackage.haskell.org/package/xmonad-wallpaper

screeen


-- 2019 记住 变量 =  之间不能和空格 
-- The command to lock the screen or show the screensaver.
myscreensaver="/usr/local/bin/xscreensaver-command -l"
-- myScreensaver = "/usr/local/bin/xscreensaver-command -l"


 , ((myModMask, xK_p), spawn myscreensaver)

auto 的直接打开 直接配置




下面这些是尝试不成功的,但是有帮忙
    , ((myModMask, xK_s), spawn "xscreensaver-command -lock")
    --,((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock"  
    --, ("M-S-l", spawn "xscreensaver-command -lock")

为什么win+q  locker了 还有 能自动locker么 

https://github.com/vicfryzel/xmonad-config/blob/master/xmonad.hs 就是这个给了帮忙 自己加测试

redshift


https://wiki.archlinux.org/index.php/Redshift

ubuntu下 保护眼睛的RedShift

桌面背景

/usr/local/bin/feh --bg-fill  /home/evan/wallpaper/Mallnitz_Stappitz_Ankogel-Panorama_01.jpg

pkg installl

 stalonetray

layouts

https://github.com/xmonad/xmonad/wiki/Layouts


https://hackage.haskell.org/package/xmonad-0.15/docs/XMonad-Layout.html


https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Layout-WorkspaceDir.html


我的xmonad配置


在xmonad中更改窗口之间的红色边框

me


居然以前的配置可以用了

2019年 9月22日 星期日 22时36分21秒 CST
搞了好几天 ,今天换了一下 
https://github.com/sw2wolf/qachina/tree/master/db/doc/freebsd/xmonad
这个的主配置, 因为key 不习惯 再换回我在dovo的配置 居然就全好了 厉害 厉害 



launcher
deskutils/launchy


https://beginners-guide-to-xmonad.readthedocs.io/intro.html

https://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen's_Configuration


快速的xmonad good

https://github.com/sw2wolf/qachina/tree/master/db/doc/freebsd/xmonad

我的xmonad配置

http://hometown.scau.edu.cn/bbs/forum.php?mod=viewthread&tid=663621


https://beginners-guide-to-xmonad.readthedocs.io/configure_stalonetray.html

see also

https://wiki.haskell.org/Xmonad/Config_archive/adamvo's_xmonad.hs


xmonad on arch good

https://en.wikipedia.org/wiki/Xmonad

XMonad 配置教程


https://archives.haskell.org/

Xmonad: A Config


https://wiki.gentoo.org/wiki/Xmonad

这次轮到Xmonad了

轻量组件

第一 下载

到自己的 repository 下载

git clone https://github.com/davidbrewer/xmonad-ubuntu-conf.git

第二 安装

mv xmonad-ubuntu-conf/ .xmonad
echo "Installing required packages..."
sudo apt-get install xmonad trayer libghc-xmonad-dev libghc-xmonad-contrib-dev xmobar xcompmgr nitrogen stalonetray moreutils kupfer #synapse ssh-askpass-gnome thunar terminator remmina

echo “Creating xmonad xsession configuration…”
#sudo mv /usr/share/xsessions/xmonad.desktop /usr/share/xsessions/xmonad.desktop.original
#sudo cp ~/.xmonad/xmonad.desktop /usr/share/xsessions
#sudo cp ~/.xmonad/images/custom_xmonad_badge.png /usr/share/unity-greeter

echo “Linking to customized gnome 2 configuration…”
#mv ~/.gtkrc-2.0 ~/gtkrc-2.0.original
#ln -s .xmonad/.gtkrc-2.0 ~/.gtkrc-2.0

apt install trayer
# apt install trayer Set up an icon tray add to startup-hook
trayer --edge top --align right --SetDockType true --SetPartialStrut true \
--expand true --width 5 --transparent true --tint 0x191970 --height 26 &

open startup-hook add

# Use synapse as our app launcher. (-s: don't display until requested)
if [ -z "$(pgrep kupfer)" ] ; then
kupfer &
fi
Installing_xmonad on Debian 




usage


对了,这是一个几乎没有panel的桌面,所以快捷键就非常多了,下面是我常用的
xfce-terminal tab 之间是 alt+1 or 2 etc no.


打开终端窗口,按下mod + shift + return 201911 不成功


mod-enter #突出当前窗口,并提升到左边主screen

mod-shift-NUMBER: move a window to a workspace using its number

#去到另一个当前窗口
mod-j

mod-h mod-l

mod-z mod-a

mod-shift-c #closing

mod-shift-q: quits xmonad, returning to the login screen

apt-get install dmenu

http://stackoverflow.com/questions/11718196/how-to-start-using-xmonad-on-ubuntu-12-04-lts

using the “super” key as the mod key, which on many keyboards is the windows logo key

#去到另一个当前窗口
mod-j or mod-shift-tab moves your focus to the previous window

#变小
mod-l and mod-h will grow or shrink the size of the master pane.
mod-a and mod-z will grow or shrink the size of the currently focused window.

my xmonad 常用快捷键

Launching software

When you start xmonad for the first time, you’re not looking at much. You will see a status bar near the top of your screen, and that’s about it.

There are no menus for selecting programs to run. Everything is launched in one of two ways:

mod-shift-enter: launches a terminal window (Terminator). You can run other programs from the terminal.
ctrl-space:(已被我改了) launches a Synapse prompt. You can run any program by starting to type its name, and then hitting enter once Synapse has found the program you want.

*****************
Changing layouts

mod-space: cycle through the available layouts`
mod-shift-space: jump to the default layout

************
Focusing windows (#去到另一个当前窗口 写代码时,这个特别有用)
mod-j or mod-shift-tab moves your focus to the previous window
mod-k or mod-tab moves your focus to the next window
mod-m moves your focus to the master pane (see next section)
or, you can focus a window by moving your mouse cursor over it

***********
You can manipulate the contents of the master pane as follows:

mod-enter will swap the currently focused window with the contents of the master pane, making it the new master.
mod-comma will make the master pane contain more windows, if the current layout supports this.
mod-period will make the master pane contain fewer contains, if the current layout supports this.

*********************
Resizing windows
mod-l and mod-h will grow or shrink the size of the master pane.
mod-a and mod-z will grow or shrink the size of the currently focused window.

************
Closing windows

You can use mod-shift-c to close the focused window if you are done with it.

***********
Quitting or restarting xmonad

The following commands involve quitting or restarting xmonad:

mod-shift-q: quits xmonad, returning to the login screen.
mod-q: restarts and recompiles xmonad. Does not require restarting any other programs you may be running, and happens very quickly. Very useful while experimenting with changes to your xmonad.hs file!

xmonad 显示托盘


# startup-hook or 
# TRAY ICON SOFTWARE  on bsd 

#要先配置文件 哦 在bsd上
 cat  ~/.stalonetrayrc
decorations none
transparent false
dockapp_mode none
geometry 5x1-40+0
max_geometry 5x1-325-10
background "#FFFFFF"
kludges force_icons_size
grow_gravity NE
icon_gravity NE
icon_size 24
sticky true
#window_strut none
window_type dock
window_layer bottom
#no_shrink false
skip_taskbar true


然后再启动 stalonetray




stalonetray \
  --icon-gravity E \
 --geometry 5x1-0+0 \
  --max-geometry 5x1-0+0 \
  --background '#000000' \
  --skip-taskbar \
  --icon-size 24 \
  --kludges force_icons_size \
  --window-strut none \

#  这个在bsd上会被全屏盖住
#  apt install trayer  Set up an icon tray   2016-09-07pm
# trayer --edge top --align right --SetDockType true --SetPartialStrut true \
#      --expand true --width 4 --transparent true --tint 0x191970 --height 26 &













新公司要用到VPN 于是 找半天 才发现 上次升级后 xmonad的配置有些少了

apt install trayer
# apt install trayer Set up an icon tray add to startup-hook

# TRAY ICON SOFTWARE
# apt install trayer Set up an icon tray
trayer --edge top --align right --SetDockType true --SetPartialStrut true \
--expand true --width 9 --transparent true --tint 0x191970 --height 26 &

参考 https://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen’s_Configuration#Configuring_xmonad_to_use_xmobar

多显示器

窗口管理器 xmonad 教程

troubleshooting

现在上面的bar会在全屏化不见了 不方便 不过可能和win+mouse 迁移窗口下移也可以达到目的

xmobar显示中文乱码 原来是字体问题

 font = "xft:Ubuntu Mono-12",
 --font =         "xft:Bitstream Vera Sans Mono:size=14:bold:antialias=true" #这个导致乱码

Could not find module ‘XMonad’

xmonad.hs:17:1: error:
    Could not find module ‘XMonad’
    Perhaps you meant DsMonad (needs flag -package-key ghc-8.6.5)
    Use -v to see a list of the files searched for.
   |
17 | import XMonad
   | ^^^^^^^^^^^^^

xmonad.hs:18:1: error:
    Could not find module ‘XMonad.Hooks.SetWMName’
    Use -v to see a list of the files searched for.
   |
18 | import XMonad.Hooks.SetWMName
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

解决命令
evan@bsd-latop:~/.xmonad % ghc-pkg list xmonad
/usr/local/lib/ghc-8.6.5/package.conf.d
    (no packages)

evan@bsd-latop:~/.xmonad %sudo ghc-pkg recache

https://stackoverflow.com/questions/22390858/xmonad-cant-find-module-xmonad-or-any-other

xmonad.hs:349:44: warning: [-Wdeprecations]
    In the use of ‘defaultConfig’
    (imported from XMonad, but defined in XMonad.Config):
    Deprecated: "Use def (from Data.Default, and re-exported by XMonad and XMonad.Config) instead."
    |
349 |   xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig {
    |                                            ^^^^^^^^^^^^^

xmonad.hs:362:29: warning: [-Wdeprecations]
    In the use of ‘defaultConfig’
    (imported from XMonad, but defined in XMonad.Config):
    Deprecated: "Use def (from Data.Default, and re-exported by XMonad and XMonad.Config) instead."
    |
362 |   , manageHook = manageHook defaultConfig
    |                             ^^^^^^^^^^^^^

other

颜色测试

参考

https://github.com/vicfryzel/xmonad-config


xmonad a guided tour http://xmonad.org/tour.html

https://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen’s_Configuration#Configuring_xmonad_to_use_xmobar


xmonad一些常用脚本和监控显示

Using xmonad in Ubuntu

https://wiki.archlinux.org/index.php/Xmonad_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

窗口管理器 xmonad 教程

这次轮到Xmonad了

我的 xmonad 配置 https://zlb.me/2011/07/15/my-xmonad-config/

XMonad Starter Kit 平铺窗口管理器配置分享 https://ruby-china.org/topics/2357

http://lastavenger.github.io/2015/07/20/configure-of-archlinux.html

http://lastavenger.github.io/2016/03/11/thinkpad-l450.html

http://blog.csdn.net/ooaven/article/details/9002302

https://maskray.me/blog/2011-11-30-xmonad-config


dzwn2

sudo pkg install dzen2

https://github.com/pbrisbin/xmonad-config/blob/master/xmonad.hs

https://wiki.archlinux.org/index.php/Dzen

http://robm.github.io/dzen/