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
output = $ ( printf " H D M I \n H e a d p h o n e s " | $ { pkgs . bmenu } /bin/bmenu - b )
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 = {
wayland . windowManager . sway = {
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 " ; } ; } ;
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 " ;
} ;
assigns = {
" 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 " ; }
] ;
} ;
modes = let return_mode = lib . mapAttrs ( k : v : " ${ v } ; m o d e d e f a u l t " ) ;
in {
audio = {
$ { key . tabL } = " v o l u m e s d e c r e a s e " ;
} // return_mode {
" s p a c e " = " e x e c m p c t o g g l e " ;
" e s c a p e " = " " ;
" s " = " e x e c ${ pulse_sink } / b i n / p u l s e _ s i n k " ;
} ;
} ;
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
mod = " M o d 4 " ;
menu = " ${ pkgs . bmenu } / b i n / b m e n u r u n " ;
terminal = " a l a c r i t t y " ;
workspace_binds = {
" ${ mod } + 1 " = " w o r k s p a c e n u m b e r 1 " ;
" ${ mod } + 2 " = " w o r k s p a c e n u m b e r 2 " ;
" ${ mod } + 3 " = " w o r k s p a c e n u m b e r 3 " ;
" ${ mod } + 4 " = " w o r k s p a c e n u m b e r 4 " ;
" ${ mod } + 5 " = " w o r k s p a c e n u m b e r 5 " ;
" ${ mod } + 6 " = " w o r k s p a c e n u m b e r 6 " ;
" ${ mod } + 7 " = " w o r k s p a c e n u m b e r 7 " ;
" ${ mod } + 8 " = " w o r k s p a c e n u m b e r 8 " ;
" ${ mod } + 9 " = " w o r k s p a c e n u m b e r 9 " ;
" ${ mod } + 0 " = " w o r k s p a c e n u m b e r 1 0 " ;
" ${ mod } + S h i f t + 1 " = " 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 1 " ;
" ${ mod } + S h i f t + 2 " = " 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 2 " ;
" ${ mod } + S h i f t + 3 " = " 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 3 " ;
" ${ mod } + S h i f t + 4 " = " 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 4 " ;
" ${ mod } + S h i f t + 5 " = " 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 5 " ;
" ${ mod } + S h i f t + 6 " = " 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 6 " ;
" ${ mod } + S h i f t + 7 " = " 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 7 " ;
" ${ mod } + S h i f t + 8 " = " 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 8 " ;
" ${ mod } + S h i f t + 9 " = " 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 9 " ;
" ${ mod } + S h i f t + 0 " = " 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 1 0 " ;
} ;
prev_next_binds = let
join_dict_arr = builtins . foldl' ( a : v : a // v ) { } ;
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
" " ;
prev_binds = map ( key : {
" ${ maybe_window key } ${ mod } + ${ key } " = " w o r k s p a c e p r e v _ o n _ o u t p u t " ;
} ) [ 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 " ] ;
next_binds = map ( key : {
" ${ maybe_window key } ${ mod } + ${ key } " = " w o r k s p a c e n e x t _ o n _ o u t p u 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 " ] ;
in join_dict_arr ( prev_binds ++ next_binds ) ;
movement_binds = {
" ${ mod } + ${ key . left } " = " f o c u s l e f t " ;
" ${ mod } + ${ key . down } " = " f o c u s d o w n " ;
" ${ mod } + ${ key . up } " = " f o c u s u p " ;
" ${ mod } + ${ key . right } " = " f o c u s r i g h t " ;
" ${ mod } + L e f t " = " f o c u s l e f t " ;
" ${ mod } + D o w n " = " f o c u s d o w n " ;
" ${ mod } + U p " = " f o c u s u p " ;
" ${ mod } + R i g h t " = " f o c u s r i g h t " ;
" ${ mod } + S h i f t + ${ key . left } " = " m o v e l e f t " ;
" ${ mod } + S h i f t + ${ key . down } " = " m o v e d o w n " ;
" ${ mod } + S h i f t + ${ key . up } " = " m o v e u p " ;
" ${ mod } + S h i f t + ${ key . right } " = " m o v e r i g h t " ;
" ${ mod } + S h i f t + L e f t " = " m o v e l e f t " ;
" ${ mod } + S h i f t + D o w n " = " m o v e d o w n " ;
" ${ mod } + S h i f t + U p " = " m o v e u p " ;
" ${ mod } + S h i f t + R i g h t " = " m o v e r i g h t " ;
" ${ mod } + C o n t r o l + ${ key . left } " = " r e s i z e s h r i n k w i d t h " ;
" ${ mod } + C o n t r o l + ${ key . down } " = " r e s i z e g r o w h e i g h t " ;
" ${ mod } + C o n t r o l + ${ key . up } " = " r e s i z e s h r i n k h e i g h t " ;
" ${ mod } + C o n t r o l + ${ key . right } " = " r e s i z e g r o w w i d t h " ;
" ${ mod } + C o n t r o l + L e f t " = " r e s i z e s h r i n k w i d t h " ;
" ${ mod } + C o n t r o l + D o w n " = " r e s i z e g r o w h e i g h t " ;
" ${ mod } + C o n t r o l + U p " = " r e s i z e s h r i n k h e i g h t " ;
" ${ mod } + C o n t r o l + R i g h t " = " r e s i z e g r o w w i d t h " ;
" ${ mod } + m o d 1 + ${ key . left } " = " f o c u s o u t p u t l e f t " ;
" ${ mod } + m o d 1 + ${ key . down } " = " f o c u s o u t p u t d o w n " ;
" ${ mod } + m o d 1 + ${ key . up } " = " f o c u s o u t p u t u p " ;
" ${ mod } + m o d 1 + ${ key . right } " = " f o c u s o u t p u t r i g h t " ;
" ${ mod } + m o d 1 + L e f t " = " f o c u s o u t p u t l e f t " ;
" ${ mod } + m o d 1 + D o w n " = " f o c u s o u t p u t d o w n " ;
" ${ mod } + m o d 1 + U p " = " f o c u s o u t p u t u p " ;
" ${ mod } + m o d 1 + R i g h t " = " f o c u s o u t p u t r i g h t " ;
" ${ mod } + m o d 1 + S h i f t + ${ key . left } " = " m o v e w o r k s p a c e o u t p u t l e f t " ;
" ${ mod } + m o d 1 + S h i f t + ${ key . down } " = " m o v e w o r k s p a c e o u t p u t d o w n " ;
" ${ mod } + m o d 1 + S h i f t + ${ key . up } " = " m o v e w o r k s p a c e o u t p u t u p " ;
" ${ mod } + m o d 1 + S h i f t + ${ key . right } " = " m o v e w o r k s p a c e o u t p u t r i g h t " ;
" ${ mod } + m o d 1 + S h i f t + L e f t " = " m o v e w o r k s p a c e o u t p u t l e f t " ;
" ${ mod } + m o d 1 + S h i f t + D o w n " = " m o v e w o r k s p a c e o u t p u t d o w n " ;
" ${ mod } + m o d 1 + S h i f t + U p " = " m o v e w o r k s p a c e o u t p u t u p " ;
" ${ mod } + m o d 1 + S h i f t + R i g h t " = " m o v e w o r k s p a c e o u t p u t r i g h t " ;
} ;
audio_binds = {
XF86AudioRaiseVolume =
" e x e c p a c t l s e t - s i n k - v o l u m e @ D E F A U L T _ S I N K @ + 1 0 % " ;
XF86AudioLowerVolume =
" e x e c p a c t l s e t - s i n k - v o l u m e @ D E F A U L T _ S I N K @ - 1 0 % " ;
XF86AudioMute = " e x e c p a c t l s e t - s i n k - m u t e @ D E F A U L T _ S I N K @ t o g g l e " ;
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 " ;
} ;
in {
" ${ 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 } + s " = " e x e c ${ menu } " ;
" ${ mod } + m " = " m o d e a u d i o " ;
" ${ mod } + b " = " s p l i t h " ;
" ${ mod } + v " = " s p l i t v " ;
" ${ mod } + f " = " f u l l s c r e e n t o g g l e " ;
" ${ mod } + a " = " f o c u s p a r e n t " ;
# "${mod}+s" = "layout stacking";
" ${ mod } + w " = " l a y o u t t a b b e d " ;
# "${mod}+e" = "layout toggle split";
" ${ 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 + m i n u s " = " m o v e s c r a t c h p a d " ;
" ${ mod } + m i n u s " = " s c r a t c h p a d s h o w " ;
" ${ 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'";
" ${ mod } + r " = " m o d e r e s i z e " ;
} // workspace_binds // prev_next_binds // movement_binds // audio_binds
// system_binds
# // map (key: "$mod+${key} workspace prev_on_output") [ key.tabL "bracketleft" "Prior" "button9" "button4" ]
# // map (key: "$mod+${key} workspace next_on_output") [ key.tabL "bracketleft" "Prior" "button9" "button4" ]
;
terminal = pkgs . alacritty . executable ;
} ;
} ;
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 " ;
backgroundColor = color . bg ;
borderColor = accent . color ;
progressColor = " o v e r ${ accent . color } 8 8 " ;
defaultTimeout = 10000 ;
# # {{@@ header() @@}}
# # text
# font={{@@ font.interface @@}} {{@@ font.size.small @@}}
# text-color={{@@ color.txt @@}}
# # colors
# background-color={{@@ color.bg @@}}{{@@ opacity | clamp_to_hex @@}}
# border-color={{@@ accent_color @@}}
# progress-color=over {{@@ accent_color @@}}88
# # decoration
# border-size=2
# padding=5
# margin=15
# # features
# icons=1
# markup=1
# actions=1
# default-timeout=10000
# # position
# layer=overlay
# [app-name=volumesh]
# default-timeout=5000
# group-by=app-name
# format=<b>%s</b>\n%b
# [app-name=dotdrop]
# default-timeout=5000
# group-by=app-name
# format=<b>%s</b>\n%b
# # vim: ft=ini
} ;
} ;
}