create scripts folder
This commit is contained in:
		
							parent
							
								
									cf841d62ea
								
							
						
					
					
						commit
						1018c9f85f
					
				
					 7 changed files with 11 additions and 7 deletions
				
			
		
							
								
								
									
										83
									
								
								scripts/bmenu.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								scripts/bmenu.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,83 @@
 | 
			
		|||
{ config, pkgs, lib, ... }:
 | 
			
		||||
let inherit (pkgs.uservars) key theme color accent font;
 | 
			
		||||
in pkgs.writeScriptBin "bmenu" ''
 | 
			
		||||
  #!${pkgs.fish}/bin/fish
 | 
			
		||||
 | 
			
		||||
  # wrapper around bemenu
 | 
			
		||||
  # bmenu *       - use as dmenu, -p for custom prompt (man bemenu)
 | 
			
		||||
  # bmenu run     - select from .desktop files and run it
 | 
			
		||||
  # bmenu start   - internal option
 | 
			
		||||
 | 
			
		||||
  set swaymsg ${pkgs.sway}/bin/swaymsg
 | 
			
		||||
  set swaymsg ${pkgs.sway}/bin/swaymsg
 | 
			
		||||
 | 
			
		||||
  if test "$argv[1]" = "run"
 | 
			
		||||
      test -n "$argv[2]" && set t "$argv[2]" || set t "terminal"
 | 
			
		||||
 | 
			
		||||
      test -n "$i3SOCK" && set wrapper 'i3-msg exec --'
 | 
			
		||||
      test -n "$SWAYSOCK" && set wrapper 'swaymsg exec --'
 | 
			
		||||
 | 
			
		||||
      exec ${pkgs.j4-dmenu-desktop}/bin/j4-dmenu-desktop \
 | 
			
		||||
          --dmenu="bmenu start -p Iniciar:" \
 | 
			
		||||
          --term "$t" \
 | 
			
		||||
          --wrapper="$wrapper" \
 | 
			
		||||
          --no-generic
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if test -n "$SWAYSOCK"
 | 
			
		||||
      swaymsg -t get_tree |
 | 
			
		||||
          ${pkgs.jq}/bin/jq -je '..|select(.focused? and .fullscreen_mode? == 1)|""' &&
 | 
			
		||||
          ${pkgs.sway}/bin/swaymsg -q fullscreen off &&
 | 
			
		||||
          set fullscreen
 | 
			
		||||
 | 
			
		||||
      ${pkgs.sway}/bin/swaymsg -t get_outputs |
 | 
			
		||||
          ${pkgs.jq}/bin/jq -r 'map(.focused)|reverse|index(true)' |
 | 
			
		||||
          read focused_output
 | 
			
		||||
 | 
			
		||||
      test -n "$focused_output"
 | 
			
		||||
      and set focused_output "-m $focused_output"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  function clean_exit
 | 
			
		||||
      set -q fullscreen
 | 
			
		||||
      and swaymsg -q fullscreen on &
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  trap clean_exit EXIT
 | 
			
		||||
 | 
			
		||||
  # t  title
 | 
			
		||||
  # f  filter
 | 
			
		||||
  # n  normal
 | 
			
		||||
  # h  highlighted
 | 
			
		||||
  # s  selected
 | 
			
		||||
  # sc scrollbar
 | 
			
		||||
 | 
			
		||||
      set fn "${font.mono} ${toString font.size.small}"
 | 
			
		||||
 | 
			
		||||
      set tb "${color.bg}${theme.opacityHex}"
 | 
			
		||||
      set tf "${accent.color}"
 | 
			
		||||
 | 
			
		||||
      set fb "${color.bg}${theme.opacityHex}"
 | 
			
		||||
      set ff "${color.txt}"
 | 
			
		||||
 | 
			
		||||
      set nb "${color.bg}${theme.opacityHex}"
 | 
			
		||||
      set nf "${color.txt}"
 | 
			
		||||
      set hb "${accent.color}"
 | 
			
		||||
      set hf "${accent.fg}"
 | 
			
		||||
 | 
			
		||||
  ${pkgs.dhist}/bin/dhist wrap -- ${pkgs.bemenu}/bin/bemenu \
 | 
			
		||||
      $focused_output\
 | 
			
		||||
      --ignorecase\
 | 
			
		||||
      --bottom\
 | 
			
		||||
      --no-overlap\
 | 
			
		||||
      --list 20\
 | 
			
		||||
      --prefix '>'\
 | 
			
		||||
      --fn "$fn"\
 | 
			
		||||
      --tb "$tb" --tf "$tf" \
 | 
			
		||||
      --fb "$fb" --ff "$ff" \
 | 
			
		||||
      --nb "$nb" --nf "$nf" \
 | 
			
		||||
      --hb "$hb" --hf "$hf" \
 | 
			
		||||
      $argv
 | 
			
		||||
 | 
			
		||||
  # vim: ft=fish
 | 
			
		||||
''
 | 
			
		||||
							
								
								
									
										6
									
								
								scripts/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								scripts/default.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
{ config, lib, ... }: (_: pkgs: {
 | 
			
		||||
  bmenu = import ./bmenu.nix { inherit config pkgs lib; };
 | 
			
		||||
  _diffr = import ./diffr.nix { inherit config pkgs lib; };
 | 
			
		||||
  kak-pager = import ./kak-pager.nix { inherit config pkgs lib; };
 | 
			
		||||
  terminal = import ./terminal.nix { inherit config pkgs lib; };
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										13
									
								
								scripts/diffr.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								scripts/diffr.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
{ config, pkgs, lib, ... }:
 | 
			
		||||
pkgs.writeShellScriptBin "diffr" ''
 | 
			
		||||
  exec ${pkgs.diffr}/bin/diffr \
 | 
			
		||||
      --colors 'refine-added:foreground:green:underline' \
 | 
			
		||||
      --colors 'refine-added:background:none' \
 | 
			
		||||
      --colors 'refine-removed:foreground:red:underline' \
 | 
			
		||||
      --colors 'refine-removed:background:none' \
 | 
			
		||||
      --colors 'added:foreground:green' \
 | 
			
		||||
      --colors 'added:background:none' \
 | 
			
		||||
      --colors 'removed:foreground:red' \
 | 
			
		||||
      --colors 'removed:background:none' \
 | 
			
		||||
      $@
 | 
			
		||||
''
 | 
			
		||||
							
								
								
									
										36
									
								
								scripts/kak-pager.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								scripts/kak-pager.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
{ config, pkgs, lib, ... }:
 | 
			
		||||
pkgs.writeScriptBin "kak-pager" ''
 | 
			
		||||
  #!/usr/bin/env fish
 | 
			
		||||
 | 
			
		||||
  if test (count $argv) -ne 0
 | 
			
		||||
      for i in $argv
 | 
			
		||||
          cat "$i"
 | 
			
		||||
      end | eval (status filename)
 | 
			
		||||
      exit 0
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  set term_line_count (tput lines)
 | 
			
		||||
 | 
			
		||||
  while read line
 | 
			
		||||
      set -a input_lines "$line"
 | 
			
		||||
 | 
			
		||||
      set input_line_count (printf "%s\n" $input_lines | wc -l)
 | 
			
		||||
 | 
			
		||||
      if test "$term_line_count" -lt "$input_line_count"
 | 
			
		||||
          begin
 | 
			
		||||
              printf "%s\n" $input_lines
 | 
			
		||||
              cat
 | 
			
		||||
          end | kak -e '
 | 
			
		||||
              exec <a-o>
 | 
			
		||||
              map global normal q :q<ret>;
 | 
			
		||||
              rmhl global/number-lines;
 | 
			
		||||
              set global scrolloff 10,0;
 | 
			
		||||
          '
 | 
			
		||||
 | 
			
		||||
          exit 0
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  printf "%s\n" $input_lines
 | 
			
		||||
''
 | 
			
		||||
							
								
								
									
										23
									
								
								scripts/terminal.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								scripts/terminal.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
{ config, pkgs, lib, ... }:
 | 
			
		||||
pkgs.writeScriptBin "terminal" ''
 | 
			
		||||
  #!/bin/sh
 | 
			
		||||
 | 
			
		||||
  CLASS="terminal"
 | 
			
		||||
 | 
			
		||||
  while test $# -gt 0;do
 | 
			
		||||
      case $1 in
 | 
			
		||||
          -c|--class)
 | 
			
		||||
              shift
 | 
			
		||||
              CLASS=$1
 | 
			
		||||
              shift
 | 
			
		||||
              ;;
 | 
			
		||||
          *)
 | 
			
		||||
              break
 | 
			
		||||
              ;;
 | 
			
		||||
      esac
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  test $# -gt 0 &&
 | 
			
		||||
      exec alacritty --class "$CLASS" -e $@ ||
 | 
			
		||||
      exec alacritty --class "$CLASS"
 | 
			
		||||
''
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue