nixos-private-dots/modules/home-manager/wm/sxhkd.nix
2024-08-07 19:12:33 +03:00

114 lines
8.7 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Можно запускать софт через "${pkgs.betterlockscreen}/bin/betterlockscreen -l dimblur";
# Но мне лень столько текста делать. И так сойдёт
# Стандартный конфиг https://github.com/baskerville/bspwm/blob/master/examples/sxhkdrc
let
notifyMute = ''dunstify "t2" -a "$(if [ "$(pamixer --get-mute)" = "true" ]; then echo " Muted"; else echo " Unmuted"; fi)" -r 91190 -t 8000'';
notifyMicMute = ''dunstify "t2" -a "$(if [ "$(pamixer --default-source --get-mute)" = "true" ]; then echo " Muted"; else echo " Unmuted"; fi)" -r 91190 -t 8000'';
notifyVolume = ''dunstify "t2" -a " Volume: $(pamixer --get-volume)" -r 91190 -t 800'';
# Если указать "t2" перед "-a", то заголовок будет огромным.
# -r 91190: Это идентификатор уведомления (notification ID). Уведомления с одинаковым ID будут заменять друг друга.
# -t 800: Это время в миллисекундах, через которое уведомление будет автоматически закрыто.
# Взято отсюда https://my-take-on.tech/2020/07/03/some-tricks-for-sxhkd-and-bspwm/
rofiClipmenu = "rofi clipmenu -location 1 -m -3 -no-show-icons -theme-str '* \{ font: 10px; \}' -theme-str 'listview \{ spacing: 0; \}' -theme-str 'window \{ width: 20em; \}'";
terminalFirst = "alacritty";
terminalSecond = "kitty";
in {
services.sxhkd = { # Бинды системы https://manpages.org/sxhkd
enable = true;
keybindings = {
#########################################################
## bspwm (описание параметров есть в файле "bspwm.md") ##
#########################################################
"super + shift + ctrl + r" = "pkill -USR1 -x sxhkd; dunstify \"t2\" -a \"󰑓 Sxhkd reloaded\""; # Make sxhkd reload its config files
"super + shift + ctrl + alt + {q,r}" = "bspc {quit,wm -r}"; # Quit/Restart bspwm
# "super + return" = "bspc desktop -l next"; # Fullscreen toggle (немного не тот)
# "super + ctrl + {m,x,y,z}" = "bspc node -g {marked,locked,sticky,private}"; # Set the node flags
"super + l" = "betterlockscreen -l dimblur"; # Lock screen
"super + button{1-3}" = "bspc pointer -g {move,resize_side,resize_corner}"; # Двигать и ресайзить окно мышкой
"super + q" = "bspc node -c"; # Quit. Закрыть приложение
"super + shift + q" = "bspc node -k"; # Kill. Убить приложение, если оно не отвечает
"super + {f,return}" = "bspc node -t ~{floating,fullscreen}"; # Floating/Fullscreen toggle
"super + s" = "bspc node -F"; # Меняет позиционирование с горизонтального на вертикальный и обратно. Мб надо -R
"super + ctrl + alt + {left,right}" = "bspc node -d {next,prev}.local --follow"; # Перекидывает активное окно на предыдущий/следующий воркспейс и следует за ним
"super + {left,down,up,right}" = "bspc node -f {west,south,north,east}"; # Менять фокус приложения в указанном направлении
"super + alt + {left,down,up,right}" = "bspc node -v {-30 0,0 30,0 -30,30 0}"; # Move a floating window
"super + ctrl + alt + down" = "bspc node -s biggest.window --follow"; # Свапает активное окно с самым большим на экране
"super + shift + ctrl + {left,down,up,right}" = "bspc node -n {west,south,north,east} --follow"; # Перемещает активное окно в указанном направлении (не уверен сработает ли, мб надо -s)
"super + shift + {left,down,up,right}" = "bspc node -z {left -30 0,bottom 0 30,top 0 -30,right 30 0}"; # Expand a window by moving one of its side outward
"super + shift + alt + {left,down,up,right}" = "bspc node -z {right -30 0,top 0 30,bottom 0 -30,left 30 0}"; # Contract a window by moving one of its side inward
"super + ctrl + {left,right}" = "bspc desktop -f {prev,next}.local"; # Переключает на предыдущий/следующий воркспейс внутри одного монитора.
"super + escape" = "bspc desktop -f last.local"; # Прошлый воркспейс внутри одного монитора
"super + {_,shift + }{1-9,0}" = "bspc {desktop -f,node -d} '^{1-9,10}'"; # Focus or send to the given desktop
"super + ctrl + down" = "bspk desktop -f next.!occupied"; # Переключает на первый пустой воркспейс
##########
## rofi ##
##########
"super + a" = "rofi -show drun"; # Applications. Запускатор софта
#"super + c" = ""; # Calculator имбовый. Можно даже написать `5600 USD to BTC` или `500 + 25%`.
#"super + p" = ""; # Passwords. Пароли из утилиты pass
"super + v" = "${rofiClipmenu}"; # История буфера обмена. Как ctrl+v, но через win.
#"super + tab" = ""; # Как alt+tab, переключение окон. На нужный воркспейс само перекинет
#"super + alt + t" = ""; # Timer. Думаю сделать через утилиту timer
#"super + shift + n" = ""; # Notification history. История оповещений. Мб не делать
#"super + backspace" = ""; # PowerMenu. Выключение пк
##################
## applications ##
##################
"super + b" = "librewolf"; # Browser LibreWolf. Основа
"super + shift + b" = "firefox"; # Browser Firefox. Паблик активность
"super + shift + ctrl + b" = "chromium"; # Browser Chromium. Пусть будет
"super + n" = "obsidian"; # Note taking app (obsidian)
"super + e" = "thunar"; # Explorer. Thunar file manager
"super + i" = "code"; # IDE, text editor
"super + m" = "${terminalFirst} -e btop"; # Monitor of resources (btop)
"super + g" = "planify"; # Goals. Todo manager. Task tracker
"super + shift + c" = "xcolor -s"; # Color picker. Получить hex в буфер обмена
"super + ctrl + c" = "xcolor -s -f rgb"; # Color picker. Получить rgb в буфер обмена
##############
## terminal ##
##############
"super + t" = terminalFirst; # Терминал alacritty
"super + shift + t" = "${terminalFirst} --class floating-terminal"; # Floating терминал alacritty в центре экрана 600x300px
"super + ctrl + t" = terminalSecond; # Tерминал kitty
"super + ctrl + shift + t" = "${terminalSecond} --class floating-terminal"; # Floating терминал kitty в центре экрана 600x300px
#######################
## Колдунские кнопки ##
#######################
# В pamixer для настроек микро надо добавлять "--default-source"
"XF86AudioMute" = "pamixer -t; ${notifyMute}"; # Toggle mute
"XF86AudioMicMute" = "pamixer --default-source -t; ${notifyMicMute}"; # Toggle microphone mute
"XF86Audio{Lower,Raise}Volume" = "pamixer -{d,i} 5; ${notifyVolume}"; # Decrease/Increase volume
"XF86Audio{Play,Pause}" = "playerctl play-pause"; # Play/Pause
"XF86Audio{Next,Prev}" = "playerctl {next,previous}"; # Next/Previous track
# Простое редактирование яркости будет менять на 1% (Символ _ означает ничего, просто бинд яркости)
# С зажатым шифтом будет редактировать яркость на 10%
# С зажатой клавишей win будет менять между минимальным и максимальным значениями
# Не знаю работает ли эта команда, у меня не ноут. Добавил как написано в "man sxhkd"
"{_,shift + ,super + }XF86MonBrightness{Down,Up}" = "bright {-1,-10,min,+1,+10,max}"; # Increase/Decrease brightness
###########
## other ##
###########
};
};
}