diff options
Diffstat (limited to 'config/X/xmonad')
| -rwxr-xr-x | config/X/xmonad/autostart/.cyclepaper.sh | 19 | ||||
| -rwxr-xr-x | config/X/xmonad/autostart/autostart.sh | 10 | ||||
| -rwxr-xr-x | config/X/xmonad/autostart/fehbg.sh | 2 | ||||
| -rwxr-xr-x | config/X/xmonad/autostart/getvolume.sh | 20 | ||||
| -rwxr-xr-x | config/X/xmonad/autostart/yt-not.sh | 63 | ||||
| -rwxr-xr-x | config/X/xmonad/xmonad.disabled/autostart/.cyclepaper.sh | 19 | ||||
| -rwxr-xr-x | config/X/xmonad/xmonad.disabled/autostart/autostart.sh | 10 | ||||
| -rwxr-xr-x | config/X/xmonad/xmonad.disabled/autostart/fehbg.sh | 2 | ||||
| -rwxr-xr-x | config/X/xmonad/xmonad.disabled/autostart/getvolume.sh | 20 | ||||
| -rwxr-xr-x | config/X/xmonad/xmonad.disabled/autostart/yt-not.sh | 63 | ||||
| -rw-r--r-- | config/X/xmonad/xmonad.disabled/xmonad.hs | 344 | ||||
| -rw-r--r-- | config/X/xmonad/xmonad.hs | 344 | 
12 files changed, 916 insertions, 0 deletions
diff --git a/config/X/xmonad/autostart/.cyclepaper.sh b/config/X/xmonad/autostart/.cyclepaper.sh new file mode 100755 index 0000000..fb07bc9 --- /dev/null +++ b/config/X/xmonad/autostart/.cyclepaper.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +wallpaper_dir="$HOME/Pictures/Wallpapers/nord" + +interval="15m" + +wallpapers=($(ls $wallpaper_dir)) +wp_count=${#wallpapers[@]} +i=0 + +while true; do +    feh --bg-scale $wallpaper_dir/${wallpapers[$i]} +    ((i++)) +    if [ $i -eq $wp_count ] +    then +        i=0 +    fi +    sleep $interval +done diff --git a/config/X/xmonad/autostart/autostart.sh b/config/X/xmonad/autostart/autostart.sh new file mode 100755 index 0000000..c9d75ae --- /dev/null +++ b/config/X/xmonad/autostart/autostart.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +cd $HOME/.config/xmonad/autostart/ +for script in *.sh +do +    if [ "./$script" != "$0" ] && [ -z "$(ps aux | grep "$script" | head -n -1)" ]  +    then +        echo "started $script" +        setsid ./$script & +    fi +done diff --git a/config/X/xmonad/autostart/fehbg.sh b/config/X/xmonad/autostart/fehbg.sh new file mode 100755 index 0000000..4b65f3a --- /dev/null +++ b/config/X/xmonad/autostart/fehbg.sh @@ -0,0 +1,2 @@ +#!/bin/sh +feh --no-fehbg --bg-scale "$HOME/pictures/Wallpapers/nord/nord_background3.jpg"  diff --git a/config/X/xmonad/autostart/getvolume.sh b/config/X/xmonad/autostart/getvolume.sh new file mode 100755 index 0000000..ee2509e --- /dev/null +++ b/config/X/xmonad/autostart/getvolume.sh @@ -0,0 +1,20 @@ +#!/bin/bash +while true +do +    string=$(pamixer --get-volume) +    muted=$(pamixer --get-mute) +    if [[ "$muted" == "true" ]]  +    then +      icon="<fn=1></fn>" +    elif [ $string -gt 49 ] +    then +      icon="<fn=1></fn>" +    elif [ $string -eq 0 ] +    then +      icon="<fn=1></fn>" +    elif [ $string -lt 50 ] +    then +      icon="<fn=1></fn>" +    fi +    echo "${string}% $icon" > $HOME/.config/xmobar/scripts/volume-pipe +done diff --git a/config/X/xmonad/autostart/yt-not.sh b/config/X/xmonad/autostart/yt-not.sh new file mode 100755 index 0000000..a68f0c3 --- /dev/null +++ b/config/X/xmonad/autostart/yt-not.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +ytnotdir="$HOME/.local/share/yt-not" + +get_notification() +{ + +    cat "${ytnotdir}/channels.yt-not" | \ +    while read line +    do +        channelId="$(echo "$line" | awk '{print $1}')" +        ch_name="$(echo "$line" | awk '{print $2}')" +        pre_vId="$(echo "$line" | awk '{print $3}')" +        # Get last vid from xml feed +        new_vId="$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}" | sed '/videoId/!d;s/^.*>\(.*\)<.*$/\1/g' | head -n1)" +        if [ "$new_vId" != "$pre_vId" ] +        then +            dunstify "yt-notify" "NEW VID!! from\n${ch_name}" +            newline=$(echo "$line" | sed "s/$pre_vId/$new_vId/") +            sed -i "s/$line/$newline/" "${ytnotdir}/channels.yt-not" +        fi +    done +} + +# Two valid formats: +# 1: @channel +# 2: channelId @channel videoId +parse_channels() +{ +    cat "${ytnotdir}/channels.yt-not" | \ +    while read line +        do  +            # First word of line is channelId or channelTag +            chidot="$(echo "$line" | awk '{print $1}')" +            # Tags start with @ +            if [ "${chidot::1}" == "@" ]  +            then +                # channel tag -> channelId +                channelId="$(curl -s "https://www.youtube.com/${chidot}" | pup 'meta[itemprop="channelId"] attr{content}')" +                sed -i "s/${chidot}/${channelId} ${chidot} novideo/" "${ytnotdir}/channels.yt-not" +            fi +        done +} + +main() +{ +    mkdir -p "${ytnotdir}" +    if [ ! -f "${ytnotdir}/channels.yt-not" ] +    then +        echo "@bugswriter_" > "${ytnotdir}/channels.yt-not" +        echo "@DistroTube" >> "${ytnotdir}/channels.yt-not" +        echo "@MentalOutlaw" >> "${ytnotdir}/channels.yt-not" +        echo "@Fireship" >> "${ytnotdir}/channels.yt-not" +    fi + +    while true +    do +        sleep 15m +        parse_channels +        get_notification +    done +} + +main diff --git a/config/X/xmonad/xmonad.disabled/autostart/.cyclepaper.sh b/config/X/xmonad/xmonad.disabled/autostart/.cyclepaper.sh new file mode 100755 index 0000000..fb07bc9 --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/autostart/.cyclepaper.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +wallpaper_dir="$HOME/Pictures/Wallpapers/nord" + +interval="15m" + +wallpapers=($(ls $wallpaper_dir)) +wp_count=${#wallpapers[@]} +i=0 + +while true; do +    feh --bg-scale $wallpaper_dir/${wallpapers[$i]} +    ((i++)) +    if [ $i -eq $wp_count ] +    then +        i=0 +    fi +    sleep $interval +done diff --git a/config/X/xmonad/xmonad.disabled/autostart/autostart.sh b/config/X/xmonad/xmonad.disabled/autostart/autostart.sh new file mode 100755 index 0000000..c9d75ae --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/autostart/autostart.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +cd $HOME/.config/xmonad/autostart/ +for script in *.sh +do +    if [ "./$script" != "$0" ] && [ -z "$(ps aux | grep "$script" | head -n -1)" ]  +    then +        echo "started $script" +        setsid ./$script & +    fi +done diff --git a/config/X/xmonad/xmonad.disabled/autostart/fehbg.sh b/config/X/xmonad/xmonad.disabled/autostart/fehbg.sh new file mode 100755 index 0000000..4b65f3a --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/autostart/fehbg.sh @@ -0,0 +1,2 @@ +#!/bin/sh +feh --no-fehbg --bg-scale "$HOME/pictures/Wallpapers/nord/nord_background3.jpg"  diff --git a/config/X/xmonad/xmonad.disabled/autostart/getvolume.sh b/config/X/xmonad/xmonad.disabled/autostart/getvolume.sh new file mode 100755 index 0000000..ee2509e --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/autostart/getvolume.sh @@ -0,0 +1,20 @@ +#!/bin/bash +while true +do +    string=$(pamixer --get-volume) +    muted=$(pamixer --get-mute) +    if [[ "$muted" == "true" ]]  +    then +      icon="<fn=1></fn>" +    elif [ $string -gt 49 ] +    then +      icon="<fn=1></fn>" +    elif [ $string -eq 0 ] +    then +      icon="<fn=1></fn>" +    elif [ $string -lt 50 ] +    then +      icon="<fn=1></fn>" +    fi +    echo "${string}% $icon" > $HOME/.config/xmobar/scripts/volume-pipe +done diff --git a/config/X/xmonad/xmonad.disabled/autostart/yt-not.sh b/config/X/xmonad/xmonad.disabled/autostart/yt-not.sh new file mode 100755 index 0000000..a68f0c3 --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/autostart/yt-not.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +ytnotdir="$HOME/.local/share/yt-not" + +get_notification() +{ + +    cat "${ytnotdir}/channels.yt-not" | \ +    while read line +    do +        channelId="$(echo "$line" | awk '{print $1}')" +        ch_name="$(echo "$line" | awk '{print $2}')" +        pre_vId="$(echo "$line" | awk '{print $3}')" +        # Get last vid from xml feed +        new_vId="$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}" | sed '/videoId/!d;s/^.*>\(.*\)<.*$/\1/g' | head -n1)" +        if [ "$new_vId" != "$pre_vId" ] +        then +            dunstify "yt-notify" "NEW VID!! from\n${ch_name}" +            newline=$(echo "$line" | sed "s/$pre_vId/$new_vId/") +            sed -i "s/$line/$newline/" "${ytnotdir}/channels.yt-not" +        fi +    done +} + +# Two valid formats: +# 1: @channel +# 2: channelId @channel videoId +parse_channels() +{ +    cat "${ytnotdir}/channels.yt-not" | \ +    while read line +        do  +            # First word of line is channelId or channelTag +            chidot="$(echo "$line" | awk '{print $1}')" +            # Tags start with @ +            if [ "${chidot::1}" == "@" ]  +            then +                # channel tag -> channelId +                channelId="$(curl -s "https://www.youtube.com/${chidot}" | pup 'meta[itemprop="channelId"] attr{content}')" +                sed -i "s/${chidot}/${channelId} ${chidot} novideo/" "${ytnotdir}/channels.yt-not" +            fi +        done +} + +main() +{ +    mkdir -p "${ytnotdir}" +    if [ ! -f "${ytnotdir}/channels.yt-not" ] +    then +        echo "@bugswriter_" > "${ytnotdir}/channels.yt-not" +        echo "@DistroTube" >> "${ytnotdir}/channels.yt-not" +        echo "@MentalOutlaw" >> "${ytnotdir}/channels.yt-not" +        echo "@Fireship" >> "${ytnotdir}/channels.yt-not" +    fi + +    while true +    do +        sleep 15m +        parse_channels +        get_notification +    done +} + +main diff --git a/config/X/xmonad/xmonad.disabled/xmonad.hs b/config/X/xmonad/xmonad.disabled/xmonad.hs new file mode 100644 index 0000000..e72957b --- /dev/null +++ b/config/X/xmonad/xmonad.disabled/xmonad.hs @@ -0,0 +1,344 @@ +import XMonad + +-- Actions +import qualified XMonad.Actions.CycleWS as CWS +import XMonad.Actions.NoBorders +import XMonad.Actions.SpawnOn + +-- Hooks +import XMonad.Hooks.DynamicLog (dynamicLogWithPP, filterOutWsPP, wrap, xmobarPP, xmobarColor, shorten, shorten', shortenLeft', PP(..)) +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageHelpers +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat) +import XMonad.Hooks.SetWMName +import XMonad.Hooks.StatusBar +import XMonad.Hooks.StatusBar.PP (xmobarFont) +import XMonad.Hooks.WorkspaceHistory + +import XMonad.Layout.Gaps +import XMonad.Layout.PerWorkspace +import XMonad.Layout.NoBorders +import XMonad.Layout.Spacing +import XMonad.Layout.Spiral + +import qualified XMonad.StackSet as W +-- import XMonad.EZConfig (AddAdditionalKeysP) + +-- Utils +import XMonad.Util.Cursor +import XMonad.Util.Dmenu +import XMonad.Util.EZConfig (additionalKeysP) +import XMonad.Util.NamedScratchpad +import XMonad.Util.Run +import XMonad.Util.SpawnOnce + +-- Data +import Data.Maybe (fromJust) +import Data.Monoid +import qualified Data.Map        as M + +import System.Exit +import System.IO + +-- Variables +-- +-- Default Terminal +myTerminal :: String +myTerminal = "alacritty" + +-- Whether focus follows the mouse pointer. +myFocusFollowsMouse :: Bool +myFocusFollowsMouse = True + +-- Whether clicking on a window to focus also passes the click to the window +myClickJustFocuses :: Bool +myClickJustFocuses = True + +-- Width of the window border in pixels. +-- +myBorderWidth = 2 + +myModMask = mod4Mask + +-- myScratchPads :: [NamedScratchpad] +-- myScratchPads = [ NS "terminal" "kitty" (title =? "getScratched") defaultFloating ] +-- +-- Workspaces +myWorkspaces = ["cab","web","lab","ser","gfx","idi","gam","muz","cha","hid"] +colorbg = "#2e3440" +colorfg = "#eceff4" + +color01 = "#5e8bac" +color02 = "#b48ead" +color04 = "#ebcb8b" +color05 = "#81a1c1" +color09 = "#4c566a" +color17 = "#d03a3f" + +leftwp = "<box type=Bottom width=2 mb=2 color=" ++ colorfg ++ ">" +rightwp = "</box>" + +-- Count of window in active workspace +windowCount :: X (Maybe String) +windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset + +------ COLORS + +-- Border colors for unfocused and focused windows, respectively. +myNormalBorderColor  = color09 +myFocusedBorderColor = color05 + +------------------------------------------------------------------------ +-- Key bindings. Add, modify or remove key bindings here. +myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ + +    -- +    -- mod-[1..9], Switch to workspace N +    -- mod-shift-[1..9], Move client to workspace N +    -- +    [((m .|. modm, k), windows $ f i) +        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] +        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] +    ++ +    -- +    -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 +    -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 +    -- +    [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) +        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] +        -- | (key, sc) <- zip [xK_e, xK_w, xK_r] [0..] +        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] + +------------------------------------------------------------------------ +-- Mouse bindings: default actions bound to mouse events +-- +myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ + +    -- mod-button1, Set the window to floating mode and move by dragging +    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w +                                       >> windows W.shiftMaster)) +    -- mod-button2, Raise the window to the top of the stack +    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster)) +    -- mod-button3, Set the window to floating mode and resize by dragging +    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w +                                       >> windows W.shiftMaster)) +    -- you may also bind events to the mouse scroll wheel (button4 and button5) +    ] + +------------------------------------------------------------------------ +-- Layouts: +myLayoutPrinter :: String -> String +myLayoutPrinter "Spacing Tall" = xmobarColor colorfg colorbg "til" +myLayoutPrinter "Spacing Mirror Tall" = xmobarColor colorfg colorbg "mti" +myLayoutPrinter "Spacing Spiral" = xmobarColor colorfg colorbg "fib" +myLayoutPrinter "Spacing Full" = xmobarColor colorfg colorbg "ful" +myLayoutPrinter x = xmobarColor colorfg colorbg x + +myLayout = +    onWorkspace "gam" Full $ +    avoidStruts(gaps [(L,3), (D,3), (U,3), (R,3)] $ smartSpacing 2 $ tiled ||| Mirror tiled ||| fib ||| Full) +    where +        -- default tiling algorithm partitions the screen into two panes +        tiled   = Tall nmaster delta ratio +        -- The default number of windows in the master pane +        nmaster = 1 +        -- Default proportion of screen occupied by master pane +        ratio   = 2/5 +        -- Percent of screen to increment by when resizing panes +        delta   = 3/100 + +        fib     = spiral (6/7) +   + +------------------------------------------------------------------------ +-- Window rules: + +myManageHook = composeAll +    [  +    -- className =? "Gimp"           --> doFloat +    -- , className =? "Tilp"           --> doFloat +    -- , resource  =? "desktop_window" --> doIgnore +    -- , resource  =? "kdesktop"       --> doIgnore +    -- +    className =? "discord" --> doShift "cha", +    className =? "Steam" --> doShift "gam" +    ] +-- <+> namedScratchpadManageHook myScratchPads + + +------------------------------------------------------------------------ +-- Startup hook +myStartupHook = do + +    setWMName "XMonad" + +    setDefaultCursor xC_arrow + +    spawnOnce "checkupdates | wc -l > /tmp/updates.tmp" +    spawnOnce "systemctl --user restart redshift.service" +    spawnOnce "unclutter --timeout 3 --jitter 50 -b" +    spawnOnce "numlockx" +    spawnOnce "$HOME/.config/xmonad/autostart/autostart.sh" + +------------------------------------------------------------------------ +-- Now run xmonad with all the defaults we set up. + +-- Run xmonad with the settings you specify. No need to modify this. +-- +main = do +    -- Setup xmobar as docks +    -- +    xmproc0 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc0.hs" +    xmproc1 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc1.hs" + +    -- ewmh: Add fullscreen handling support +    xmonad $ docks . ewmh $ defaults { +        layoutHook = avoidStruts $ layoutHook defaults +        , logHook = dynamicLogWithPP $ filterOutWsPP ["hid"] $ xmobarPP {  +             ppOutput = \x  -> hPutStrLn xmproc0 x + +            , ppCurrent = xmobarColor colorfg colorbg . wrap leftwp rightwp -- Visible but not current workspace +            , ppVisible = xmobarColor colorfg colorbg -- Hidden workspace +            , ppHidden = xmobarColor color01 colorbg -- Hidden workspaces (no windows) +            , ppHiddenNoWindows = xmobarColor color04 colorbg -- Title of active window +            , ppTitle = xmobarColor "" "" . shorten' "" 0 -- Separator character +            , ppSep =  "  " +            , ppLayout = myLayoutPrinter +              -- Urgent workspace , ppUrgent = xmobarColor color17 colorbg . wrap "!" "!" +            , ppExtras  = [windowCount] -- Adding # of windows on current workspace to the bar +        } + +} + + +defaults = ewmh def { +      -- simple stuff +        terminal           = myTerminal, +        focusFollowsMouse  = myFocusFollowsMouse, +        clickJustFocuses   = myClickJustFocuses, +        borderWidth        = myBorderWidth, +        modMask            = myModMask, +        workspaces         = myWorkspaces, +        normalBorderColor  = myNormalBorderColor, +        focusedBorderColor = myFocusedBorderColor, + +      -- key bindings +        keys               = myKeys, +        mouseBindings      = myMouseBindings, + +      -- hooks, layouts +        layoutHook         = myLayout, +        manageHook         = myManageHook <+> manageSpawn, +        startupHook        = myStartupHook +        } +        `additionalKeysP` +        [ ("M-<Return>", spawn myTerminal) +        , ("M-<Backspace>", withFocused hide) -- N.B. this is an absurd thing to do +        , ("M-0", windows $ W.greedyView $ "hid") -- N.B. this is an absurd thing to do +        , ("M-u",       incScreenWindowSpacing (2)) +        , ("M-i",       incScreenWindowSpacing (-2)) +        , ("M-o",       setScreenWindowSpacing (2)) +        -- Then these key bindings +        -- cycling worspaces +        , ("M-<R>",     CWS.nextWS) +        , ("M-<L>",     CWS.prevWS) +        , ("M-S-<R>",   CWS.shiftToNext >> CWS.nextWS) +        , ("M-S-<L>",   CWS.shiftToPrev >> CWS.prevWS) +        , ("M-m",       spawn "emacs") +        -- launch firefox +        , ("M-b",       spawn "firefox") +        -- take screenshots +        , ("M-s",       spawn "maim ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png") +        , ("M-C-s",   spawn "maim -i $(xdotool getactivewindow) ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png") +        , ("M-S-s",     spawn "maim --select | xclip -selection clipboard -t image/png") +        -- close focused window +        , ("M-c",       spawn "kill $(xprop | grep PID | cut -d = -f 2)") +        , ("M-S-c",     kill) +         -- Rotate through the available layout algorithms +        , ("M-C-1", sendMessage $ JumpToLayout "Tall") +        , ("M-C-2", sendMessage $ JumpToLayout "Mirror Tall") +        , ("M-C-3", sendMessage $ JumpToLayout "Spiral") +        , ("M-C-4", sendMessage $ JumpToLayout "Full") +        , ("M-<Tab>", sendMessage NextLayout) + +        , ("M-<Space>", spawn "cycleKB") +        -- Resize viewed windows to the correct size +        , ("M-n",       refresh)  +        -- Move focus to the next window +        , ("M-j",       windows W.focusDown) +        -- Move focus to the previous window +        , ("M-k",       windows W.focusUp)  +        -- Swap the focused window with the next window +        , ("M-S-j",     windows W.swapDown)  +        -- Swap the focused window with the previous window +        , ("M-S-k",     windows W.swapUp)  +        -- Shrink the master area +        , ("M-h",       sendMessage Shrink)  +        -- Expand the master area +        , ("M-l",       sendMessage Expand)  +        -- Push window back into tiling +        , ("M-S-t",     withFocused $ windows . W.sink)  +    -- Increment the number of windows in the master area +        , ("M-,",       sendMessage (IncMasterN 1))  +        -- Deincrement the number of windows in the master area +        , ("M-.",       sendMessage (IncMasterN (-1)))  +        -- Quit xmonad +        , ("M-S-q",     io (exitWith ExitSuccess))  +        -- Restart xmonad +        , ("M-q",       spawn "killall xmobar; xmonad --recompile && xmonad --restart")  +        , ("M-x m",       spawn "kill -USR1 $(pgrep xmobar)")  +        -- open alsamixer and change volume with keyboard wheel +        , ("<XF86AudioLowerVolume>" , spawn "pamixer -d 5") +        , ("<XF86AudioRaiseVolume>" , spawn "pamixer -i 5") +        , ("<XF86AudioMute>"        , spawn "pamixer -t") +        , ("<XF86MonBrightnessDown>", spawn "light -U 5") +        , ("<XF86MonBrightnessUp>"  , spawn "light -A 5") +        , ("M-y" , spawn "arr_hjkl") +        -- Toggle borders +        , ("M-S-b", do +            withFocused toggleBorder +            refresh) +        -- Fullscreen by toggling borders, +        -- struts so docks can be obfuscated +        -- (forcing it into tiling, because problems if you change layouts) +        , ("M-S-f", do +            sendMessage ToggleStruts +            sendMessage ToggleGaps +            toggleWindowSpacingEnabled +            withFocused toggleBorder +            refresh) +         +        , ("M-a c" , spawn "code") +        , ("M-a d" , spawnOn "cha" "discord") +        , ("M-a s" , spawnOn "cha" "signal-desktop") +        , ("M-a k" , spawn "virt-manager") +        , ("M-a m" , spawn "mumble") +        , ("M-a v" , spawn "virtualbox") +        -- file managers +        , ("M-f k", spawn ("kitty" ++ " -e ranger")) +        , ("M-f d", spawn "dolphin") + + +        -- cycle keyboards +        -- dmenu +        , ("M-S-<Return>", spawn "dmenu_run") +        , ("M-p a", spawn "dmapimg") +        , ("M-<Insert>", spawn "dmpsbm") +        , ("M-S-<Insert>", spawn "dmpsclip") +        , ("M-p c", spawn "dmclip") +        , ("M-p d", spawn "dmdsktp") +        , ("M-p f", spawn "dmfm") +        , ("M-p g", spawn "passgen") +        , ("M-p h", spawn "dmhelp") +        , ("M-p l", spawn "dmlang") +        , ("M-p m", spawn "passmenu") +        -- , ("M-p S-m", spawn "passmenu --type") +        , ("M-p p", spawn "dmpdf") +        , ("M-p o", spawn "dmpower") +        , ("M-p v", spawn "dmvid") + +        -- Gaming +        , ("M-g s", spawnOn "gam" "steam") +        , ("M-g m", spawnOn "gam" "multimc -l 1.8.9") +        ] diff --git a/config/X/xmonad/xmonad.hs b/config/X/xmonad/xmonad.hs new file mode 100644 index 0000000..c6cf44b --- /dev/null +++ b/config/X/xmonad/xmonad.hs @@ -0,0 +1,344 @@ +import XMonad + +-- Actions +import qualified XMonad.Actions.CycleWS as CWS +import XMonad.Actions.NoBorders +import XMonad.Actions.SpawnOn + +-- Hooks +import XMonad.Hooks.DynamicLog (dynamicLogWithPP, filterOutWsPP, wrap, xmobarPP, xmobarColor, shorten, shorten', shortenLeft', PP(..)) +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageHelpers +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat) +import XMonad.Hooks.SetWMName +import XMonad.Hooks.StatusBar +import XMonad.Hooks.StatusBar.PP (xmobarFont) +import XMonad.Hooks.WorkspaceHistory + +import XMonad.Layout.Gaps +import XMonad.Layout.PerWorkspace +import XMonad.Layout.NoBorders +import XMonad.Layout.Spacing +import XMonad.Layout.Spiral + +import qualified XMonad.StackSet as W +-- import XMonad.EZConfig (AddAdditionalKeysP) + +-- Utils +import XMonad.Util.Cursor +import XMonad.Util.Dmenu +import XMonad.Util.EZConfig (additionalKeysP) +import XMonad.Util.NamedScratchpad +import XMonad.Util.Run +import XMonad.Util.SpawnOnce + +-- Data +import Data.Maybe (fromJust) +import Data.Monoid +import qualified Data.Map        as M + +import System.Exit +import System.IO + +-- Variables +-- +-- Default Terminal +myTerminal :: String +myTerminal = "alacritty" + +-- Whether focus follows the mouse pointer. +myFocusFollowsMouse :: Bool +myFocusFollowsMouse = True + +-- Whether clicking on a window to focus also passes the click to the window +myClickJustFocuses :: Bool +myClickJustFocuses = True + +-- Width of the window border in pixels. +-- +myBorderWidth = 2 + +myModMask = mod4Mask + +-- myScratchPads :: [NamedScratchpad] +-- myScratchPads = [ NS "terminal" "kitty" (title =? "getScratched") defaultFloating ] +-- +-- Workspaces +myWorkspaces = ["cab","web","lab","ser","gfx","idi","gam","muz","cha","hid"] +colorbg = "#2e3440" +colorfg = "#eceff4" + +color01 = "#5e8bac" +color02 = "#b48ead" +color04 = "#ebcb8b" +color05 = "#81a1c1" +color09 = "#4c566a" +color17 = "#d03a3f" + +leftwp = "<box type=Bottom width=2 mb=2 color=" ++ colorfg ++ ">" +rightwp = "</box>" + +-- Count of window in active workspace +windowCount :: X (Maybe String) +windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset + +------ COLORS + +-- Border colors for unfocused and focused windows, respectively. +myNormalBorderColor  = color09 +myFocusedBorderColor = color05 + +------------------------------------------------------------------------ +-- Key bindings. Add, modify or remove key bindings here. +myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ + +    -- +    -- mod-[1..9], Switch to workspace N +    -- mod-shift-[1..9], Move client to workspace N +    -- +    [((m .|. modm, k), windows $ f i) +        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] +        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] +    ++ +    -- +    -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 +    -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 +    -- +    [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) +        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] +        -- | (key, sc) <- zip [xK_e, xK_w, xK_r] [0..] +        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] + +------------------------------------------------------------------------ +-- Mouse bindings: default actions bound to mouse events +-- +myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ + +    -- mod-button1, Set the window to floating mode and move by dragging +    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w +                                       >> windows W.shiftMaster)) +    -- mod-button2, Raise the window to the top of the stack +    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster)) +    -- mod-button3, Set the window to floating mode and resize by dragging +    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w +                                       >> windows W.shiftMaster)) +    -- you may also bind events to the mouse scroll wheel (button4 and button5) +    ] + +------------------------------------------------------------------------ +-- Layouts: +myLayoutPrinter :: String -> String +myLayoutPrinter "Spacing Tall" = xmobarColor colorfg colorbg "til" +myLayoutPrinter "Spacing Mirror Tall" = xmobarColor colorfg colorbg "mti" +myLayoutPrinter "Spacing Spiral" = xmobarColor colorfg colorbg "fib" +myLayoutPrinter "Spacing Full" = xmobarColor colorfg colorbg "ful" +myLayoutPrinter x = xmobarColor colorfg colorbg x + +myLayout = +    onWorkspace "gam" Full $ +    avoidStruts(gaps [(L,3), (D,3), (U,3), (R,3)] $ smartSpacing 2 $ tiled ||| Mirror tiled ||| fib ||| Full) +    where +        -- default tiling algorithm partitions the screen into two panes +        tiled   = Tall nmaster delta ratio +        -- The default number of windows in the master pane +        nmaster = 1 +        -- Default proportion of screen occupied by master pane +        ratio   = 2/5 +        -- Percent of screen to increment by when resizing panes +        delta   = 3/100 + +        fib     = spiral (6/7) +   + +------------------------------------------------------------------------ +-- Window rules: + +myManageHook = composeAll +    [  +    -- className =? "Gimp"           --> doFloat +    -- , className =? "Tilp"           --> doFloat +    -- , resource  =? "desktop_window" --> doIgnore +    -- , resource  =? "kdesktop"       --> doIgnore +    -- +    className =? "discord" --> doShift "cha", +    className =? "Steam" --> doShift "gam" +    ] +-- <+> namedScratchpadManageHook myScratchPads + + +------------------------------------------------------------------------ +-- Startup hook +myStartupHook = do + +    setWMName "XMonad" + +    setDefaultCursor xC_arrow + +    spawnOnce "checkupdates | wc -l > /tmp/updates.tmp" +    spawnOnce "systemctl --user restart redshift.service" +    spawnOnce "unclutter --timeout 3 --jitter 50 -b" +    spawnOnce "numlockx" +    spawnOnce "$HOME/.config/xmonad/autostart/autostart.sh" + +------------------------------------------------------------------------ +-- Now run xmonad with all the defaults we set up. + +-- Run xmonad with the settings you specify. No need to modify this. +-- +main = do +    -- Setup xmobar as docks +    -- +    xmproc0 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc0.hs" +    xmproc1 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc1.hs" + +    -- ewmh: Add fullscreen handling support +    xmonad $ docks . ewmh $ defaults { +        layoutHook = avoidStruts $ layoutHook defaults +        , logHook = dynamicLogWithPP $ filterOutWsPP ["hid"] $ xmobarPP {  +             ppOutput = \x  -> hPutStrLn xmproc0 x + +            , ppCurrent = xmobarColor colorfg colorbg . wrap leftwp rightwp -- Visible but not current workspace +            , ppVisible = xmobarColor colorfg colorbg -- Hidden workspace +            , ppHidden = xmobarColor color01 colorbg -- Hidden workspaces (no windows) +            , ppHiddenNoWindows = xmobarColor color04 colorbg -- Title of active window +            , ppTitle = xmobarColor "" "" . shorten' "" 0 -- Separator character +            , ppSep =  "  " +            , ppLayout = myLayoutPrinter +              -- Urgent workspace , ppUrgent = xmobarColor color17 colorbg . wrap "!" "!" +            , ppExtras  = [windowCount] -- Adding # of windows on current workspace to the bar +        } + +} + + +defaults = ewmh def { +      -- simple stuff +        terminal           = myTerminal, +        focusFollowsMouse  = myFocusFollowsMouse, +        clickJustFocuses   = myClickJustFocuses, +        borderWidth        = myBorderWidth, +        modMask            = myModMask, +        workspaces         = myWorkspaces, +        normalBorderColor  = myNormalBorderColor, +        focusedBorderColor = myFocusedBorderColor, + +      -- key bindings +        keys               = myKeys, +        mouseBindings      = myMouseBindings, + +      -- hooks, layouts +        layoutHook         = myLayout, +        manageHook         = myManageHook <+> manageSpawn, +        startupHook        = myStartupHook +        } +        `additionalKeysP` +        [ ("M-<Return>", spawn myTerminal) +        , ("M-<Backspace>", withFocused hide) -- N.B. this is an absurd thing to do +        , ("M-0", windows $ W.greedyView $ "hid") -- N.B. this is an absurd thing to do +        , ("M-u",       incScreenWindowSpacing (2)) +        , ("M-i",       incScreenWindowSpacing (-2)) +        , ("M-o",       setScreenWindowSpacing (2)) +        -- Then these key bindings +        -- cycling worspaces +        , ("M-<R>",     CWS.nextWS) +        , ("M-<L>",     CWS.prevWS) +        , ("M-S-<R>",   CWS.shiftToNext >> CWS.nextWS) +        , ("M-S-<L>",   CWS.shiftToPrev >> CWS.prevWS) +        , ("M-m",       spawn "emacs") +        -- launch firefox +        , ("M-b",       spawn "firefox") +        -- take screenshots +        , ("M-s",       spawn "maim ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png") +        , ("M-C-s",   spawn "maim -i $(xdotool getactivewindow) ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png") +        , ("M-S-s",     spawn "maim --select | xclip -selection clipboard -t image/png") +        -- close focused window +        , ("M-c",       spawn "kill $(xprop | grep PID | cut -d = -f 2)") +        , ("M-S-c",     kill) +         -- Rotate through the available layout algorithms +        , ("M-C-1", sendMessage $ JumpToLayout "Tall") +        , ("M-C-2", sendMessage $ JumpToLayout "Mirror Tall") +        , ("M-C-3", sendMessage $ JumpToLayout "Spiral") +        , ("M-C-4", sendMessage $ JumpToLayout "Full") +        , ("M-<Tab>", sendMessage NextLayout) + +        , ("M-<Space>", spawn "cycleKB") +        -- Resize viewed windows to the correct size +        , ("M-n",       refresh)  +        -- Move focus to the next window +        , ("M-j",       windows W.focusDown) +        -- Move focus to the previous window +        , ("M-k",       windows W.focusUp)  +        -- Swap the focused window with the next window +        , ("M-S-j",     windows W.swapDown)  +        -- Swap the focused window with the previous window +        , ("M-S-k",     windows W.swapUp)  +        -- Shrink the master area +        , ("M-h",       sendMessage Shrink)  +        -- Expand the master area +        , ("M-l",       sendMessage Expand)  +        -- Push window back into tiling +        , ("M-S-t",     withFocused $ windows . W.sink)  +    -- Increment the number of windows in the master area +        , ("M-,",       sendMessage (IncMasterN 1))  +        -- Deincrement the number of windows in the master area +        , ("M-.",       sendMessage (IncMasterN (-1)))  +        -- Quit xmonad +        , ("M-S-q",     io (exitWith ExitSuccess))  +        -- Restart xmonad +        , ("M-q",       spawn "killall xmobar; xmonad --recompile && xmonad --restart")  +        , ("M-x m",       spawn "kill -USR1 $(pgrep xmobar)")  +        -- open alsamixer and change volume with keyboard wheel +        , ("<XF86AudioLowerVolume>" , spawn "pamixer -d 5") +        , ("<XF86AudioRaiseVolume>" , spawn "pamixer -i 5") +        , ("<XF86AudioMute>"        , spawn "pamixer -t") +        , ("<XF86MonBrightnessDown>", spawn "light -U 5") +        , ("<XF86MonBrightnessUp>"  , spawn "light -A 5") +        , ("M-y" , spawn "arr_hjkl") +        -- Toggle borders +        , ("M-S-b", do +            withFocused toggleBorder +            refresh) +        -- Fullscreen by toggling borders, +        -- struts so docks can be obfuscated +        -- (forcing it into tiling, because problems if you change layouts) +        , ("M-S-f", do +            sendMessage ToggleStruts +            sendMessage ToggleGaps +            toggleWindowSpacingEnabled +            withFocused toggleBorder +            refresh) +         +        , ("M-a c" , spawn "code") +        , ("M-a d" , spawnOn "cha" "discord") +        , ("M-a s" , spawnOn "cha" "signal-desktop") +        , ("M-a k" , spawn "virt-manager") +        , ("M-a m" , spawn "mumble") +        , ("M-a v" , spawn "virtualbox") +        -- file managers +        , ("M-f k", spawn ("kitty" ++ " -e ranger")) +        , ("M-f d", spawn "dolphin") + + +        -- cycle keyboards +        -- dmenu +        , ("M-S-<Return>", spawn "dmenu_run") +        , ("M-p a", spawn "dmapimg") +        , ("M-<Insert>", spawn "dmpsbm") +        , ("M-S-<Insert>", spawn "dmpsclip") +        , ("M-p c", spawn "dmclip") +        , ("M-p d", spawn "dmdsktp") +        , ("M-p f", spawn "dmfm") +        , ("M-p g", spawn "dmpassgen") +        , ("M-p h", spawn "dmhelp") +        , ("M-p l", spawn "dmlang") +        , ("M-p m", spawn "dmpass") +        -- , ("M-p S-m", spawn "passmenu --type") +        , ("M-p p", spawn "dmpdf") +        , ("M-p o", spawn "dmpower") +        , ("M-p v", spawn "dmvid") + +        -- Gaming +        , ("M-g s", spawnOn "gam" "steam") +        , ("M-g m", spawnOn "gam" "multimc -l 1.8.9") +        ]  | 
