2022-08-05 11:20:13 -03:00
{ config , pkgs , lib , . . . }:
let
2023-01-24 11:42:49 -03:00
inherit ( pkgs . uservars ) key accent font theme ;
inherit ( theme ) color ;
2022-09-05 18:43:29 -03:00
color_picker = pkgs . writeShellScript " c o l o r _ p i c k e r " ''
grim - g " $ ( s l u r p - b a a b b c c 0 0 - p ) " - |
convert - txt:- |
grep - oE ' #[0-9A-Fa-f]{6}' |
wl-copy - n
notify-send " $ ( w l - p a s t e ) " " C o p i e d t o c l i p b o a r d "
'' ;
2022-08-05 11:20:13 -03:00
_lock = pkgs . writeShellScriptBin " _ l o c k " ''
2022-12-06 00:34:46 -03:00
$ { pkgs . swaylock } /bin/swaylock - f
2022-08-05 11:20:13 -03:00
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 " ''
2022-12-05 12:49:30 -03:00
if systemctl - - user status swayidle > /dev/null ; then
2022-08-05 11:20:13 -03:00
systemctl - - user stop swayidle . service
else
systemctl - - user start swayidle . service
fi
'' ;
2023-01-22 18:12:04 -03:00
in
{
2022-11-07 11:24:40 -03:00
imports = [ ./theme.nix ] ;
2022-08-05 11:20:13 -03:00
config = {
2023-01-22 18:12:04 -03:00
wayland . windowManager . sway =
let
mod = " M o d 4 " ;
menu = " w l a u n c h e r " ;
terminal = " a l a c r i t t y " ;
2022-08-18 13:58:35 -03:00
2023-01-22 18:12:04 -03:00
# Utility funcion
# Input: [{v1=1;} {v2=2;}]
# Output: {v1=1;v2=2;}
mergeAttrsSet = lib . foldAttrs ( n : _ : n ) { } ;
2022-08-18 13:58:35 -03:00
2023-01-22 18:12:04 -03:00
forEachMerge = list : func : mergeAttrsSet ( lib . forEach list func ) ;
in
{
enable = true ;
config = {
bars = [ ] ;
window . titlebar = false ;
gaps = {
smartGaps = true ;
smartBorders = " o n " ;
inner = 5 ;
2022-08-05 11:20:13 -03:00
} ;
2023-01-22 18:12:04 -03:00
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 = {
" * " = {
adaptive_sync = " o n " ;
bg = " ${ theme . background } f i l l " ;
} ;
" D P - 1 " = {
mode = " 1 9 2 0 x 1 0 8 0 @ 1 4 4 . 0 0 0 H z " ;
} ;
2022-11-29 20:39:41 -03:00
} ;
2023-01-22 18:12:04 -03:00
fonts = {
names = [ font . interface ] ;
size = font . size . medium * 1 .0 ;
2022-11-29 20:39:41 -03:00
} ;
2023-01-22 18:12:04 -03:00
input . " t y p e : t o u c h p a d " = {
# Disable While Typing
dwt = " e n 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 " ;
} ;
# setup cursor based on home.pointerCursor
seat . " * " = {
xcursor_theme = " ${ config . home . pointerCursor . name } ${
2022-08-07 23:58:05 -03:00
toString config . home . pointerCursor . size
} " ;
2022-08-05 11:20:13 -03:00
} ;
2023-01-22 18:12:04 -03:00
assigns = {
" 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 " ; }
] ;
" 7 " = [
{ app_id = " t h u n d e r b i r d " ; }
2023-01-31 23:43:36 -03:00
{ app_id = " a s t r o i d " ; }
2022-08-07 15:54:56 -03:00
] ;
2023-01-22 18:12:04 -03:00
" 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-07 16:02:21 -03:00
] ;
2023-01-22 18:12:04 -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 " ; }
{ app_id = " W e b C o r d " ; }
] ;
} ;
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 " ) ;
in
{
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 {
" s p a c e " = " e x e c m p c t o g g l e " ;
" e s c a p e " = " " ;
" q " = " " ;
" m " = " e x e c v o l u m e s h - t " ;
" s " = " e x e c ${ pkgs . pulse_sink } / b i n / p u l s e _ s i n k " ;
2023-01-28 15:31:51 -03:00
" d " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u d e l e t e " ;
" f " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u s e a r c h " ;
" S h i f t + y " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u y a n k " ;
" C t r l + a " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u p a d d " ;
" C t r l + s " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u p s a v e " ;
" C t r l + o " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u p l o a d " ;
" C t r l + d " = " e x e c ${ pkgs . musmenu } / b i n / m u s m e n u p d e l e t e " ;
2023-01-24 10:09:12 -03:00
} // {
" p " = " m o d e p l a y e r c t l " ;
2023-01-28 15:31:51 -03:00
" C t r l + c " = " e x e c m u s m e n u p c l e a r " ;
2023-01-22 18:12:04 -03:00
} ;
2023-01-24 10:09:12 -03:00
playerctl = code_binds
( return_mode {
" s p a c e " = " e x e c ${ pkgs . playerctl } / b i n / p l a y e r c t l t o g g l e " ;
" e s c a p e " = " " ;
" q " = " " ;
} ) ;
2023-01-22 18:12:04 -03:00
passthrough = {
" ${ 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 ' " ;
} ;
} ;
floating = {
modifier = " M o d 4 " ;
criteria = [ { class = " f i l e _ p i c k e r " ; } { app_id = " f i l e _ p i c k e r " ; } ] ;
} ;
keybindings =
let
# 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-07 16:02:21 -03:00
2023-01-22 18:12:04 -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
" " ;
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 " [
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 "
] ;
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 "
] ;
in
mergeAttrsSet ( prev_binds ++ next_binds ) ;
2022-08-07 16:58:23 -03:00
2023-01-22 18:12:04 -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
2023-01-22 18:12:04 -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 " ;
2022-08-07 21:40:27 -03:00
2023-01-22 18:12:04 -03:00
## TODO:
# "${mod}+Shift+minus" = "move scratchpad";
# "${mod}+minus" = "scratchpad show";
} ;
audio_binds = {
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 " ;
XF86AudioMute = " e x e c v o l u m e s h - t " ;
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 " ;
} ;
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 " ;
} ;
other_binds = {
" ${ mod } + p " = " e x e c ${ pkgs . wpass } / b i n / w p a s s " ;
" ${ mod } + s " = " e x e c ${ menu } " ;
" ${ mod } + g " = " e x e c ${ pkgs . demoji } / b i n / d e m o j i - - l a n g p t - - f a l l b a c k - - c o p y - - ${ pkgs . wdmenu } / b i n / w d m e n u " ;
" ${ mod } + c " = " e x e c ${ color_picker } " ;
" ${ 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 } + S h i f t + s " = " e x e c g r i m - | s w a p p y - f - " ;
" ${ mod } + C t r l + v " = " e x e c w l - p a s t e | t e s s e r a c t - l p o r - - | w l - c o p y " ;
" ${ mod } + k " = " e x e c s h o w k e y s " ;
" ${ mod } + x " = " k i l l " ;
" ${ mod } + m " = " m o d e a u d i o " ;
" ${ 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 ' " ;
" ${ 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 } + c t r l + s p a c e " = " s t i c k y 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
screenshot_binds
] ;
terminal = pkgs . alacritty . executable ;
} ;
extraConfig = ''
for_window [ title = . * ] inhibit_idle fullscreen
exec $ { pkgs . dbus-sway-environment } /bin/dbus-sway-environment
exec swaymsg workspace 2
'' ;
2022-08-05 11:20:13 -03:00
} ;
services . swayidle = {
enable = true ;
timeouts = [
{
timeout = 360 ;
2022-12-06 00:34:46 -03:00
command = " ${ pkgs . swaylock } / b i n / s w a y l o c k - f " ;
2022-08-05 11:20:13 -03:00
}
{
timeout = 1800 ;
command = ''
2022-12-06 00:34:46 -03:00
mpc status | grep " ^ [ p l a y i n g ] " > /dev/null || $ { pkgs . sway } /bin/swaymsg " o u t p u t * d p m s o f f " '' ;
resumeCommand = '' ${ pkgs . sway } / b i n / s w a y m s g " o u t p u t * d p m s o n " '' ;
2022-08-05 11:20:13 -03:00
}
] ;
2022-11-08 12:34:59 -03:00
events = [
{
event = " b e f o r e - s l e e p " ;
2022-12-06 00:34:46 -03:00
command = " ${ pkgs . swaylock } / b i n / s w a y l o c k - f " ;
2022-11-08 12:34:59 -03:00
}
{
event = " a f t e r - r e s u m e " ;
command = '' s w a y m s g " o u t p u t * d p m s o n " '' ;
}
] ;
2022-08-05 11:20:13 -03:00
} ;
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 ; [
2022-12-02 16:13:10 -03:00
sway
swaybg
swaylock
2022-08-23 23:42:36 -03:00
waybar
dhist
2023-01-21 01:58:12 -03:00
demoji
2022-08-23 23:42:36 -03:00
bmenu
wdmenu
wlauncher
volumesh
2022-11-14 15:27:25 -03:00
showkeys
2022-08-23 23:42:36 -03:00
pamixer
libnotify
xdg-utils
screenshotsh
2022-10-17 00:18:10 -03:00
wf-recorder
2022-10-18 23:30:35 -03:00
wl-clipboard
2022-10-17 00:18:10 -03:00
wtype
2022-10-24 08:02:22 -03:00
2022-11-14 15:02:18 -03:00
grim
2022-11-05 09:48:20 -03:00
swappy
2022-11-14 14:59:32 -03:00
tesseract5
2022-11-05 09:48:20 -03:00
2022-10-24 08:02:22 -03:00
mpvpaper
2022-08-23 23:42:36 -03:00
] ;
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
} ;
}