graphical#xmonad: init profile
This commit is contained in:
parent
31c2b767ca
commit
54be96d8b6
10 changed files with 318 additions and 1 deletions
18
pkgs/applications/misc/dzvol.nix
Normal file
18
pkgs/applications/misc/dzvol.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ stdenv, pkgconfig, alsaLib, x11, fetchFromGitHub }:
|
||||
stdenv.mkDerivation {
|
||||
name = "dzvol";
|
||||
src = fetchFromGitHub {
|
||||
owner = "allevaton";
|
||||
repo = "dzvol";
|
||||
rev = "ca7099520525df2d54ad24f6def22819d5f36b3b";
|
||||
sha256 = "1xx7xai6hzrm3gs026z41pl877y849vpfi71syj6cj3ir9h16lpz";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp dzvol $out/bin
|
||||
'';
|
||||
|
||||
buildInputs = [ pkgconfig alsaLib x11 ];
|
||||
hardeningDisable = [ "format" ];
|
||||
}
|
|
@ -4,4 +4,5 @@ final: prev: {
|
|||
dejavu_nerdfont = prev.callPackage ./data/fonts/dejavu-nerdfont { };
|
||||
purs = prev.callPackage ./shells/zsh/purs { };
|
||||
pure = prev.callPackage ./shells/zsh/pure { };
|
||||
dzvol = prev.callPackage ./applications/misc/dzvol.nix { };
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ config, pkgs, ... }:
|
||||
let inherit (builtins) readFile;
|
||||
in {
|
||||
imports = [ ./sway ../develop ];
|
||||
imports = [ ./sway ../develop ./xmonad ];
|
||||
|
||||
hardware.opengl.enable = true;
|
||||
hardware.opengl.driSupport = true;
|
||||
|
@ -54,6 +54,8 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
services.xbanish.enable = true;
|
||||
|
||||
services.xserver = {
|
||||
enable = true;
|
||||
|
||||
|
|
87
profiles/graphical/xmonad/_xmonad.hs
Normal file
87
profiles/graphical/xmonad/_xmonad.hs
Normal file
|
@ -0,0 +1,87 @@
|
|||
import XMonad
|
||||
import XMonad.Config.Desktop (desktopConfig)
|
||||
import XMonad.Hooks.EwmhDesktops (ewmh)
|
||||
import XMonad.Hooks.ICCCMFocus (takeTopFocus)
|
||||
import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Util.EZConfig (additionalKeys)
|
||||
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Graphics.X11.ExtraTypes.XF86 (xF86XK_AudioLowerVolume,
|
||||
xF86XK_AudioMute,
|
||||
xF86XK_AudioRaiseVolume)
|
||||
import Graphics.X11.Types (KeyMask, KeySym, Window)
|
||||
import System.Environment (lookupEnv)
|
||||
import XMonad.Layout.ResizableTile (ResizableTall(..),
|
||||
MirrorResize (MirrorShrink,
|
||||
MirrorExpand))
|
||||
import XMonad.Layout.MultiToggle
|
||||
import XMonad.Layout.MultiToggle.Instances
|
||||
|
||||
import Control.Monad (liftM2)
|
||||
import Data.Monoid (Endo)
|
||||
import XMonad.Core (Layout, Query,
|
||||
ScreenDetail, ScreenId,
|
||||
WorkspaceId, X)
|
||||
import XMonad.Hooks.SetWMName (setWMName)
|
||||
import XMonad.Layout.NoBorders (smartBorders)
|
||||
import XMonad.Layout.PerWorkspace (onWorkspace)
|
||||
import XMonad.Layout.Reflect (reflectHoriz)
|
||||
import XMonad.Util.Cursor
|
||||
import qualified XMonad.StackSet as S (StackSet, greedyView,
|
||||
shift)
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
xmonad . ewmh $ desktopConfig
|
||||
{ terminal = "alacritty"
|
||||
, modMask = myModKey
|
||||
, layoutHook = avoidStruts myLayout
|
||||
, workspaces = myWorkspaces
|
||||
, startupHook = myAutostart
|
||||
, manageHook = myManageHook
|
||||
<+> manageHook defaultConfig
|
||||
<+> manageDocks
|
||||
, borderWidth = 1
|
||||
, logHook = takeTopFocus
|
||||
}
|
||||
`additionalKeys` myKeys
|
||||
|
||||
myLayout = smartBorders
|
||||
. mkToggle ( NBFULL ?? EOT)
|
||||
. onWorkspace "7:im" ( half ||| Mirror half ||| tiled ||| reflectHoriz tiled )
|
||||
$ tiled ||| reflectHoriz tiled ||| half ||| Mirror half
|
||||
where
|
||||
tiled = ResizableTall nmaster delta ratiot []
|
||||
half = ResizableTall nmaster delta ratioh []
|
||||
nmaster = 1
|
||||
ratiot = 309/500
|
||||
ratioh = 1/2
|
||||
delta = 1/9
|
||||
|
||||
myWorkspaces :: [ String ]
|
||||
myWorkspaces = ["1:main", "2:art", "3:net", "4:pdf", "5:game", "6:media", "7:im", "8", "9"]
|
||||
|
||||
-- Move Programs by X11 Class to specific workspaces on opening
|
||||
myManageHook :: Query
|
||||
( Endo
|
||||
( S.StackSet WorkspaceId (Layout Window) Window ScreenId ScreenDetail )
|
||||
)
|
||||
myManageHook = composeAll
|
||||
[ className =? "st-256color" --> viewShift "1:main"
|
||||
, className =? "qutebrowser" --> viewShift "1:main"
|
||||
, className =? "Gimp" --> viewShift "2:art"
|
||||
, className =? "krita" --> viewShift "2:art"
|
||||
, className =? "qBittorrent" --> viewShift "3:torrent"
|
||||
, className =? "PCSX2" --> viewShift "5:game"
|
||||
, className =? "RPCS3" --> viewShift "5:game"
|
||||
, className =? "mpv" --> viewShift "6:media"
|
||||
, className =? "Zathura" --> viewShift "4:pdf"
|
||||
, className =? "Signal" --> doShift "7:im"
|
||||
, className =? "Steam" --> doFloat
|
||||
, className =? "Wine" --> doFloat
|
||||
]
|
||||
where viewShift = doF . liftM2 (.) S.greedyView S.shift
|
||||
|
||||
-- Set ModKey to the Windows Key
|
||||
myModKey :: KeyMask
|
||||
myModKey = mod4Mask
|
106
profiles/graphical/xmonad/_xmonad.nix
Normal file
106
profiles/graphical/xmonad/_xmonad.nix
Normal file
|
@ -0,0 +1,106 @@
|
|||
{ autostart, screenshots, touchtoggle, dzvol, stoggle }: ''
|
||||
-- Function for fullscreen toggle
|
||||
fullToggle :: X ()
|
||||
fullToggle = do
|
||||
spawn "${stoggle}"
|
||||
sendMessage $ Toggle NBFULL
|
||||
sendMessage $ SetStruts [] [minBound .. maxBound]
|
||||
|
||||
-- function to call dzen2 and show volume in the middle of the screen
|
||||
dzcall :: String
|
||||
dzcall = "${dzvol}/bin/dzvol -fn 'DejaVu Sans Mono for Powerline-16:normal'"
|
||||
|
||||
myAutostart :: X ()
|
||||
myAutostart = do
|
||||
spawn "${autostart}"
|
||||
setWMName "LG3D"
|
||||
sendMessage $ SetStruts [] [minBound .. maxBound]
|
||||
setDefaultCursor xC_left_ptr
|
||||
|
||||
-- Set custom keybinds below following the structure:
|
||||
-- ( ( ModifierKey, KeyPress ), Action )
|
||||
myKeys :: [ ( ( KeyMask, KeySym ), X () ) ]
|
||||
myKeys =
|
||||
-- toggle fullscreen, along with power state
|
||||
[ ( ( myModKey , xK_f )
|
||||
, fullToggle
|
||||
)
|
||||
-- resize windows in master pane
|
||||
, ( ( myModKey , xK_Left )
|
||||
, sendMessage MirrorExpand
|
||||
)
|
||||
, ( ( myModKey , xK_Right )
|
||||
, sendMessage MirrorShrink
|
||||
)
|
||||
, ( ( myModKey , xK_Up )
|
||||
, sendMessage MirrorExpand
|
||||
)
|
||||
, ( ( myModKey , xK_Down )
|
||||
, sendMessage MirrorShrink
|
||||
)
|
||||
-- toggle systray
|
||||
, ( ( myModKey .|. shiftMask , xK_f )
|
||||
, sendMessage ToggleStruts
|
||||
)
|
||||
-- lower volume
|
||||
, ( ( 0 , xF86XK_AudioLowerVolume )
|
||||
, spawn dzcall
|
||||
)
|
||||
-- raise volume
|
||||
, ( ( 0 , xF86XK_AudioRaiseVolume )
|
||||
, spawn dzcall
|
||||
)
|
||||
-- mute volume
|
||||
, ( ( 0 , xF86XK_AudioMute )
|
||||
, spawn dzcall
|
||||
)
|
||||
-- start qutebrowser
|
||||
, ( ( myModKey , xK_b )
|
||||
, spawn "qute"
|
||||
)
|
||||
-- screen lock
|
||||
, ( ( myModKey .|. shiftMask , xK_l )
|
||||
|
||||
, spawn "loginctl lock-session"
|
||||
)
|
||||
-- screenshot
|
||||
, ( ( myModKey , xK_Print )
|
||||
, spawn "maim -u \
|
||||
\ | png2ff | xz -9 - \
|
||||
\ > ~/${screenshots}/$(date +%m.%d.%y_%I.%M.%S_%p).ff.xz"
|
||||
)
|
||||
-- screenshot focused window
|
||||
, ( ( myModKey .|. shiftMask , xK_Print )
|
||||
|
||||
, spawn "maim -u -i$(xdotool getactivewindow) \
|
||||
\ | png2ff \
|
||||
\ | xz -9 - \
|
||||
\ > ~/${screenshots}/$(date +%m.%d.%y_%I.%M.%S_%p).ff.xz"
|
||||
)
|
||||
-- screenshot selection to clipboard
|
||||
, ( ( myModKey .|. controlMask , xK_Print )
|
||||
|
||||
, spawn "maim -s -u \
|
||||
\ | xclip -selection clipboard -t image/png"
|
||||
)
|
||||
-- screenshot selection file
|
||||
, ( ( myModKey .|. controlMask .|. shiftMask, xK_Print )
|
||||
|
||||
, spawn "maim -s -u \
|
||||
\ | png2ff \
|
||||
\ | xz -9 - \
|
||||
\ > ~/${screenshots}/$(date +%m.%d.%y_%I.%M.%S_%p).ff.xz"
|
||||
)
|
||||
-- screenshot selection to imgur and paste url in clipboard
|
||||
, ( ( myModKey .|. shiftMask , xK_i )
|
||||
|
||||
, spawn "maim -s -u /tmp/img.png; \
|
||||
\ imgurbash2 /tmp/img.png; \
|
||||
\ rm /tmp/img.png"
|
||||
)
|
||||
-- dmenu frontend for network manager
|
||||
, ( ( myModKey , xK_n )
|
||||
, spawn "networkmanager_dmenu -fn 'DejaVu Sans Mono for Powerline-16:normal'"
|
||||
)
|
||||
]
|
||||
''
|
11
profiles/graphical/xmonad/default.nix
Normal file
11
profiles/graphical/xmonad/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ pkgs, ... }: {
|
||||
environment.systemPackages = with pkgs; [ xss-lock dzvol maim ];
|
||||
|
||||
services.xserver.windowManager.xmonad = {
|
||||
enable = true;
|
||||
enableContribAndExtras = true;
|
||||
config = import ./xmonad.hs.nix { inherit pkgs; };
|
||||
};
|
||||
|
||||
programs.slock.enable = true;
|
||||
}
|
16
profiles/graphical/xmonad/scripts/autostart
Normal file
16
profiles/graphical/xmonad/scripts/autostart
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
terminal="alacritty"
|
||||
|
||||
# set screen locker to slock
|
||||
pgrep -x xss-lock \
|
||||
|| xss-lock slock&!
|
||||
|
||||
pgrep -x xbanish \
|
||||
|| xbanish&!
|
||||
|
||||
${terminal} -e tmux new-session -As $(whoami)&!
|
||||
|
||||
if ! pgrep -f qutebrowser; then
|
||||
${BROWSER} &!
|
||||
fi
|
45
profiles/graphical/xmonad/scripts/stoggle
Normal file
45
profiles/graphical/xmonad/scripts/stoggle
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env zsh
|
||||
# variables for dzen2
|
||||
WIDTH=512
|
||||
WINDOW_HEIGHT=$( xdpyinfo \
|
||||
| awk '$1 ~ /dimensions/ {split($2,arr,"x"); print int(arr[2])}' \
|
||||
)
|
||||
WINDOW_WIDTH=$( xdpyinfo \
|
||||
| awk '$1 ~ /dimensions/ {split($2,arr,"x"); print int(arr[1])}' \
|
||||
)
|
||||
XPOS=$(( ( ${WINDOW_WIDTH} / 2 ) - ( ${WIDTH} / 2 ) ))
|
||||
YPOS=$(( ${WINDOW_HEIGHT} / 2 ))
|
||||
|
||||
readonly WIDTH WINDOW_HEIGHT WINDOW_WIDTH XPOS YPOS
|
||||
|
||||
# get current state of dpms
|
||||
xset -q \
|
||||
| grep -Eo 'DPMS is (Enabled|Disabled)' \
|
||||
| awk '{print $3}' \
|
||||
| read dpms_state
|
||||
|
||||
# function to call dzen2 with current state
|
||||
dzen2_dpms_state () {
|
||||
local -r \
|
||||
new_dpms_state=$1
|
||||
|
||||
print "Power Management ${new_dpms_state}" \
|
||||
| dzen2 -fn "DejaVu Sans Mono for Powerline-16:normal" -p 2 -tw ${WIDTH} -x ${XPOS} -y ${YPOS}
|
||||
}
|
||||
|
||||
case $dpms_state in
|
||||
Enabled)
|
||||
xset -dpms
|
||||
xset s off
|
||||
dzen2_dpms_state "Disabled"
|
||||
;;
|
||||
Disabled)
|
||||
xset +dpms
|
||||
xset s on
|
||||
xset s 300
|
||||
dzen2_dpms_state "Enabled"
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
12
profiles/graphical/xmonad/scripts/touchtoggle
Normal file
12
profiles/graphical/xmonad/scripts/touchtoggle
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env zsh
|
||||
touchpad_name=$(libinput list-devices | grep -B 5 "pointer gesture" | awk '/Device/ {for (i=2; i<NF; i++) printf $i " "; print $NF}')
|
||||
|
||||
[[ $touchpad_name == "" ]] && exit
|
||||
|
||||
touchpad_status=$(xinput list-props "$touchpad_name" | awk '/Device Enabled/ {print $4}')
|
||||
|
||||
if [[ $touchpad_status == "0" ]]; then
|
||||
xinput --enable "$touchpad_name"
|
||||
else
|
||||
xinput --disable "$touchpad_name"
|
||||
fi
|
19
profiles/graphical/xmonad/xmonad.hs.nix
Normal file
19
profiles/graphical/xmonad/xmonad.hs.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
inherit (builtins) readFile;
|
||||
inherit (pkgs) writeScript dzvol;
|
||||
|
||||
screenshots = "Pictures/shots";
|
||||
|
||||
autostart = writeScript "xmonad-autostart" (readFile ./scripts/autostart);
|
||||
|
||||
stoggle = writeScript "xmonad-stoggle" (readFile ./scripts/stoggle);
|
||||
|
||||
touchtoggle =
|
||||
writeScript "xmonad-touchtoggle" (readFile ./scripts/touchtoggle);
|
||||
in ''
|
||||
${readFile ./_xmonad.hs}
|
||||
${import ./_xmonad.nix {
|
||||
inherit screenshots touchtoggle autostart dzvol stoggle;
|
||||
}}
|
||||
''
|
Loading…
Reference in a new issue