Skip to content

Instantly share code, notes, and snippets.

@Dnomyar
Last active April 16, 2022 20:12
Show Gist options
  • Save Dnomyar/9c289fcc2668b59e1ffb to your computer and use it in GitHub Desktop.
Save Dnomyar/9c289fcc2668b59e1ffb to your computer and use it in GitHub Desktop.
My XMonad (xmobar : battery, cpu, memory, volume, time) - ArchLinux
# ~/.bash_profile
alias subl="sublime_text"
alias l="ls -la"
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
# ~/.bashrc
exec zsh
Xcursor.theme: Vanilla-DMZ-AA
!urxvt color scheme:
URxvt*background: #2B2B2B
URxvt*foreground: #DEDEDE
!URxvt*colorUL: #86a2b0
! black
!URxvt*color0 : #2E3436
!URxvt*color8 : #555753
! red
!URxvt*color1 : #CC0000
!URxvt*color9 : #EF2929
! green
!URxvt*color2 : #4E9A06
!URxvt*color10 : #8AE234
! yellow
!URxvt*color3 : #C4A000
!URxvt*color11 : #FCE94F
! blue
!URxvt*color4 : #3465A4
!URxvt*color12 : #729FCF
! magenta
!URxvt*color5 : #75507B
!URxvt*color13 : #AD7FA8
! cyan
!URxvt*color6 : #06989A
!URxvt*color14 : #34E2E2
! white
!URxvt*color7 : #D3D7CF
!URxvt*color15 : #EEEEEC
! to match gnome-terminal "Linux console" scheme
! foreground/background
!URxvt*background: #000000
!URxvt*foreground: #ffffff
! black
URxvt.color0 : #000000
URxvt.color8 : #555555
! red
URxvt.color1 : #AA0000
URxvt.color9 : #FF5555
! green
URxvt.color2 : #00AA00
URxvt.color10 : #55FF55
! yellow
URxvt.color3 : #AA5500
URxvt.color11 : #FFFF55
! blue
URxvt.color4 : #0000AA
URxvt.color12 : #5555FF
! magenta
URxvt.color5 : #AA00AA
URxvt.color13 : #FF55FF
! cyan
URxvt.color6 : #00AAAA
URxvt.color14 : #55FFFF
! white
URxvt.color7 : #AAAAAA
!urxvt fonts:
URxvt*font: xft:Monospace:pixelsize=12
URxvt*boldFont: xft:Monospace:bold:pixelsize=12
!urxvt extensions:
URxvt.perl-ext-common: default,matcher,tabbedex
!enabling clickable links:
URxvt.urlLauncher: /usr/bin/firefox
URxvt.matcher.button: 1
!urxvt scrolling options and cursor style:
URxvt*saveLines: 12000
URxvt*scrollstyle:plain
URxvt*scrollBar: false
URxvt*cursorBlink: true
URxvt*cursorUnderline: true
! urxvt tabs settings:
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 2
URxvt.tabbed.tab-bg: 8
URxvt.tabbed.autohide: yes
URxvt.tabbed.new-button: no
URxvt.tabbed.title: no
urxvt*transparent: true
urxvt*shading: 30
# .xinitrc
# Type de curseur
xsetroot -cursor_name left_ptr
# Backgroud screen
feh --bg-scale ~/wallpepper.jpg
# Désactiver touchpad
/home/damien/.xmonad/touchpadHandler.sh
# ScreenSaver
/usr/bin/xscreensaver -no-splash &
xmonad &
xmobar &
# wait for xmonad
wait $!
pkill -HUP dzen2
pkill -HUP -f xmonad-clock
wait
-- xmobar configuration file
--
-- Mess with this file to change the appearance of the contents of the
-- status bar which are not directly controlled by xmonad. You can see your
-- changes immediately by recompiling xmonad using "super-q".
--
-- There's a lot you can do here. Refer to "man xmobar".
--
-- Author: David Brewer
-- Repository: https://github.com/davidbrewer/xmonad-ubuntu-conf
Config {
-- Set font and default foreground/background colors. Note that
-- the height of xmobar is controlled by the font you use.
font = "xft:Ubuntu Mono-8",
bgColor = "black",
fgColor = "grey",
-- Position is top left, taking up 95% of screen.
-- You are likely to have to tweak the width here based on the width
-- of your screen to make it play nicely with stalonetray, which we
-- want to be taking up the remainer of the space on the right side
-- of your screen.
position = TopW L 100,
-- list of commands which gather information about your system for
-- presentation in the bar.
commands = [
-- Gather and format CPU usage information.
-- If it's above 50%, we consider it high usage and make it red.
Run Cpu [
"-L", "3",
"-H", "50",
"--normal", "green",
"--high","red"
]
10,
Run Network "enp2s0" ["-L","0","-H","32","--normal","green","--high","red"] 10,
Run Network "wlp3s0" ["-L","0","-H","32","--normal","green","--high","red"] 10,
--Run Brightness ["-t", ""] 60,
-- Gather and format memory usage information
Run Memory [
"-t","Mem: <usedratio>%"
] 10,
-- Date formatting
--Run Date "%k:%M:%S" "date" 10,
Run DateZone "%a %d %b %Y - %H:%M:%S" "fr_FR.UTF-8" "UTC" "date" 10,
-- Battery information. This is likely to require some customization
-- based upon your specific hardware. Or, for a desktop you may want
-- to just remove this section entirely.
Run Battery [
"-t", "<acstatus>: <left>% - <timeleft>",
"--",
--"-c", "charge_full",
"-O", "AC",
"-o", "Bat",
"-h", "green",
"-l", "red"
] 10,
-- To get volume information, we run a custom bash script.
-- This is because the built-in volume support in xmobar is disabled
-- in Debian and derivatives like Ubuntu.
--Run Com "~/bin/get-volume.sh" [] "myvolume" 10,
-- /!\ https://github.com/jaor/xmobar/issues/127
Run Com "/bin/bash" ["-c", "~/.xmonad/get-volume.sh"] "myvolume" 1,
Run Com "/bin/bash" ["-c", "echo `xbacklight -get | grep -oE '^.[0-9]{0,3}'`%"] "mybright" 1,
--Run Com "~/bin/get-volume.sh" [] "vol",
--Run Com "~/bin/babbage-latency" [] "babbageLatency" 10,
--Run Com "~/bin/google-latency" [] "googleLatency" 10,
--Run Com "~/bin/hs0-latency" [] "hs0Latency" 10,
--Run Weather "KNYC" ["-t", "KNYC: <tempC>C/<skyCondition>"] 36000,
--Run Network "eth0" [] 36000,
-- This line tells xmobar to read input from stdin. That's how we
-- get the information that xmonad is sending it for display.
Run StdinReader
],
-- Separator character used to wrape variables in the xmobar template
sepChar = "%",
-- Alignment separater characer used in the xmobar template. Everything
-- before this will be aligned left, everything after aligned right.
alignSep = "}{",
-- Overall template for the layout of the xmobar contents. Note that
-- space is significant and can be used to add padding.
-- template = "%StdinReader% }{ %battery% | %cpu% | %memory% | Vol: %myvolume% <fc=#e6744c>%date%</fc> "
template = "%StdinReader% }{ %enp2s0%%wlp3s0% | %battery% | %cpu% | %memory% | %myvolume% | Lum: %mybright% | <fc=#e6744c>%date%</fc>"
}
--Config { font = "-xos4-terminus-bold-r-normal--20-*-*-*-*-*-iso10646-1"
-- , bgColor = "black"
-- , fgColor = "grey"
-- , position = TopW L 100
-- , lowerOnStart = True
-- , commands = [ Run Weather "LFRS" ["-t","<station>: <tempC>C / <rh>%","-L","18","-H","25","--normal","#00CC00","--high","#CC0000","--low","lightblue"] 36000
-- , Run Network "eth0" ["-L","0","-H","32","--normal","#00CC00","--high","#CC0000"] 10
-- , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
-- , Run Memory ["-t","Mem: <usedratio>%"] 10
-- , Run Battery ["-t","<timeleft>","-L","50","-H","75","-h","green","-n","yell","-l","red"] 10
-- --, Run Battery ["--", "-c", "energy_full"] 30
-- , Run Date "%k:%M:%S" "date" 10
-- , Run Com "date" ["+'%a %d %b'"] "mydate" 600
-- --, Run StdinReader
-- ]
-- , sepChar = "%"
-- , alignSep = "}{"
-- , template = " Hi Damien ! How are you today ?}{ | %cpu% | %memory% | <fc=#ee9a00>%date% %mydate%</fc>"
-- }
---- , Run Date "%a %d %b %Y %H:%M:%S" "date" 10
---- <fc=#00cc00>%date%</fc>
-- ~/.xsession
xss-lock -- xscreensaver-command -lock &
xmonad
#/bin/shell
# Created by newuser for 5.0.7
# function untargz {
# tar xzvf "$@"
# }
# https://github.com/rpellerin/dotfiles/blob/master/.aliases
# Extract any archive
function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Open a file with the appropriate application
function open {
while [ "$1" ] ; do
xdg-open $1 &> /dev/null
shift # shift décale les param
done
}
# A reminder
function githelp {
echo "-------------------------------------------------------------------------------"
echo "git clone http://... [repo-name]"
echo "git init [repo-name]"
echo "-------------------------------------------------------------------------------"
echo "git add -A <==> git add . ; git add -u # Add to the staging area (index)"
echo "-------------------------------------------------------------------------------"
echo "git commit -m 'message' -a"
echo "git commit -m 'message' -a --amend"
echo "-------------------------------------------------------------------------------"
echo "git status"
echo "git log --stat # Last commits, --stat optional"
echo "git ls-files"
echo "git diff HEAD~1..HEAD"
echo "-------------------------------------------------------------------------------"
echo "git push origin master"
echo "git push origin master:master"
echo "-------------------------------------------------------------------------------"
echo "git remote add origin http://..."
echo "git remote set-url origin git://..."
echo "-------------------------------------------------------------------------------"
echo "git stash"
echo "git pull origin master"
echo "git stash list ; git stash pop"
echo "-------------------------------------------------------------------------------"
echo "git submodule add /absolute/path repo-name"
echo "git submodule add http://... repo-name"
echo "-------------------------------------------------------------------------------"
echo "git checkout -b new-branch <==> git branch new-branch ; git checkout new-branch"
echo "git merge old-branch"
echo "git branch local_name origin/remote_name # Associate branches"
echo "-------------------------------------------------------------------------------"
echo "git update-index --assume-unchanged <file> # Ignore changes"
echo "git rm --cached <file> # Untrack a file"
echo "-------------------------------------------------------------------------------"
echo "git reset --hard HEAD # Repair what has been done since last commit"
echo "git revert HEAD # Repair last commit"
echo "git checkout [file] # Reset a file to its previous state at last commit"
echo "-------------------------------------------------------------------------------"
echo "git tag # List"
echo "git tag v0.5 # Lightwieght tag"
echo "git tag -a v1.4 -m 'my version 1.4' # Annotated tag"
echo "git push origin v1.4 # Pushing"
echo "-------------------------------------------------------------------------------"
echo "HOW TO RENAME A BRANCH LOCALLY AND REMOTELY"
echo "git branch -m old_name new_name"
echo "git push origin new_name"
echo "git push origin :old_name"
echo "------"
echo "Each other client of the repository has to do:"
echo "git fetch origin ; git remote prune origin"
echo "-------------------------------------------------------------------------------"
}
# Alias
alias ls='ls --color=auto'
alias l="ls --color=auto -la"
alias grep='grep -i --color=auto'
alias rm='rm --interactive --verbose'
alias mv='mv --interactive --verbose'
alias cp='cp --verbose'
# bindkey '~' beginning-of-line # Home (console)
# bindkey '9~' '~' # Home (console)
domain=$(cat /etc/resolv.conf | grep domain)
if [[ "$domain" = "domain ca.cite-u.univ-nantes.prive" ]]; then
source ~/proxy/citeu.sh
echo ">>> Cité U proxy environment"
fi
search=$(cat /etc/resolv.conf | grep search)
if [[ "$search" = "search jof.wifi.univ-nantes.prive" ]]; then
source ~/proxy/iut-wifi.sh
echo ">>> IUT wifi proxy environment"
fi
UTILISATEUR=%n
# THIS_DIRECTORY=%~
THIS_DIRECTORY=%c
PROMPT="${UTILISATEUR} | ${THIS_DIRECTORY} $ "
# ~/bin/get-volume.sh
#!/bin/bash
# Get the maximum volume of any pulseaudio sink channel
# amixer get Master | egrep -o "[0-9]+%"
vol=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "MM" } else { print $2 }}' | head -n 1)
echo Vol: $vol%
exit 0
--~/.xmonad/touchpadHandler.sh
TOUCHPAD=$(echo `synclient -l | grep TouchpadOff` | grep -o "[0-1]")
if [[ "$TOUCHPAD" == "1" ]]; then
synclient TouchpadOff=0
# echo "on"
else
synclient TouchpadOff=1
# echo "off"
fi
--https://gist.github.com/maxbane/9521612#file-xmonad-hs-L43
import XMonad
import Graphics.X11.ExtraTypes.XF86
import XMonad.Util.EZConfig
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.NoBorders
import XMonad.Layout.Circle
import XMonad.Layout.Grid
import XMonad.Layout.ResizableTile
import XMonad.Layout.ThreeColumns
-- import XMonad.Layout.Fullscreen
import XMonad.Layout.Gaps
import Data.Monoid
import System.Exit
import XMonad.Util.Run
import System.IO
import Control.Monad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Actions.CycleWS
-- See https://github.com/davidbrewer/xmonad-ubuntu-conf
-- Width of the window border in pixels.
--
myBorderWidth = 0
--
myWorkspaces = ["web", "code", "irc"] ++ map show [4..9]
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
[
((modm, xK_Left), prevWS)
, ((modm, xK_Right), nextWS)
--, ("<Next>", spawn "xbacklight -10")
-- , ((modm, xF86XK_MonBrightnessDown) spawn "xbacklight +10")
--, ((mod4Mask, xK_Right), spawn "amixer set Master 5%- unmute &")
--, ((mod4Mask, xK_Left), spawn "amixer set Master 5%+ unmute &")
]
--myKeys =
-- -- volume key binding
-- [
-- ("<XF86MonBrightnessDown>", spawn "xbacklight -10")
-- , ("M-<Left>", prevWS)
-- , ("M-<Right>", nextWS)
-- --, ("<XF86AudioLowerVolume>", spawn "aumix2pipe -10")
-- ]
newKeys x = myKeys x `M.union` keys defaultConfig x
-- The main function.
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig
-- Command to launch the bar.
myBar = "xmobar"
{-
Xmobar configuration variables. These settings control the appearance
of text which xmonad is sending to xmobar via the DynamicLog hook.
-}
myTitleColor = "#eeeeee" -- color of window title
myTitleLength = 80 -- truncate window title to this length
myCurrentWSColor = "#e6744c" -- color of active workspace
myVisibleWSColor = "#c185a7" -- color of inactive workspace
myUrgentWSColor = "#cc0000" -- color of workspace with 'urgent' window
myCurrentWSLeft = "[" -- wrap active workspace with these
myCurrentWSRight = "]"
myVisibleWSLeft = "(" -- wrap inactive workspace with these
myVisibleWSRight = ")"
myUrgentWSLeft = "{" -- wrap urgent workspace with these
myUrgentWSRight = "}"
-- Custom PP, configure it as you like. It determines what is being written to the bar.
myPP = xmobarPP {
-- ppCurrent = xmobarColor "#429942" "" . wrap "<" ">"
ppTitle = xmobarColor myTitleColor "" . shorten myTitleLength
, ppCurrent = xmobarColor myCurrentWSColor ""
. wrap myCurrentWSLeft myCurrentWSRight
, ppVisible = xmobarColor myVisibleWSColor ""
. wrap myVisibleWSLeft myVisibleWSRight
, ppUrgent = xmobarColor myUrgentWSColor ""
. wrap myUrgentWSLeft myUrgentWSRight
}
-- Key binding to toggle the gap for the bar.
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
-- http://www.nepherte.be/step-by-step-configuration-of-xmonad/
myManageHook = composeAll . concat $
[
-- Applications that go to web
[ className =? "Firefox" --> viewShift "web"]
, [ className =? "Sublime_text" --> viewShift "code"]
]
where
viewShift = doF . liftM2 (.) W.greedyView W.shift
-- Define default layouts used on most workspaces
defaultLayouts = smartBorders(avoidStruts(
ResizableTall 1 (3/100) (1/2) []
-- ||| Mirror (ResizableTall 1 (3/100) (1/2) [])
||| noBorders Full
-- ||| Grid
||| ThreeColMid 1 (3/100) (3/4)
-- ||| Circle
))
-- Define layout for specific workspaces
webLayout = noBorders $ Full
-- Put all layouts together
--myLayouts = onWorkspace "web" webLayout $ defaultLayouts
-- Main configuration, override the defaults to your liking.
myConfig = defaultConfig {
modMask = mod1Mask,
--terminal = "xterm -bg black -fg gray -fa \"Ubuntu Mono\" -fs 12 -e '/usr/bin/env -u TMUX tmux -2'",
terminal = "urxvt",
borderWidth = myBorderWidth,
workspaces = myWorkspaces,
keys = newKeys,
manageHook = myManageHook,
handleEventHook = fullscreenEventHook
-- border colors from solarized dark palette
--focusedBorderColor = "#268bd2",
--normalBorderColor = "#586e75",
--layoutHook = myLayouts
-- manageHook = composeAll [
-- className =? "Gimp" --> doFloat,
-- className =? "MPlayer" --> doFloat,
-- isFullscreen --> doFullFloat
-- ]
}
`additionalKeys`
[
--((mod4Mask, xK_R), spawn "amixer set Master 5- unmute")
--, ((mod4Mask, xK_L), spawn "amixer set Master 5+ unmute")
---- XF86XK_AudioLowerVolume
((mod1Mask .|. shiftMask, xK_Left), spawn "amixer set Master 2- unmute")
---- XF86XK_AudioRaiseVolume
, ((mod1Mask .|. shiftMask, xK_Right), spawn "amixer set Master 2+ unmute")
, ((mod1Mask .|. shiftMask, xK_Up), spawn "xbacklight -inc 5")
, ((mod1Mask .|. shiftMask, xK_Down), spawn "xbacklight -dec 5")
--, ((mod4Mask, xK_l), spawn "systemctl suspend")
, ((mod4Mask, xK_l), spawn "xscreensaver-command --lock")
, ((mod4Mask, xK_t), spawn "./.xmonad/touchpadHandler.sh")
, ((mod4Mask, xK_f), spawn "firefox &")
, ((mod4Mask, xK_s), spawn "sublime_text &")
, ((mod4Mask .|. shiftMask, xK_q), spawn "systemctl poweroff")
-- Pas très fonctionnel
, ((mod4Mask, xK_c), spawn "source ~/proxy/citeu.sh")
, ((mod4Mask, xK_m), spawn "source ~/proxy/maison.sh")
, ((mod4Mask, xK_i), spawn "source ~/proxy/iut.sh")
--((0x0, 122), spawn "amixer set Master 2- unmute")
--, ((0x0, 123), spawn "amixer set Master 2+ unmute")
--, ((0x0, 232), spawn "xbacklight -inc 40000")
--, ((0x0, 233), spawn "xbacklight -dec 40000")
--((0, 0x1008FF11), spawn "amixer set Master 2-"),
--((0, 0x1008FF13), spawn "amixer set Master 2+"),
--, ((mod1Mask, Next), spawn "xbacklight -10")
--, ((mod1Mask, XF86MonBrightnessDown), spawn "xbacklight +10")
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment