1
Fork 0

feat: bluetooth, better keybinds for vim and direnv?

This commit is contained in:
Matei Adriel 2022-04-05 20:42:32 +03:00
parent 5c93d9dbed
commit 79b65f3640
14 changed files with 129 additions and 31 deletions

View file

@ -47,18 +47,6 @@
manual.manpages.enable = false; manual.manpages.enable = false;
}; };
hardware = {
pulseaudio = {
enable = true;
# NixOS allows either a lightweight build (default) or full build of PulseAudio to be installed.
# Only the full build has Bluetooth support, so it must be selected here.
package = pkgs.pulseaudioFull;
# Extra codecs
extraModules = [ pkgs.pulseaudio-modules-bt ];
};
};
system.stateVersion = "21.11"; system.stateVersion = "21.11";

View file

@ -11,5 +11,6 @@ function fish_user_key_bindings
# Use jj to exit insert mode # Use jj to exit insert mode
bind -e -M insert \e # unbinds esc bind -e -M insert \e # unbinds esc
bind -M insert -m default jj 'commandline -f repaint' bind -M insert -m default jk 'commandline -f repaint'
bind -M insert -m default kj 'commandline -f repaint'
end end

View file

@ -1,10 +1,11 @@
(defcfg (defcfg
;; For Linux ;; For Linux
;; input (device-file "$DEVICE") ;; gets dynamically replaced by nix
input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd") input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
output (uinput-sink "My KMonad output" output (uinput-sink "My KMonad output"
;; To understand the importance of the following line, see the section on ;; To understand the importance of the following line, see the section on
;; Compose-key sequences at the near-bottom of this file. ;; Compose-key sequences at the near-bottom of this file.
"/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap -option compose:ralt") "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap" -option compose:ralt")
cmp-seq ralt ;; Set the compose key to `RightAlt' cmp-seq ralt ;; Set the compose key to `RightAlt'
cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press
@ -27,9 +28,6 @@
|# |#
(defalias (defalias
mth (layer-toggle math)
Mth (layer-toggle capital-math)
ga #(ralt a h) ;; alpha ga #(ralt a h) ;; alpha
gb #(ralt b h) ;; beta gb #(ralt b h) ;; beta
gg #(ralt g h) ;; gamma gg #(ralt g h) ;; gamma
@ -60,14 +58,30 @@
ex #(ralt l e) ;; ∃ ex #(ralt l e) ;; ∃
lar #(ralt < -) ;; ← lar #(ralt < -) ;; ←
rar #(ralt - >) ;; → rar #(ralt - >) ;; →
and #(ralt l c) ;; and symbol
or #(ralt l d) ;; or symbol
eq #(ralt e q) ;; Equivalence
alp #(ralt f \( ) ;; angled left parenthesis alp #(ralt f \( ) ;; angled left parenthesis
arp #(ralt f \) ) ;; angled right parenthesis arp #(ralt f \) ) ;; angled right parenthesis
shrugFace #(ralt l s h r) ;; shrug face shrugFace #(ralt l s h r) ;; shrug face
topBar #(ralt t -) ;; ¯ topBar #(ralt t -) ;; ¯
)
;; layers
(defalias
mth (layer-toggle math)
Mth (layer-toggle capital-math)
mathExtra (layer-toggle math-extra)
)
;; more "special" stuff
(defalias
shr #(@topBar \ \_ \_ \( @shrugFace \) \_ / @topBar) ;; ¯\_(ツ)_/¯ shr #(@topBar \ \_ \_ \( @shrugFace \) \_ / @topBar) ;; ¯\_(ツ)_/¯
ml (tap-hold-next-release 200 @gl @mathExtra)
mll l
) )
(defsrc (defsrc
@ -92,8 +106,17 @@
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ @ex _ _ _ _ _ @alp @arp @neg _ _ _ _ _ @ex _ _ _ _ _ @alp @arp @neg _ _
_ @shr @go @ge _ @gt _ @gu _ @go @gp _ _ _ _ @shr @go @ge _ @gt _ @gu _ @go @gp _ _ _
_ @ga @gs _ _ @gg @gth @gps @gph @gl _ _ _ _ @ga @gs _ _ @gg @gth @gps @gph @ml _ _ _
@Mth _ @gx _ @fal @gb _ @gm @lar @rar _ _ @Mth _ @gx _ @fal @gb _ @gm @lar @rar _ _
_ _ _ _ @mathExtra _ _
)
(deflayer math-extra
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ @eq _ _ _ _ _ @or _ _ _ _
_ @and _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _
) )
@ -106,4 +129,3 @@
_ _ _ _ _ _ _ _ _ _ _ _ _ _
) )

View file

@ -38,3 +38,8 @@
<Multi_key> <f> <parenleft> : "⟨" U0357 # FANCY LEFT PAREN <Multi_key> <f> <parenleft> : "⟨" U0357 # FANCY LEFT PAREN
<Multi_key> <f> <parenright> : "⟩" U0358 # FANCY RIGHT PAREN <Multi_key> <f> <parenright> : "⟩" U0358 # FANCY RIGHT PAREN
<Multi_key> <e> <q> : "⟷" U0359 # LOGICAL EQUIVALENCE
<Multi_key> <l> <c> : "∧" U0360 # LOGICAL CONJUNCTION
<Multi_key> <l> <d> : "" U0361 # LOGICAL DISJUNCTION

View file

@ -11,7 +11,7 @@ Table of my own keybinds. Here as documentation for myself. I am yet to include
| ---------------- | ------------------------------------------- | ------------------ | | ---------------- | ------------------------------------------- | ------------------ |
| vv | Create vertical split | | | vv | Create vertical split | |
| \<Space>\<Space> | Save | | | \<Space>\<Space> | Save | |
| jj | Exit insert mode | | | _jk_ | Exit insert mode | |
| _\<leader>k_ | Insert digraph | | | _\<leader>k_ | Insert digraph | |
| _\<leader>a_ | Swap last 2 used buffers | | | _\<leader>a_ | Swap last 2 used buffers | |
| C-n | Open tree | nvim-tree | | C-n | Open tree | nvim-tree |

View file

@ -21,16 +21,15 @@ function M.mapSilent(mode, lhs, rhs, opts)
end end
function M.setup() function M.setup()
M.map("i", "jj", "<Esc>") -- Remap Esc to jj
M.map("n", "<Space><Space>", ":w<cr>") -- Double space to sace
M.map("n", "vv", "<C-w>v") -- Create vertical split M.map("n", "vv", "<C-w>v") -- Create vertical split
if arpeggio ~= nil then if arpeggio ~= nil then
-- Create chords -- Create chords
arpeggio.chord("n", "jl", ":w<cr>") -- Double space to sace
arpeggio.chord("i", "jk", "<Esc>") -- Remap Esc to jk
arpeggio.chord("i", "<Leader>k", "<C-k><cr>") -- Rebind digraph insertion to leader+k arpeggio.chord("i", "<Leader>k", "<C-k><cr>") -- Rebind digraph insertion to leader+k
arpeggio.chord("inv", "<Leader>a", "<C-6><cr>") -- Rebind switching to the last pane using leader+a arpeggio.chord("inv", "<Leader>a", "<C-6><cr>") -- Rebind switching to the last pane using leader+a
end end
end end
return M return M

View file

@ -35,8 +35,8 @@ function M.setup()
arpeggio.chord("inv", "mo", '<Plug>MarkersJumpOutside') arpeggio.chord("inv", "mo", '<Plug>MarkersJumpOutside')
for key, brackets in pairs(extraBrackets) do for key, brackets in pairs(extraBrackets) do
for _, v in ipairs(brackets) do
A.augroup('custom-brackets' .. key, function() A.augroup('custom-brackets' .. key, function()
for _, v in ipairs(brackets) do
local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "") local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "")
local glob = '*.' .. key local glob = '*.' .. key
@ -46,8 +46,8 @@ function M.setup()
end end
A.autocmd('BufEnter', glob, action) A.autocmd('BufEnter', glob, action)
end)
end end
end)
end end
end end

View file

@ -19,6 +19,7 @@
./neovim.nix ./neovim.nix
./tmux.nix ./tmux.nix
./kmonad.nix ./kmonad.nix
./direnv.nix
]; ];
} }

View file

@ -0,0 +1,10 @@
# https://github.com/nix-community/nix-direnv
{ pkgs, ... }: {
home-manager.users.adrielus = {
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
# optional for nix flakes support in home-manager 21.11, not required in home-manager unstable or 22.05
programs.direnv.nix-direnv.enableFlakes = true;
};
}

View file

@ -1,12 +1,33 @@
{ pkgs, ... }: { pkgs, lib, ... }:
let kmonadRoot = ../../dotfiles/kmonad; in let
kmonadRoot = ../../dotfiles/kmonad;
kmonadInstances = [{
config = kmonadRoot + "/keymap.kbd";
inputDevices = [
"/dev/input/by-path/platform-i8042-serio-0-event-kbd"
];
}];
createKmonadInstances = ({ config, inputDevices }:
let
configContent = builtins.readFile config;
in
lib.lists.map
(device:
"${pkgs.writeTextDir "configs/kmonad.kbd" (builtins.replaceStrings [ "$DEVICE" ] [ device ] configContent)}/kmonad.kbd"
)
inputDevices
);
in
{ {
users.extraUsers.adrielus.extraGroups = [ "input" "uinput" ]; users.extraUsers.adrielus.extraGroups = [ "input" "uinput" ];
services = { services = {
kmonad = { kmonad = {
enable = true; enable = true;
configfiles = [ (kmonadRoot + "/keymap.kbd") ]; # configfiles = lib.lists.concatMap createKmonadInstances kmonadInstances;
configfiles = lib.lists.map ({ config, ... }: config) kmonadInstances;
}; };
xserver = { xserver = {

View file

@ -64,6 +64,7 @@ in
purescript-vim # purescript syntax highlighting purescript-vim # purescript syntax highlighting
nvim-comment # allows toggling line-comments nvim-comment # allows toggling line-comments
nvim-treesitter # use treesitter for syntax highlighting nvim-treesitter # use treesitter for syntax highlighting
nvim-treesitter-textobjects # the lean plugin told me to add this
startup-nvim # splash screen startup-nvim # splash screen
vim-devicons # nice looking icons vim-devicons # nice looking icons
nvim-web-devicons # fork of vim-devicons? nvim-web-devicons # fork of vim-devicons?

View file

@ -7,6 +7,7 @@ let
themePackage = builtins.getAttr theme pkgs.myFishPlugins.themes; # Dynamically pick the theme path themePackage = builtins.getAttr theme pkgs.myFishPlugins.themes; # Dynamically pick the theme path
in in
{ {
users.defaultUserShell = pkgs.fish;
home-manager.users.adrielus = { home-manager.users.adrielus = {
# Source every file in the theme # Source every file in the theme
xdg.configFile."fish/conf.d/plugin-${theme}.fish".text = lib.mkAfter '' xdg.configFile."fish/conf.d/plugin-${theme}.fish".text = lib.mkAfter ''

48
modules/bluetooth.nix Normal file
View file

@ -0,0 +1,48 @@
# Taken from https://nixos.wiki/wiki/Bluetooth
{ pkgs, ... }: {
hardware.bluetooth = {
enable = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
};
};
};
services.blueman.enable = true;
# TODO: investigate why this does not work
# systemd.user.services.mpris-proxy = {
# Unit.Description = "Mpris proxy";
# Unit.After = [ "network.target" "sound.target" ];
# Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy";
# Install.WantedBy = [ "default.target" ];
# };
hardware = {
pulseaudio = {
enable = true;
# NixOS allows either a lightweight build (default) or full build of PulseAudio to be installed.
# Only the full build has Bluetooth support, so it must be selected here.
package = pkgs.pulseaudioFull;
# Extra codecs
extraModules = [ pkgs.pulseaudio-modules-bt ];
configFile = pkgs.writeText "default.pa" ''
load-module module-bluetooth-policy
load-module module-bluetooth-discover
## module fails to load with
## module-bluez5-device.c: Failed to get device path from module arguments
## module.c: Failed to load module "module-bluez5-device" (argument: ""): initialization failed.
# load-module module-bluez5-device
# load-module module-bluez5-discover
'';
extraConfig = ''
load-module module-switch-on-connect
'';
};
};
}

View file

@ -9,5 +9,6 @@
./xserver.nix ./xserver.nix
./users.nix ./users.nix
./nix.nix ./nix.nix
./bluetooth.nix
]; ];
} }