switch x/xmonad for wayland/river

This commit is contained in:
Felix Van der Jeugt 2024-08-02 11:09:49 +02:00
parent 3ffb35cc2e
commit dac9f903c9
8 changed files with 81 additions and 131 deletions

4
config/foot/foot.ini Normal file
View File

@ -0,0 +1,4 @@
font=M+ 2m:size=12
[url]
launch=rifle ${url}

42
config/river/init Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
riverctl map normal Super+Shift q exit
riverctl map normal Super Return spawn foot
riverctl map normal Super t spawn foot
riverctl map normal Super+Shift c close
riverctl map normal Super n focus-output next
riverctl map normal Super+Shift n spawn "riverctl send-to-output next && riverctl focus-output next"
riverctl map normal Super j focus-view next
riverctl map normal Super k focus-view previous
riverctl map normal Super+Shift j swap next
riverctl map normal Super+Shift k swap previous
riverctl map normal Super s send-layout-cmd rivertile "main-location right"
riverctl map normal Super w send-layout-cmd rivertile "main-location left"
riverctl map normal Super i send-layout-cmd rivertile "main-count +1"
riverctl map normal Super d send-layout-cmd rivertile "main-count -1"
riverctl map normal Super r spawn 'exec "$(dmenu_path | skmenu)"'
riverctl map normal Super p spawn 'delegator -g'
riverctl map normal Super 1 set-focused-tags 1
riverctl map normal Super 2 set-focused-tags 2
riverctl map normal Super 3 set-focused-tags 4
riverctl map normal Super+Shift 1 set-view-tags 1
riverctl map normal Super+Shift 2 set-view-tags 2
riverctl map normal Super+Shift 3 set-view-tags 4
riverctl map-pointer normal Super BTN_LEFT move-view
riverctl map-pointer normal Super BTN_RIGHT resize-view
riverctl map-pointer normal Super BTN_MIDDLE toggle-float
riverctl border-color-focused 0xFF0000
riverctl focus-follows-cursor always
riverctl keyboard-layout -options compose:caps us
riverctl set-cursor-warp on-focus-change
riverctl set-repeat 55 300
riverctl default-layout rivertile
riverctl rule-add -title skmenu float
riverctl spawn 'dbus-run-session pipewire'
riverctl spawn 'swayidle timeout 300 waylock timeout 300 "wlopm --off \*" resume "wlopm --on \*"'
riverctl spawn "wbg '$(find -L /data/pictures/background-source/ -type f | sort -R | head -1)'"
rivertile -view-padding 0 -outer-padding 0 -main-ratio 0.7 &

View File

@ -2,7 +2,7 @@
set -e set -e
if [ -t 1 ]; then if [ -t 1 -a "$1" != '-g' ]; then
pick() { pick() {
sk sk
} }
@ -10,16 +10,32 @@ if [ -t 1 ]; then
echo "$@" echo "$@"
} }
else else
window="$(xdotool getwindowfocus)"
pick() { pick() {
dmenu -i -l 10 if pgrep wayland >/dev/null; then
skmenu
else
dmenu -i -l 10
fi
} }
inject() { inject() {
xdotool type --clearmodifiers --window "$window" "$*" if pgrep wayland >/dev/null; then
xdotool windowfocus "$window" wtype -s 500 "$*"
else
window="$(xdotool getwindowfocus)"
xdotool type --clearmodifiers --window "$window" "$*"
xdotool windowfocus "$window"
fi
} }
fi fi
if wl-paste -h >/dev/null; then
primary() { wl-paste --primary; }
clip() { wl-paste; }
else
primary() { xclip -o; }
clip() { xclip -o -sel c; }
fi
choice="$(pick <<HERE choice="$(pick <<HERE
email address email address
pass pass
@ -53,10 +69,10 @@ case "$choice" in
inject "$(lpass show --password "$choice" | head -1)" inject "$(lpass show --password "$choice" | head -1)"
;; ;;
'clipboard') 'clipboard')
inject "$(xclip -o -sel c)" inject "$(clip)"
;; ;;
'selection') 'selection')
inject "$(xclip -o)" inject "$(primary)"
;; ;;
'run') 'run')
choice="$(dmenu_path | pick)" choice="$(dmenu_path | pick)"
@ -74,7 +90,7 @@ case "$choice" in
d="$(mktemp -d)" d="$(mktemp -d)"
trap "rm -r '$d'" EXIT KILL trap "rm -r '$d'" EXIT KILL
cd "$d" cd "$d"
curl -LOJ "$(xclip -o)" curl -LOJ "$(primary)"
rifle -fF * rifle -fF *
;; ;;
'clipmenu') 'clipmenu')
@ -89,13 +105,13 @@ case "$choice" in
inject "${choice##* }" inject "${choice##* }"
;; ;;
'spotify-title') 'spotify-title')
inject "$(curl -L "$(xclip -o)" | sed -n 's@.*<title>\(.*\) - song \(and lyrics \)\?by \(.*\) | Spotify</title>.*@\1 - \3@p')" inject "$(curl -L "$(clip)" | sed -n 's@.*<title>\(.*\) - song \(and lyrics \)\?by \(.*\) | Spotify</title>.*@\1 _van_ \3@p')"
;; ;;
'youtube-dl') 'youtube-dl')
d="$(mktemp -d)" d="$(mktemp -d)"
trap "rm -r '$d'" EXIT KILL trap "rm -r '$d'" EXIT KILL
cd "$d" cd "$d"
yt-dlp "$(xclip -o)" yt-dlp "$(primary)"
if mplayer -v >/dev/null; then if mplayer -v >/dev/null; then
exec st mplayer * exec st mplayer *
else else
@ -106,7 +122,7 @@ case "$choice" in
d="$(mktemp -d)" d="$(mktemp -d)"
trap "rm -r '$d'" EXIT KILL trap "rm -r '$d'" EXIT KILL
cd "$d" cd "$d"
yt-dlp -x "$(xclip -o)" yt-dlp -x "$(primary)"
exec st mpv --no-video * exec st mpv --no-video *
;; ;;
esac esac

View File

@ -1,19 +0,0 @@
#!/bin/bash
xset dpms 0 0 300
dp1="$(xrandr | grep '^DP1 connected')"
dp1_1="$(xrandr | grep '^DP1-1 connected')"
dp1_2="$(xrandr | grep '^DP1-2 connected')"
dp1_3="$(xrandr | grep '^DP1-3 connected')"
if [ -n "$dp1" -a -z "$dp1_1" -a -z "$dp1_2" -a -z "$dp1_3" ]; then
xrandr --output DP1 --auto --primary --above eDP1
elif [ -z "$dp1" -a -n "$dp1_1" -a -z "$dp1_2" -a -z "$dp1_3" ]; then
xrandr --output DP1-1 --auto --primary --above eDP1
elif [ -z "$dp1" -a -n "$dp1_1" -a -n "$dp1_2" -a -z "$dp1_3" ]; then
xrandr --output DP1-1 --auto --left-of eDP1 \
--output DP1-2 --auto --right-of eDP1
elif [ -z "$dp1" -a -z "$dp1_1" -a -z "$dp1_2" -a -n "$dp1_3" ]; then
xrandr --output DP1-3 --auto --primary --above eDP1
fi

2
local/bin/skmenu Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
foot --title skmenu sh -c "sk -e < /proc/$$/fd/0 > /proc/$$/fd/1"

View File

@ -8,6 +8,7 @@ export XDG_RUNTIME_DIR="/tmp/runtime-$(whoami)"
mkdir -p "$XDG_RUNTIME_DIR" mkdir -p "$XDG_RUNTIME_DIR"
chmod 0700 "$XDG_RUNTIME_DIR" chmod 0700 "$XDG_RUNTIME_DIR"
export XDG_DOWNLOAD_DIR="/tmp" export XDG_DOWNLOAD_DIR="/tmp"
export XDG_DESKTOP_DIR="/tmp"
# Local scripts # Local scripts
export CABAL_HOME="/data/homes/cabal" export CABAL_HOME="/data/homes/cabal"
@ -35,3 +36,8 @@ if [ -d "$HOME/.cache/ncspot/librespot/files" ]; then
fi fi
#stty -ixon # disable <C-s> #stty -ixon # disable <C-s>
# Start river if logging in on TTY 1
if [ "$(tty)" = "/dev/tty1" ]; then
exec river
fi

20
xinitrc
View File

@ -1,20 +0,0 @@
#!/bin/sh
# Forking graphical programs
forklog() {
$* 2>&1 | logger &
}
case "$(hostname)" in
mantle) xset dpms 0 0 300 s off ; backimg="bgs -z" ;;
abysm) xset dpms 0 0 50 s off ; backimg="feh --bg-fill" ;;
vaults) xset dpms 0 0 300 s off ; backimg="feh --bg-fill" ;;
esac
xset r rate 300 55
forklog $backimg $(find -L /data/pictures/background-source/ -type f | sort -R | head)
forklog redshift
forklog dbus-run-session pipewire
exec xmonad

View File

@ -1,81 +0,0 @@
module Main where
import qualified Data.Map as M
import Data.Maybe (isJust)
import Graphics.X11.ExtraTypes.XF86
import System.Exit (exitSuccess)
import XMonad.Actions.CycleWS (nextScreen, shiftNextScreen)
import XMonad.Actions.Warp (warpToWindow)
import XMonad hiding ((|||))
import XMonad.Hooks.EwmhDesktops (ewmh)
import XMonad.Hooks.ManageHelpers ((-?>), ($?))
import qualified XMonad.Hooks.ManageHelpers as H
import XMonad.Layout.IndependentScreens (countScreens, onCurrentScreen, withScreens, workspaces')
import XMonad.Layout.LayoutCombinators ((|||), JumpToLayout(JumpToLayout))
import XMonad.Layout.LayoutModifier (ModifiedLayout(ModifiedLayout))
import XMonad.Layout.NoBorders (noBorders)
import qualified XMonad.Layout.Renamed as Renamed
import XMonad.Layout.SimplestFloat (simplestFloat)
import qualified XMonad.StackSet as W
main :: IO ()
main = countScreens >>= \n -> xmonad . ewmh $ def
{ modMask = mod4Mask
, terminal = "st"
, keys = myKeys
, mouseBindings = myMouse
, layoutHook = myLayout
, workspaces = withScreens n ["1", "2", "3"]
}
myKeys :: XConfig l -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig { modMask = modMask }) = M.fromList $
[ (mod xK_Return, spawn $ terminal conf)
, (mod xK_t, spawn $ terminal conf)
, (mod xK_r, spawn "exec \"$(dmenu_path | dmenu)\"")
, (mod xK_p, spawn "delegator")
, (mod xK_BackSpace, kill)
, (mod xK_j, windows W.focusDown >> center)
, (mod xK_k, windows W.focusUp >> center)
, (modshift xK_j, windows W.swapDown >> center)
, (modshift xK_k, windows W.swapUp >> center)
, (mod xK_n, nextScreen >> center)
, (modshift xK_n, shiftNextScreen >> nextScreen >> center)
, (mod xK_i, sendMessage (IncMasterN 1) >> center)
, (mod xK_d, sendMessage (IncMasterN (-1)) >> center)
, (mod xK_h, sendMessage Shrink >> center)
, (mod xK_l, sendMessage Expand >> center)
, (mod xK_q, spawn "xmonad --recompile; xmonad --restart")
, (modshift xK_q, io exitSuccess)
, (mod xK_m, sendMessage $ JumpToLayout "Max")
, (mod xK_w, sendMessage $ JumpToLayout "Wide")
, (mod xK_f, sendMessage $ JumpToLayout "Floating")
, (mediaUp, spawn "pamixer -i 5")
, (mediaDown, spawn "pamixer -d 5")
, (mediaPlay, spawn "playerctl play-pause")
, (mediaNext, spawn "playerctl next")
] ++
[ (m k, windows $ onCurrentScreen f i)
| (i, k) <- zip (workspaces' conf) [xK_1 .. xK_9] ++ zip (workspaces' conf) [xK_z, xK_x, xK_c, xK_v, xK_b]
, (f, m) <- [(W.greedyView, mod), (W.shift, modshift)]
]
where
mod k = (modMask, k)
modshift k = (modMask .|. shiftMask, k)
center = warpToWindow 0.5 0.5
mediaUp = (0, xF86XK_AudioRaiseVolume)
mediaDown = (0, xF86XK_AudioLowerVolume)
mediaNext = (0, xF86XK_AudioNext)
mediaPlay = (0, xF86XK_AudioPlay)
myMouse :: XConfig l -> M.Map (KeyMask, Button) (Window -> X ())
myMouse conf@(XConfig { modMask = modMask }) = M.fromList
[ ((modMask, button1), \w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)
, ((modMask, button2), windows . W.sink)
, ((modMask, button3), \w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster)
]
myLayout = rename "Wide" (Tall 1 (3/100) (1/2))
||| rename "Max" (noBorders Full)
||| rename "Floating" simplestFloat
where rename = ModifiedLayout . Renamed.Replace