2022-08-05 11:20:13 -03:00
{ config , pkgs , lib , . . . }:
let
inherit ( import ./variables.nix ) key theme color accent font ;
pulse_sink = pkgs . writeShellScriptBin " p u l s e _ s i n k " ''
#!/bin/sh
2022-08-19 20:40:39 -03:00
output = $ ( printf " H D M I \n H e a d p h o n e s " | wdmenu - i - p " O u t p u t : " )
2022-08-05 11:20:13 -03:00
vol = $ ( $ { pkgs . pamixer } /bin/pamixer - - get-volume )
case " $ o u t p u t " in
HDMI )
pactl set-default-sink alsa_output . pci-0000_07_00 .1 . hdmi-stereo-extra1
; ;
Headphones )
pactl set-default-sink alsa_output . pci-0000_09_00 .4 . analog-stereo
; ;
esac
$ { pkgs . pamixer } /bin/pamixer - - set-volume " $ v o l "
'' ;
_lock = pkgs . writeShellScriptBin " _ l o c k " ''
swaylock - f
systemctl - - user start swayidle . service
'' ;
_suspend = pkgs . writeShellScriptBin " _ s u s p e n d " ''
$ { _lock } /bin/_lock
systemctl suspend
'' ;
_sway_idle_toggle = pkgs . writeShellScriptBin " _ s w a y _ i d l e _ t o g g l e " ''
if pidof swayidle > /dev/null ; then
systemctl - - user stop swayidle . service
else
systemctl - - user start swayidle . service
fi
'' ;
in {
config = {
2022-08-18 13:58:35 -03:00
wayland . windowManager . sway = let
mod = " M o d 4 " ;
2022-08-19 20:40:39 -03:00
menu = " w l a u n c h e r " ;
2022-08-18 13:58:35 -03:00
terminal = " a l a c r i t t y " ;
# Utility funcion
# Input: [{v1=1;} {v2=2;}]
# Output: {v1=1;v2=2;}
mergeAttrsSet = lib . foldAttrs ( n : _ : n ) { } ;
forEachMerge = list : func : mergeAttrsSet ( lib . forEach list func ) ;
# same as imap0 but reversed inputs
iforEach0 = ( list : func : lib . imap0 func list ) ;
# Usefull for translating an imperative foreach into declarative attrset creation
# iforEach0mergeAttrsSet ["val1" "val2"] (i: v: {
# ${i} = v;
# })
# Ouput: {val1 = 1; val2 = 2;}
2022-08-19 20:40:39 -03:00
iforEach0mergeAttrsSet = list : func : mergeAttrsSet ( iforEach0 list func ) ;
2022-08-18 13:58:35 -03:00
in {
2022-08-05 11:20:13 -03:00
enable = true ;
config = {
bars = [ ] ;
window . titlebar = false ;
gaps = {
smartGaps = true ;
smartBorders = " o n " ;
inner = 5 ;
} ;
colors = let
acc = accent . color ;
fg_acc = accent . fg ;
fg_color = color . txt ;
bg_color = color . bg_dark ;
alert = " # 0 0 0 0 0 0 " ;
client = border : background : text : indicator : childBorder : {
inherit border background text indicator childBorder ;
} ;
in {
focused = client acc acc fg_acc acc acc ;
focusedInactive = client bg_color bg_color fg_color bg_color bg_color ;
unfocused = client bg_color bg_color fg_color bg_color bg_color ;
urgent = client alert alert fg_color alert alert ;
} ;
output = { " * " = { bg = " ${ theme . background } f i l l " ; } ; } ;
2022-08-07 22:08:32 -03:00
fonts = {
names = [ font . interface ] ;
size = font . size . medium * 1 .0 ;
} ;
2022-08-05 11:20:13 -03:00
input . " t y p e : t o u c h p a d " = {
# Disable While Typing
dwt = " d i s a b l e d " ;
natural_scroll = " e n a b l e d " ;
tap = " e n a b l e d " ;
} ;
input . " * " = {
xkb_layout = " u s ( c o l e m a k ) , b r " ;
xkb_options = " l v 3 : l s g t _ s w i t c h , g r p : s h i f t s _ t o g g l e " ;
xkb_numlock = " e n a b l e d " ;
repeat_rate = " 3 0 " ;
repeat_delay = " 2 0 0 " ;
} ;
2022-08-07 22:00:01 -03:00
# setup cursor based on home.pointerCursor
seat . " * " = {
2022-08-07 23:58:05 -03:00
xcursor_theme = " ${ config . home . pointerCursor . name } ${
toString config . home . pointerCursor . size
} " ;
2022-08-07 22:00:01 -03:00
} ;
2022-08-05 11:20:13 -03:00
assigns = {
2022-08-07 23:08:25 -03:00
" 2 " = [
{ class = " q u t e b r o w s e r " ; }
{ app_id = " q u t e b r o w s e r " ; }
{ class = " f i r e f o x " ; }
{ app_id = " f i r e f o x " ; }
{ class = " C h r o m i u m " ; }
{ app_id = " c h r o m i u m " ; }
] ;
" 9 " = [
{ class = " . * [ S s ] t e a m . * " ; }
{ app_id = " . * [ S s ] t e a m . * " ; }
{ app_id = " [ L l ] u t r i s " ; }
] ;
2022-08-05 11:20:13 -03:00
" 1 0 " = [
{ app_id = " . * [ T t ] e l e g r a m . * " ; }
{ class = " . * [ T t ] e l e g r a m . * " ; }
{ class = " J i t s i M e e t " ; }
{ class = " d i s c o r d " ; }
{ title = " D i s c o r d " ; }
{ class = " W e b C o r d " ; }
] ;
} ;
2022-08-13 10:08:59 -03:00
modes = let
locked_binds =
lib . mapAttrs' ( k : v : lib . nameValuePair " - - l o c k e d ${ k } " v ) ;
code_binds =
lib . mapAttrs' ( k : v : lib . nameValuePair " - - t o - c o d e ${ k } " v ) ;
return_mode = lib . mapAttrs ( k : v : " ${ v } ; m o d e d e f a u l t " ) ;
2022-08-05 11:20:13 -03:00
in {
2022-08-13 10:08:59 -03:00
audio = code_binds ( locked_binds {
$ { key . tabR } = " e x e c v o l u m e s h - i 1 0 " ;
$ { key . tabL } = " e x e c v o l u m e s h - d 1 0 " ;
$ { key . right } = " e x e c m p c n e x t " ;
$ { key . left } = " e x e c m p c p r e v " ;
$ { key . up } = " e x e c v o l u m e s h - - m p d - i 1 0 " ;
$ { key . down } = " e x e c v o l u m e s h - - m p d - d 1 0 " ;
} ) // return_mode {
2022-08-05 11:20:13 -03:00
" s p a c e " = " e x e c m p c t o g g l e " ;
" e s c a p e " = " " ;
2022-08-13 10:08:59 -03:00
" q " = " " ;
2022-08-29 19:14:24 -03:00
" m " = " e x e c v o l u m e s h - t " ;
2022-08-05 11:20:13 -03:00
" s " = " e x e c ${ pulse_sink } / b i n / p u l s e _ s i n k " ;
} ;
2022-08-18 13:58:35 -03:00
passthrough = {
2022-08-19 20:40:39 -03:00
" ${ mod } + e s c a p e " = " m o d e d e f a u l t ; e x e c n o t i f y - s e n d ' P a s s t h r o u g h o f f ' " ;
2022-08-18 13:58:35 -03:00
} ;
2022-08-05 11:20:13 -03:00
} ;
2022-08-06 11:10:31 -03:00
floating = {
modifier = " M o d 4 " ;
2022-08-06 18:32:34 -03:00
criteria = [ { class = " f i l e _ p i c k e r " ; } { app_id = " f i l e _ p i c k e r " ; } ] ;
2022-08-06 11:10:31 -03:00
} ;
2022-08-05 11:20:13 -03:00
keybindings = let
2022-08-07 15:54:56 -03:00
# mod+1 to swich to workspace 1
# mod+shift+1 to move to workspace 1
workspace_binds = let
workspaceBinds = map makeWorkspaceBinds ( lib . range 1 10 ) ;
makeWorkspaceBinds = ( i :
let
key = toString ( lib . mod i 10 ) ;
workspaceNumber = toString i ;
in {
" ${ mod } + ${ key } " = " w o r k s p a c e n u m b e r ${ workspaceNumber } " ;
" ${ mod } + S h i f t + ${ key } " =
" m o v e c o n t a i n e r t o w o r k s p a c e n u m b e r ${ workspaceNumber } " ;
} ) ;
in mergeAttrsSet workspaceBinds ;
2022-08-05 11:20:13 -03:00
prev_next_binds = let
maybe_window = key :
if ( lib . strings . hasInfix " b u t t o n " key ) then
" - - w h o l e - w i n d o w "
else
" " ;
2022-08-07 16:02:21 -03:00
makePrevNextBindFunction = ( prev_or_next :
map ( key : {
" ${ maybe_window key } ${ mod } + ${ key } " =
" w o r k s p a c e ${ prev_or_next } _ o n _ o u t p u t " ;
} ) ) ;
prev_binds = makePrevNextBindFunction " p r e v " [
2022-08-07 15:54:56 -03:00
key . tabL
" b r a c k e t l e f t "
" P r i o r "
" b u t t o n 9 "
" b u t t o n 4 "
" S h i f t + T a b "
] ;
2022-08-07 16:02:21 -03:00
next_binds = makePrevNextBindFunction " n e x t " [
key . tabR
" b r a c k e t r i g h t "
" N e x t "
" b u t t o n 8 "
" b u t t o n 5 "
" T a b "
] ;
2022-08-07 15:54:56 -03:00
in mergeAttrsSet ( prev_binds ++ next_binds ) ;
2022-08-07 16:02:21 -03:00
2022-08-07 16:58:23 -03:00
# focus, move, resize, (focus and move output)
# for every direction with both arrow keys and vim keys
movement_binds = let
directions = [ " L e f t " " U p " " R i g h t " " D o w n " ] ;
makeVimKeys = ( k : key . ${ lib . toLower k } ) ;
makeArrowKeys = ( k : k ) ;
makeResizeCommand = direction :
{
Left = " s h r i n k w i d t h 2 0 p x " ;
Up = " s h r i n k h e i g h t 2 0 p x " ;
Right = " g r o w w i d t h 2 0 p x " ;
Down = " g r o w h e i g h t 2 0 p x " ;
} . ${ direction } ;
in forEachMerge [ makeVimKeys makeArrowKeys ] ( prefixFun :
forEachMerge directions ( direction :
let
resize_cmd = makeResizeCommand direction ;
keyBind = prefixFun direction ;
in {
# Move focus
" ${ mod } + ${ keyBind } " = " f o c u s ${ direction } " ;
# Move window
" ${ mod } + S h i f t + ${ keyBind } " = " m o v e ${ direction } " ;
# Resize window
" ${ mod } + C o n t r o l + ${ keyBind } " = " r e s i z e ${ resize_cmd } " ;
# focus output
" ${ mod } + m o d 1 + ${ keyBind } " = " f o c u s o u t p u t ${ direction } " ;
# Move workspace to output
" ${ mod } + m o d 1 + S h i f t + ${ keyBind } " =
" m o v e w o r k s p a c e o u t p u t ${ direction } " ;
} ) ) ;
2022-08-07 21:40:27 -03:00
parenting_binds = {
" ${ mod } + e q u a l " = " f o c u s p a r e n t " ;
" ${ mod } + m i n u s " = " f o c u s c h i l d " ;
" ${ mod } + r " = " l a y o u t t o g g l e s p l i t " ;
" ${ mod } + t " = " l a y o u t t o g g l e s p l i t t a b b e d s t a c k i n g " ;
" ${ mod } + b " = " s p l i t h " ;
" ${ mod } + v " = " s p l i t v " ;
" ${ mod } + a " = " f o c u s p a r e n t " ;
## TODO:
# "${mod}+Shift+minus" = "move scratchpad";
# "${mod}+minus" = "scratchpad show";
} ;
2022-08-05 11:20:13 -03:00
audio_binds = {
2022-08-15 10:34:52 -03:00
XF86AudioRaiseVolume = " e x e c v o l u m e s h - i 1 0 " ;
XF86AudioLowerVolume = " e x e c v o l u m e s h - d 1 0 " ;
2022-08-29 19:14:24 -03:00
XF86AudioMute = " e x e c v o l u m e s h - t " ;
2022-08-05 11:20:13 -03:00
XF86AudioMicMute =
" e x e c p a c t l s e t - s o u r c e - m u t e @ D E F A U L T _ S O U R C E @ t o g g l e " ;
# Control media
XF86AudioPlay = " e x e c p l a y e r c t l p l a y - p a u s e " ;
XF86AudioPause = " e x e c p l a y e r c t l p l a y - p a u s e " ;
XF86AudioNext = " e x e c p l a y e r c t l n e x t " ;
XF86AudioPrev = " e x e c p l a y e r c t l p r e v i o u s " ;
} ;
system_binds = {
" - - l o c k e d C t r l + ${ mod } + z " = " e x e c ${ _suspend } / b i n / _ s u s p e n d " ;
" ${ mod } + A l t + c " = " e x e c ${ _sway_idle_toggle } / b i n / _ s w a y _ i d l e _ t o g g l e " ;
} ;
2022-08-08 20:05:06 -03:00
screenshot_binds = {
# Screens to file
" P r i n t " = " e x e c ${ pkgs . screenshotsh } / b i n / s c r e e n s h o t s h d e f " ;
# Screen area to file
" S h i f t + P r i n t " = " e x e c ${ pkgs . screenshotsh } / b i n / s c r e e n s h o t s h a r e a " ;
# Screen area to clipboard
" C o n t r o l + S h i f t + P r i n t " =
" e x e c ${ pkgs . screenshotsh } / b i n / s c r e e n s h o t s h a r e a - c l i p " ;
# Focused monitor to clipboard
" C o n t r o l + P r i n t " = " e x e c ${ pkgs . screenshotsh } / b i n / s c r e e n s h o t s h c l i p " ;
} ;
2022-08-07 21:40:27 -03:00
other_binds = {
2022-08-08 22:50:12 -03:00
" ${ mod } + p " = " e x e c ${ pkgs . wpass } / b i n / w p a s s " ;
2022-08-07 21:40:27 -03:00
" ${ mod } + s " = " e x e c ${ menu } " ;
" ${ mod } + R e t u r n " = " e x e c ${ terminal } " ;
" ${ mod } + C t r l + R e t u r n " = " e x e c t h u n a r " ;
" ${ mod } + x " = " k i l l " ;
" ${ mod } + m " = " m o d e a u d i o " ;
2022-08-19 20:40:39 -03:00
" ${ mod } + e s c a p e " =
" m o d e p a s s t h r o u g h ; e x e c n o t i f y - s e n d ' P a s s t h r o u g h o n ' " ;
2022-08-07 21:40:27 -03:00
" ${ mod } + f " = " f u l l s c r e e n t o g g l e " ;
" ${ mod } + S h i f t + s p a c e " = " f l o a t i n g t o g g l e " ;
" ${ mod } + s p a c e " = " f o c u s m o d e _ t o g g l e " ;
" ${ mod } + S h i f t + c " = " r e l o a d " ;
# "${mod}+Shift+e" =
# "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
} ;
in mergeAttrsSet [
other_binds
workspace_binds
prev_next_binds
movement_binds
audio_binds
system_binds
parenting_binds
2022-08-08 20:05:06 -03:00
screenshot_binds
2022-08-07 21:40:27 -03:00
] ;
2022-08-05 11:20:13 -03:00
terminal = pkgs . alacritty . executable ;
} ;
2022-08-12 09:23:40 -03:00
extraConfig = ''
for_window [ title = . * ] inhibit_idle fullscreen
'' ;
2022-08-05 11:20:13 -03:00
} ;
services . swayidle = {
enable = true ;
timeouts = [
{
timeout = 360 ;
command = " s w a y l o c k - f " ;
}
{
timeout = 1800 ;
command = ''
mpc status | grep " ^ [ p l a y i n g ] " > /dev/null || swaymsg " o u t p u t * d p m s o f f " '' ;
resumeCommand = '' s w a y m s g " o u t p u t * d p m s o n " '' ;
}
] ;
events = [ {
event = " b e f o r e - s l e e p " ;
command = " s w a y l o c k - f " ;
} ] ;
} ;
xdg . configFile . " s w a y l o c k / c o n f i g " . text = ''
image = $ { theme . background }
font = $ { font . interface }
font-size = $ { toString font . size . medium }
indicator-thickness = 20
color = $ { color . bg }
inside-color = #FFFFFF00
bs-hl-color = $ { color . normal . red }
ring-color = $ { color . normal . green }
key-hl-color = $ { accent . color }
# divisor lines
separator-color = #aabbcc00
line-color = #aabbcc00
line-clear-color = #aabbcc00
line-caps-lock-color = #aabbcc00
line-ver-color = #aabbcc00
line-wrong-color = #aabbcc00
'' ;
services . gammastep = {
enable = true ;
provider = " g e o c l u e 2 " ;
} ;
services . kanshi = {
enable = true ;
profiles = {
sedetary = {
outputs = [
{
criteria = " e D P - 1 " ;
status = " d i s a b l e " ;
position = " 1 9 2 0 , 3 1 2 " ;
}
{
criteria = " H D M I - A - 1 " ;
position = " 0 , 0 " ;
}
] ;
exec = [ " x r d b . X r e s o u r c e s " ] ;
} ;
nomad = {
outputs = [ {
criteria = " e D P - 1 " ;
status = " e n a b l e " ;
position = " 1 9 2 0 , 3 1 2 " ;
} ] ;
exec = [ " x r d b . X r e s o u r c e s " ] ;
} ;
} ;
} ;
programs . mako = {
enable = true ;
borderSize = 2 ;
padding = " 5 " ;
margin = " 1 5 " ;
layer = " o v e r l a y " ;
2022-08-13 10:08:59 -03:00
font = " ${ font . interface } ${ toString font . size . small } " ;
textColor = color . txt ;
2022-08-05 11:20:13 -03:00
backgroundColor = color . bg ;
borderColor = accent . color ;
progressColor = " o v e r ${ accent . color } 8 8 " ;
defaultTimeout = 10000 ;
2022-08-13 10:08:59 -03:00
extraConfig = ''
[ app-name = volumesh ]
default-timeout = 5000
group-by = app-name
format = <b> % s < /b > \ n % b
'' ;
2022-08-05 11:20:13 -03:00
2022-08-13 10:08:59 -03:00
# # {{@@ header() @@}}
# # text
2022-08-05 11:20:13 -03:00
# # features
# icons=1
# markup=1
# actions=1
# default-timeout=10000
# # position
# layer=overlay
} ;
2022-08-23 23:42:36 -03:00
home . packages = with pkgs ; [
waybar
dhist
bmenu
wdmenu
wlauncher
volumesh
pamixer
libnotify
xdg-utils
screenshotsh
] ;
systemd . user . services = {
mako = {
Unit = {
Description = " N o t i f i c a t i o n d a e m o n " ;
PartOf = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
After = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
} ;
Service = {
ExecStart = " ${ pkgs . mako } / b i n / m a k o " ;
Restart = " o n - f a i l u r e " ;
} ;
Install = { WantedBy = [ " s w a y - s e s s i o n . t a r g e t " ] ; } ;
} ;
} ;
2022-08-30 22:01:06 -03:00
home . file = { " . l o c a l / s h a r e / b a c k g r o u n d s " . source = ./backgrounds ; } ;
2022-08-05 11:20:13 -03:00
} ;
}