feat(gs): Bind a push-to-talk key
Bind a key, which I've located at the top-left of my right keyboard, to a momentary push-to-talk by muting and unmuting my pulseaudio source using xbindkeys. I had been putting this off for a while because i3 doesn't support binding different commands to keyup than to keydown events, but the xbindkeys support appears to have solved that reasonably well, plus it's got Scheme in it so that's cool. If there's demand for it I'll gladly expose this as a reusable, configurable home-manager module outside my users dir in the depot. Change-Id: Ie591c93037dbdac364d5d8a718d99edb70780789 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1975 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
		
							parent
							
								
									65967bbbb1
								
							
						
					
					
						commit
						6f2094c146
					
				
					 3 changed files with 46 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -37,7 +37,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		|||
                                                                    KC_LBRACKET,
 | 
			
		||||
                                        GUI_T(KC_NO), LSFT_T(KC_BSPACE),    KC_COLN,
 | 
			
		||||
 | 
			
		||||
      KC_RIGHT,     KC_6,   KC_7,   KC_8,       KC_9,       KC_0,               KC_MINUS,
 | 
			
		||||
      KC_MY_COMPUTER, KC_6,   KC_7,   KC_8,       KC_9,       KC_0,               KC_MINUS,
 | 
			
		||||
      KC_RALT,      KC_Y,   KC_U,   KC_I,       KC_O,       KC_P,               KC_BSLASH,
 | 
			
		||||
                    KC_H,   KC_J,   KC_K,       KC_L,       LT(2,KC_SCOLON),    LT(1,KC_QUOTE),
 | 
			
		||||
      KC_MINUS,     KC_N,   KC_M,   KC_COMMA,   KC_DOT,     CTL_T(KC_SLASH),    KC_RSFT,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ in {
 | 
			
		|||
    ../modules/games.nix
 | 
			
		||||
    ../modules/rtlsdr.nix
 | 
			
		||||
    ../modules/urbint.nix
 | 
			
		||||
    ../modules/ptt.nix
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  # for when hacking
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										44
									
								
								users/glittershark/system/home/modules/ptt.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								users/glittershark/system/home/modules/ptt.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,44 @@
 | 
			
		|||
{ config, lib, pkgs, ... }:
 | 
			
		||||
 | 
			
		||||
let
 | 
			
		||||
 | 
			
		||||
  pttKeycode = "152";
 | 
			
		||||
  sourceID = "3";
 | 
			
		||||
 | 
			
		||||
  mute = pkgs.writeShellScript "mute-mic" ''
 | 
			
		||||
    xset -r ${pttKeycode}
 | 
			
		||||
    ${pkgs.pulseaudio}/bin/pactl set-source-mute ${sourceID} 1
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  unmute = pkgs.writeShellScript "unmute-mic" ''
 | 
			
		||||
    xset -r ${pttKeycode}
 | 
			
		||||
    ${pkgs.pulseaudio}/bin/pactl set-source-mute ${sourceID} 0
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
in
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  home.packages = with pkgs; [
 | 
			
		||||
    xbindkeys
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  home.file.".xbindkeysrc.scm".text = ''
 | 
			
		||||
    (xbindkey '("c:${pttKeycode}") "${unmute}")
 | 
			
		||||
    (xbindkey '(release "c:${pttKeycode}") "${mute}")
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  systemd.user.services."xbindkeys" = {
 | 
			
		||||
    Unit = {
 | 
			
		||||
      Description = "Keybind daemon for push-to-talk";
 | 
			
		||||
      After = [ "graphical-session-pre.target" ];
 | 
			
		||||
      PartOf = [ "graphical-session.target" ];
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Install = { WantedBy = [ "graphical-session.target" ]; };
 | 
			
		||||
 | 
			
		||||
    Service = {
 | 
			
		||||
      ExecStart = "${pkgs.xbindkeys}/bin/xbindkeys -n -v";
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue