A collection of scripts

Compare changes

Choose any two refs to compare.

+1
.gitignore
··· 1 + result*
+37
.nix/colorgrab.nix
··· 1 + { writeScriptBin 2 + , bash 3 + , coreutils 4 + , grim 5 + , imagemagick 6 + , libnotify 7 + , slurp 8 + , wl-clipboard 9 + , xdg-utils 10 + , ... 11 + }: 12 + 13 + writeScriptBin "colorgrab" (builtins.replaceStrings 14 + [ 15 + "#!/bin/sh" 16 + "mkdir" 17 + "printf" 18 + "grim" 19 + "slurp" 20 + "convert" 21 + "wl-copy" 22 + "xdg-open " 23 + "notify-send" 24 + ] 25 + [ 26 + "#!${bash}/bin/sh" 27 + "${coreutils}/bin/mkdir" 28 + "${coreutils}/bin/printf" 29 + "${grim}/bin/grim" 30 + "${slurp}/bin/slurp" 31 + "${imagemagick}/bin/convert" 32 + "${wl-clipboard}/bin/wl-copy" 33 + "${xdg-utils}/bin/xdg-open " 34 + "${libnotify}/bin/notify-send" 35 + ] 36 + (builtins.readFile ../scritps/colorgrab) 37 + )
+22
.nix/prefon.nix
··· 1 + { writeScriptBin 2 + , bash 3 + , coreutils 4 + , imagemagick 5 + , ... 6 + }: 7 + 8 + writeScriptBin "prefon" (builtins.replaceStrings 9 + [ 10 + "#!/bin/sh" 11 + "printf" 12 + "convert" 13 + "rm" 14 + ] 15 + [ 16 + "#!${bash}/bin/sh" 17 + "${coreutils}/bin/printf" 18 + "${imagemagick}/bin/convert" 19 + "${coreutils}/bin/rm" 20 + ] 21 + (builtins.readFile ../scritps/prefon) 22 + )
+37
.nix/scr.nix
··· 1 + { writeScriptBin 2 + , bash 3 + , coreutils 4 + , ffmpeg 5 + , grim 6 + , pulseaudio 7 + , slurp 8 + , wf-recorder 9 + , wl-clipboard 10 + , ... 11 + }: 12 + 13 + writeScriptBin "scr" (builtins.replaceStrings 14 + [ 15 + "#!/bin/sh" 16 + "printf" 17 + "mkdir" 18 + "ffmpeg" 19 + "grim" 20 + "slurp" 21 + "wl-copy" 22 + "pactl" 23 + "wf-recorder" 24 + ] 25 + [ 26 + "#!${bash}/bin/sh" 27 + "${coreutils}/bin/printf" 28 + "${coreutils}/bin/mkdir" 29 + "${ffmpeg}/bin/ffmpeg" 30 + "${grim}/bin/grim" 31 + "${slurp}/bin/slurp" 32 + "${wl-clipboard}/bin/wl-copy" 33 + "${pulseaudio}/bin/pactl" 34 + "${wf-recorder}/bin/wf-recorder" 35 + ] 36 + (builtins.readFile ../scritps/scr) 37 + )
+24
.nix/thm.nix
··· 1 + { writeScriptBin 2 + , bash 3 + , coreutils 4 + , gnused 5 + , ... 6 + }: 7 + 8 + writeScriptBin "thm" (builtins.replaceStrings 9 + [ 10 + "#!/bin/sh" 11 + "printf" 12 + "mkdir" 13 + "mv" 14 + "sed" 15 + ] 16 + [ 17 + "#!${bash}/bin/sh" 18 + "${coreutils}/bin/printf" 19 + "${coreutils}/bin/mkdir" 20 + "${coreutils}/bin/mv" 21 + "${gnused}/bin/sed" 22 + ] 23 + (builtins.readFile ../scritps/thm) 24 + )
-24
LICENSE
··· 1 - This is free and unencumbered software released into the public domain. 2 - 3 - Anyone is free to copy, modify, publish, use, compile, sell, or 4 - distribute this software, either in source code form or as a compiled 5 - binary, for any purpose, commercial or non-commercial, and by any 6 - means. 7 - 8 - In jurisdictions that recognize copyright laws, the author or authors 9 - of this software dedicate any and all copyright interest in the 10 - software to the public domain. We make this dedication for the benefit 11 - of the public at large and to the detriment of our heirs and 12 - successors. We intend this dedication to be an overt act of 13 - relinquishment in perpetuity of all present and future rights to this 14 - software under copyright law. 15 - 16 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 - IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 - OTHER DEALINGS IN THE SOFTWARE. 23 - 24 - For more information, please refer to <http://unlicense.org/>
-20
README
··· 1 - # description 2 - thm is a shell script that applies colors to a template file. 3 - 4 - # usage 5 - thm theme_name 6 - 7 - the theme_name does not include the `.theme` at the end of the file. 8 - 9 - # directories 10 - By default, the config files will be searched for in `$XDG_CONFIG_HOME/thm` or `$HOME/.config/thm`. 11 - The generated files will be placed in either `$XDG_CACHE_HOME/thm` or `$HOME/.cache/thm`. This can 12 - be changed by setting the environment variables `THM_CONFIG_DIR` and `THM_DEST_DIR`. The dest dir 13 - is cleared while running. 14 - 15 - # inside config directory 16 - The themes directory holds shell scripts defining the colors. These files should end with `.theme` 17 - if they should be usable with thm. The templates directory holds files for generating the themes. 18 - These files should end with `.template` The scripts directory holds files to be executed after thm 19 - is finished generating all the files. These files should be executable in order for thm to launch 20 - them. Examples of these files can be found in the examples directory of this repository.
+2
examples/thm/scripts/reload-mako
··· 1 + #!/bin/sh 2 + makoctl reload
+2
examples/thm/scripts/reload-sway
··· 1 + #!/bin/sh 2 + swaymsg reload
+32
examples/thm/templates/alacritty-colors.yml.template
··· 1 + colors: 2 + primary: 3 + background: '#{bg_color}' 4 + foreground: '#{fg_color}' 5 + 6 + cursor: 7 + text: '#{bg_color}' 8 + cursor: '#{fg_color}' 9 + 10 + selection: 11 + text: '#{bg_color}' 12 + background: '#{fg_color}' 13 + 14 + normal: 15 + black: '#{color0}' 16 + red: '#{color1}' 17 + green: '#{color2}' 18 + yellow: '#{color3}' 19 + blue: '#{color4}' 20 + magenta: '#{color5}' 21 + cyan: '#{color6}' 22 + white: '#{color7}' 23 + 24 + bright: 25 + black: '#{color8}' 26 + red: '#{color9}' 27 + green: '#{color10}' 28 + yellow: '#{color11}' 29 + blue: '#{color12}' 30 + magenta: '#{color13}' 31 + cyan: '#{color14}' 32 + white: '#{color15}'
+43
examples/thm/templates/colors.css.template
··· 1 + :root { 2 + /* HEX */ 3 + --bg-color: #{bg_color}; 4 + --fg-color: #{fg_color}; 5 + 6 + --color0: #{color0}; 7 + --color1: #{color1}; 8 + --color2: #{color2}; 9 + --color3: #{color3}; 10 + --color4: #{color4}; 11 + --color5: #{color5}; 12 + --color6: #{color6}; 13 + --color7: #{color7}; 14 + --color8: #{color8}; 15 + --color9: #{color9}; 16 + --color10: #{color10}; 17 + --color11: #{color11}; 18 + --color12: #{color12}; 19 + --color13: #{color13}; 20 + --color14: #{color14}; 21 + --color15: #{color15}; 22 + 23 + /* RGB */ 24 + --bg-color-rgb: rgb({bg_color.rgb}); 25 + --fg-color-rgb: rgb({fg_color.rgb}); 26 + 27 + --color0-rgb: rgb({color0.rgb}); 28 + --color1-rgb: rgb({color1.rgb}); 29 + --color2-rgb: rgb({color2.rgb}); 30 + --color3-rgb: rgb({color3.rgb}); 31 + --color4-rgb: rgb({color4.rgb}); 32 + --color5-rgb: rgb({color5.rgb}); 33 + --color6-rgb: rgb({color6.rgb}); 34 + --color7-rgb: rgb({color7.rgb}); 35 + --color8-rgb: rgb({color8.rgb}); 36 + --color9-rgb: rgb({color9.rgb}); 37 + --color10-rgb: rgb({color10.rgb}); 38 + --color11-rgb: rgb({color11.rgb}); 39 + --color12-rgb: rgb({color12.rgb}); 40 + --color13-rgb: rgb({color13.rgb}); 41 + --color14-rgb: rgb({color14.rgb}); 42 + --color15-rgb: rgb({color15.rgb}); 43 + }
+45
examples/thm/templates/colors.sh.template
··· 1 + #!/bin/sh 2 + 3 + # Hex 4 + bg_color='{bg_color}' 5 + fg_color='{fg_color}' 6 + 7 + color0='{color0}' 8 + color1='{color1}' 9 + color2='{color2}' 10 + color3='{color3}' 11 + color4='{color4}' 12 + color5='{color5}' 13 + color6='{color6}' 14 + color7='{color7}' 15 + 16 + color8='{color8}' 17 + color9='{color9}' 18 + color10='{color10}' 19 + color11='{color11}' 20 + color12='{color12}' 21 + color13='{color13}' 22 + color14='{color14}' 23 + color15='{color15}' 24 + 25 + # RGB 26 + bg_color_rgb='{bg_color.rgb}' 27 + fg_color_rgb='{fg_color.rgb}' 28 + 29 + color0_rgb='{color0.rgb}' 30 + color1_rgb='{color1.rgb}' 31 + color2_rgb='{color2.rgb}' 32 + color3_rgb='{color3.rgb}' 33 + color4_rgb='{color4.rgb}' 34 + color5_rgb='{color5.rgb}' 35 + color6_rgb='{color6.rgb}' 36 + color7_rgb='{color7.rgb}' 37 + 38 + color8_rgb='{color8.rgb}' 39 + color9_rgb='{color9.rgb}' 40 + color10_rgb='{color10.rgb}' 41 + color11_rgb='{color11.rgb}' 42 + color12_rgb='{color12.rgb}' 43 + color13_rgb='{color13.rgb}' 44 + color14_rgb='{color14.rgb}' 45 + color15_rgb='{color15.rgb}'
+20
examples/thm/templates/colors.template
··· 1 + # Puts the hex and rgb values of the same color on the same line in order 2 + 3 + {bg_color} {bg_color.rgb} 4 + {fg_color} {fg_color.rgb} 5 + {color0} {color0.rgb} 6 + {color1} {color1.rgb} 7 + {color2} {color2.rgb} 8 + {color3} {color3.rgb} 9 + {color4} {color4.rgb} 10 + {color5} {color5.rgb} 11 + {color6} {color6.rgb} 12 + {color7} {color7.rgb} 13 + {color8} {color8.rgb} 14 + {color9} {color9.rgb} 15 + {color10} {color10.rgb} 16 + {color11} {color11.rgb} 17 + {color12} {color12.rgb} 18 + {color13} {color13.rgb} 19 + {color14} {color14.rgb} 20 + {color1} {color1.rgb}
+38
examples/thm/templates/dark/sway-appearance.template
··· 1 + # class border background text indicator child_border 2 + client.focused #{color5} #{color13} #{fg_color} #{color5} #{color5} 3 + client.focused_inactive #{color4} #{color12} #{fg_color} #{color4} #{color4} 4 + client.unfocused #{color8} #{color8} #{fg_color} #{color8} #{color8} 5 + client.urgent #{color1} #{color9} #{fg_color} #{color1} #{color1} 6 + 7 + default_border normal 2 8 + default_floating_border normal 2 9 + titlebar_border_thickness 2 10 + 11 + font pango:monospace 10 12 + 13 + hide_edge_borders both 14 + 15 + title_align center 16 + 17 + set { 18 + $bg_color {bg_color} 19 + $fg_color {fg_color} 20 + 21 + $color0 {color0} 22 + $color1 {color1} 23 + $color2 {color2} 24 + $color3 {color3} 25 + $color4 {color4} 26 + $color5 {color5} 27 + $color6 {color6} 28 + $color7 {color7} 29 + $color8 {color8} 30 + $color9 {color9} 31 + 32 + $color10 {color10} 33 + $color11 {color11} 34 + $color12 {color12} 35 + $color13 {color13} 36 + $color14 {color14} 37 + $color15 {color15} 38 + }
+43
examples/thm/templates/foot.ini.template
··· 1 + font=monospace:size=10 2 + dpi-aware=yes 3 + pad=8x8 4 + initial-window-size-chars=120x36 5 + 6 + [scrollback] 7 + lines=2000 8 + indicator-position=none 9 + 10 + [cursor] 11 + style=bar 12 + color={bg_color} {fg_color} 13 + 14 + [colors] 15 + background={bg_color} 16 + foreground={fg_color} 17 + regular0={color0} 18 + regular1={color1} 19 + regular2={color2} 20 + regular3={color3} 21 + regular4={color4} 22 + regular5={color5} 23 + regular6={color6} 24 + regular7={color7} 25 + bright0={color8} 26 + bright1={color9} 27 + bright2={color10} 28 + bright3={color11} 29 + bright4={color12} 30 + bright5={color13} 31 + bright6={color14} 32 + bright7={color15} 33 + # selection-foreground=<inverse foreground/background> 34 + # selection-background=<inverse foreground/background> 35 + 36 + [csd] 37 + preferred=client 38 + size=32 39 + color=ff{fg_color} 40 + button-width=32 41 + button-minimize-color={color4} 42 + button-maximize-color={color2} 43 + button-close-color={color1}
+41
examples/thm/templates/gtk.css.template
··· 1 + /* HEX */ 2 + @define-color bg-color #{bg_color}; 3 + @define-color fg-color #{fg_color}; 4 + 5 + @define-color color0 #{color0}; 6 + @define-color color1 #{color1}; 7 + @define-color color2 #{color2}; 8 + @define-color color3 #{color3}; 9 + @define-color color4 #{color4}; 10 + @define-color color5 #{color5}; 11 + @define-color color6 #{color6}; 12 + @define-color color7 #{color7}; 13 + @define-color color8 #{color8}; 14 + @define-color color9 #{color9}; 15 + @define-color color10 #{color10}; 16 + @define-color color11 #{color11}; 17 + @define-color color12 #{color12}; 18 + @define-color color13 #{color13}; 19 + @define-color color14 #{color14}; 20 + @define-color color15 #{color15}; 21 + 22 + /* RGB */ 23 + @define-color bg-color-rgb rgb ({bg_color.rgb}); 24 + @define-color fg-color-rgb rgb ({fg_color.rgb}); 25 + 26 + @define-color color0-rgb rgb ({color0.rgb}); 27 + @define-color color1-rgb rgb ({color1.rgb}); 28 + @define-color color2-rgb rgb ({color2.rgb}); 29 + @define-color color3-rgb rgb ({color3.rgb}); 30 + @define-color color4-rgb rgb ({color4.rgb}); 31 + @define-color color5-rgb rgb ({color5.rgb}); 32 + @define-color color6-rgb rgb ({color6.rgb}); 33 + @define-color color7-rgb rgb ({color7.rgb}); 34 + @define-color color8-rgb rgb ({color8.rgb}); 35 + @define-color color9-rgb rgb ({color9.rgb}); 36 + @define-color color10-rgb rgb ({color10.rgb}); 37 + @define-color color11-rgb rgb ({color11.rgb}); 38 + @define-color color12-rgb rgb ({color12.rgb}); 39 + @define-color color13-rgb rgb ({color13.rgb}); 40 + @define-color color14-rgb rgb ({color14.rgb}); 41 + @define-color color15-rgb rgb ({color15.rgb});
+38
examples/thm/templates/light/sway-appearance.template
··· 1 + # class border background text indicator child_border 2 + client.focused #{color5} #{color13} #{bg_color} #{color5} #{color5} 3 + client.focused_inactive #{color4} #{color12} #{bg_color} #{color4} #{color4} 4 + client.unfocused #{color8} #{color8} #{bg_color} #{color8} #{color8} 5 + client.urgent #{color1} #{color9} #{bg_color} #{color1} #{color1} 6 + 7 + default_border normal 2 8 + default_floating_border normal 2 9 + titlebar_border_thickness 2 10 + 11 + font pango:monospace 10 12 + 13 + hide_edge_borders both 14 + 15 + title_align center 16 + 17 + set { 18 + $bg_color {bg_color} 19 + $fg_color {fg_color} 20 + 21 + $color0 {color0} 22 + $color1 {color1} 23 + $color2 {color2} 24 + $color3 {color3} 25 + $color4 {color4} 26 + $color5 {color5} 27 + $color6 {color6} 28 + $color7 {color7} 29 + $color8 {color8} 30 + $color9 {color9} 31 + 32 + $color10 {color10} 33 + $color11 {color11} 34 + $color12 {color12} 35 + $color13 {color13} 36 + $color14 {color14} 37 + $color15 {color15} 38 + }
+47
examples/thm/templates/mako.template
··· 1 + # Global Config 2 + max-visible=2 3 + sort=-time 4 + output=DP-1 5 + layer=top 6 + anchor=top-right 7 + 8 + # All Notifcations 9 + font=monospace 10 10 + background-color=#{bg_color} 11 + text-color=#{fg_color} 12 + width=400 13 + height=200 14 + margin=8,8 15 + padding=8,8 16 + border-size=4 17 + border-color=#{fg_color} 18 + max-icon-size=48 19 + actions=1 20 + format=<b>%a</b>\n%s\n%b 21 + default-timeout=8000 22 + group-by=app-name 23 + 24 + # Low Urgency Notifcations 25 + [urgency=low] 26 + border-color=#{color8} 27 + default-timeout=4000 28 + 29 + # Normal Ugency Notifcations 30 + [urgency=normal] 31 + border-color=#{fg_color} 32 + default-timeout=8000 33 + 34 + # High Urgency Notifcations 35 + [urgency=high] 36 + border-color=#{color1} 37 + default-timeout=0 38 + 39 + [grouped] 40 + format=<b>%a</b>\n%s\n%b 41 + 42 + # Hidden Notification 43 + [hidden] 44 + width=0 45 + height=0 46 + border-size=0 47 + format=
+32
examples/thm/templates/swaylock.template
··· 1 + # Functionality 2 + ignore-empty-password 3 + daemonize 4 + 5 + # Appearance 6 + disable-caps-lock-text 7 + indicator-caps-lock 8 + color={color8} 9 + bs-hl-color={color1} 10 + caps-lock-bs-hl-color={color1} 11 + caps-lock-key-hl-color={color3} 12 + font=monospace 13 + indicator-radius=64 14 + indicator-thickness=16 15 + inside-color={color2} 16 + inside-clear-color={color5} 17 + inside-caps-lock-color={color3} 18 + inside-ver-color={color4} 19 + inside-wrong-color={color1} 20 + key-hl-color={color2} 21 + line-uses-inside 22 + ring-color={color10} 23 + ring-clear-color={color13} 24 + ring-caps-lock-color={color11} 25 + ring-ver-color={color12} 26 + ring-wrong-color={color9} 27 + separator-color={color7}00 28 + text-color={color15} 29 + text-clear-color={color15} 30 + text-caps-lock-color={color15} 31 + text-ver-color={color15} 32 + text-wrong-color={color15}
+23
examples/thm/themes/dark.theme
··· 1 + #!/bin/sh 2 + 3 + theme_type="dark" 4 + 5 + bg_color="1f1f1f" 6 + fg_color="efefef" 7 + 8 + color0="1f1f1f" 9 + color1="e67b7b" 10 + color2="80ba63" 11 + color3="f5a868" 12 + color4="849ce6" 13 + color5="b37fe3" 14 + color6="6ebdc4" 15 + color7="b0b0b0" 16 + color8="3f3f3f" 17 + color9="ed9a9a" 18 + color10="a3d989" 19 + color11="f7c297" 20 + color12="a6baf5" 21 + color13="d1adf2" 22 + color14="bedcde" 23 + color15="efefef"
+23
examples/thm/themes/default-dark.theme
··· 1 + #!/bin/sh 2 + 3 + theme_type="dark" 4 + 5 + bg_color="000000" 6 + fg_color="ffffff" 7 + 8 + color0="000000" 9 + color1="800000" 10 + color2="008000" 11 + color3="808000" 12 + color4="000080" 13 + color5="800080" 14 + color6="008080" 15 + color7="c0c0c0" 16 + color8="808080" 17 + color9="ff0000" 18 + color10="00ff00" 19 + color11="ffff00" 20 + color12="0000ff" 21 + color13="ff00ff" 22 + color14="00ffff" 23 + color15="ffffff"
+23
examples/thm/themes/default-light.theme
··· 1 + #!/bin/sh 2 + 3 + theme_type="light" 4 + 5 + bg_color="ffffff" 6 + fg_color="000000" 7 + 8 + color0="ffffff" 9 + color1="800000" 10 + color2="008000" 11 + color3="808000" 12 + color4="000080" 13 + color5="800080" 14 + color6="008080" 15 + color7="808080" 16 + color8="c0c0c0" 17 + color9="ff0000" 18 + color10="00ff00" 19 + color11="ffff00" 20 + color12="0000ff" 21 + color13="ff00ff" 22 + color14="00ffff" 23 + color15="000000"
+23
examples/thm/themes/grayscale-light.theme
··· 1 + #!/bin/sh 2 + 3 + theme_type="light" 4 + 5 + bg_color="efefef" 6 + fg_color="1f1f1f" 7 + 8 + color0="efefef" 9 + color1="b0b0b0" 10 + color2="9d9d9d" 11 + color3="8a8a8a" 12 + color4="787878" 13 + color5="656565" 14 + color6="525252" 15 + color7="3f3f3f" 16 + color9="808080" 17 + color8="bfbfbf" 18 + color10="707070" 19 + color11="606060" 20 + color12="505050" 21 + color13="3f3f3f" 22 + color14="2f2f2f" 23 + color15="1f1f1f"
+23
examples/thm/themes/light.theme
··· 1 + #!/bin/sh 2 + 3 + theme_type="light" 4 + 5 + bg_color="efefef" 6 + fg_color="1f1f1f" 7 + 8 + color0="efefef" 9 + color1="e67b7b" 10 + color2="80ba63" 11 + color3="f5a868" 12 + color4="849ce6" 13 + color5="b37fe3" 14 + color6="6ebdc4" 15 + color7="3f3f3f" 16 + color8="b0b0b0" 17 + color9="ed9a9a" 18 + color10="a3d989" 19 + color11="f7c297" 20 + color12="a6baf5" 21 + color13="d1adf2" 22 + color14="bedcde" 23 + color15="1f1f1f"
-2
exmaples/scripts/reload-sway
··· 1 - #!/bin/sh 2 - swaymsg reload
-22
exmaples/templates/colors.sh.template
··· 1 - #!/bin/sh 2 - 3 - bg_color='{bg_color}' 4 - fg_color='{fg_color}' 5 - 6 - color0='{color0}' 7 - color1='{color1}' 8 - color2='{color2}' 9 - color3='{color3}' 10 - color4='{color4}' 11 - color5='{color5}' 12 - color6='{color6}' 13 - color7='{color7}' 14 - 15 - color8='{color8}' 16 - color9='{color9}' 17 - color10='{color10}' 18 - color11='{color11}' 19 - color12='{color12}' 20 - color13='{color13}' 21 - color14='{color14}' 22 - color15='{color15}'
-29
exmaples/templates/sway-colors.template
··· 1 - # class border background text indicator child_border 2 - client.focused #{color5} #{color13} #{bg_color} #{color5} #{color5} 3 - client.focused_inactive #{color4} #{color12} #{bg_color} #{color4} #{color4} 4 - client.unfocused #{color8} #{color8} #{bg_color} #{color8} #{color8} 5 - client.urgent #{color1} #{color9} #{bg_color} #{color1} #{color1} 6 - 7 - # set variables 8 - set { 9 - $bg_color {bg_color} 10 - $fg_color {fg_color} 11 - 12 - $color0 {color0} 13 - $color1 {color1} 14 - $color2 {color2} 15 - $color3 {color3} 16 - $color4 {color4} 17 - $color5 {color5} 18 - $color6 {color6} 19 - $color7 {color7} 20 - $color8 {color8} 21 - $color9 {color9} 22 - 23 - $color10 {color10} 24 - $color11 {color11} 25 - $color12 {color12} 26 - $color13 {color13} 27 - $color14 {color14} 28 - $color15 {color15} 29 - }
-21
exmaples/themes/default-dark.theme
··· 1 - #!/bin/sh 2 - 3 - bg_color="000000" 4 - fg_color="ffffff" 5 - 6 - color0="000000" 7 - color1="800000" 8 - color2="008000" 9 - color3="808000" 10 - color4="000080" 11 - color5="800080" 12 - color6="008080" 13 - color7="c0c0c0" 14 - color8="808080" 15 - color9="ff0000" 16 - color10="00ff00" 17 - color11="ffff00" 18 - color12="0000ff" 19 - color13="ff00ff" 20 - color14="00ffff" 21 - color15="ffffff"
-21
exmaples/themes/default-light.theme
··· 1 - #!/bin/sh 2 - 3 - bg_color="ffffff" 4 - fg_color="000000" 5 - 6 - color0="ffffff" 7 - color1="800000" 8 - color2="008000" 9 - color3="808000" 10 - color4="000080" 11 - color5="800080" 12 - color6="008080" 13 - color7="808080" 14 - color8="c0c0c0" 15 - color9="ff0000" 16 - color10="00ff00" 17 - color11="ffff00" 18 - color12="0000ff" 19 - color13="ff00ff" 20 - color14="00ffff" 21 - color15="000000"
-20
exmaples/themes/grayscale-light.theme
··· 1 - #!/bin/sh 2 - bg_color="efefef" 3 - fg_color="1f1f1f" 4 - 5 - color0="efefef" 6 - color1="b0b0b0" 7 - color2="9d9d9d" 8 - color3="8a8a8a" 9 - color4="787878" 10 - color5="656565" 11 - color6="525252" 12 - color7="3f3f3f" 13 - color9="808080" 14 - color8="bfbfbf" 15 - color10="707070" 16 - color11="606060" 17 - color12="505050" 18 - color13="3f3f3f" 19 - color14="2f2f2f" 20 - color15="1f1f1f"
-21
exmaples/themes/light.theme
··· 1 - #!/bin/sh 2 - 3 - bg_color="efefef" 4 - fg_color="1f1f1f" 5 - 6 - color0="efefef" 7 - color1="e67b7b" 8 - color2="80ba63" 9 - color3="f5a868" 10 - color4="849ce6" 11 - color5="b37fe3" 12 - color6="6ebdc4" 13 - color7="3f3f3f" 14 - color8="b0b0b0" 15 - color9="ed9a9a" 16 - color10="a3d989" 17 - color11="f7c297" 18 - color12="a6baf5" 19 - color13="d1adf2" 20 - color14="bedcde" 21 - color15="1f1f1f"
+27
flake.lock
··· 1 + { 2 + "nodes": { 3 + "nixpkgs": { 4 + "locked": { 5 + "lastModified": 1726062873, 6 + "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", 7 + "owner": "NixOS", 8 + "repo": "nixpkgs", 9 + "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "NixOS", 14 + "ref": "nixos-unstable", 15 + "repo": "nixpkgs", 16 + "type": "github" 17 + } 18 + }, 19 + "root": { 20 + "inputs": { 21 + "nixpkgs": "nixpkgs" 22 + } 23 + } 24 + }, 25 + "root": "root", 26 + "version": 7 27 + }
+35
flake.nix
··· 1 + { 2 + inputs = { 3 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 4 + }; 5 + 6 + outputs = { self, nixpkgs, ... }: 7 + let 8 + forAllSystems = function: nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] 9 + (system: function (import nixpkgs { 10 + inherit system; 11 + overlays = [ self.overlays.default ]; 12 + })); 13 + in 14 + { 15 + overlays.default = final: prev: rec { 16 + colorgrab = final.callPackage ./.nix/colorgrab.nix { }; 17 + prefon = final.callPackage ./.nix/prefon.nix { }; 18 + scr = final.callPackage ./.nix/scr.nix { }; 19 + thm = final.callPackage ./.nix/thm.nix { }; 20 + yemou-scripts = final.symlinkJoin { 21 + name = "yemou-scripts"; 22 + paths = [ colorgrab prefon scr thm ]; 23 + }; 24 + }; 25 + 26 + packages = forAllSystems (pkgs: { 27 + colorgrab = pkgs.colorgrab; 28 + default = pkgs.yemou-scripts; 29 + prefon = pkgs.prefon; 30 + scr = pkgs.scr; 31 + thm = pkgs.thm; 32 + yemou-scripts = pkgs.yemou-scripts; 33 + }); 34 + }; 35 + }
+24
license
··· 1 + This is free and unencumbered software released into the public domain. 2 + 3 + Anyone is free to copy, modify, publish, use, compile, sell, or 4 + distribute this software, either in source code form or as a compiled 5 + binary, for any purpose, commercial or non-commercial, and by any 6 + means. 7 + 8 + In jurisdictions that recognize copyright laws, the author or authors 9 + of this software dedicate any and all copyright interest in the 10 + software to the public domain. We make this dedication for the benefit 11 + of the public at large and to the detriment of our heirs and 12 + successors. We intend this dedication to be an overt act of 13 + relinquishment in perpetuity of all present and future rights to this 14 + software under copyright law. 15 + 16 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 + OTHER DEALINGS IN THE SOFTWARE. 23 + 24 + For more information, please refer to <http://unlicense.org/>
+6
readme.md
··· 1 + # haiku readme 2 + random shell scripts that 3 + 4 + are potentially useful 5 + 6 + for various tasks
+118
scritps/colorgrab
··· 1 + #!/bin/sh 2 + # Grab the color of a specific point 3 + 4 + # Required Commands: 5 + # convert(imagemagick) - Get the color from the screenshotted point 6 + # grim - Take a screenshot of the selected point 7 + # slurp - Select a point 8 + # mkdir - Create missing directories 9 + # notify-send (optional) - Send a screenshot with the color 10 + # wl-copy(wl-clipboard) (optional) - Copy the color into the clipboard 11 + # xdg-open (optional) - Open the screenshot in an image viewer 12 + 13 + usage() { 14 + printf '%s\n' "usage: ${0##*/} [options]" \ 15 + "options:" \ 16 + " -c - copy to clipboard" \ 17 + " -h - display usage statement" \ 18 + " -n - send a notification with the color" \ 19 + " -o - open the color as an image" \ 20 + " -r - display the color as an rgb value" \ 21 + " -x - display the color as a hexcode value (default)" 22 + } 23 + 24 + # Parse arguments 25 + for flag 26 + do 27 + # Make sure flag begins with '-' and are atleast two characters long 28 + case $flag in 29 + - ) continue ;; 30 + -- ) break ;; 31 + -* ) ;; 32 + * ) continue ;; 33 + esac 34 + 35 + # Split the flags into individual arguments and set variables 36 + flag=${flag#-} 37 + 38 + while [ "$flag" ] 39 + do 40 + a=${flag%"${flag#?}"} 41 + 42 + case $a in 43 + c ) copy_to_clipboard=true ;; 44 + h ) usage; exit 0 ;; 45 + n ) send_notification=true ;; 46 + o ) open_color_image=true ;; 47 + r ) color_type="rgb" ;; 48 + x ) color_type="hex" ;; 49 + * ) printf '%s\n' "${0##*/}: -$a invalid argument" 1>&2 50 + usage 1>&2; exit 1 ;; 51 + esac 52 + 53 + flag=${flag#?} 54 + done 55 + done 56 + 57 + # Make sure this directory exist before continuing 58 + [ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; } 59 + 60 + # Set color_type if not already set 61 + [ "$color_type" ] || color_type="hex" 62 + 63 + # Get a screenshot of the pixel 64 + # shellcheck disable=SC2086 65 + grim -s 1 -g "$(slurp ${SLURP_ARGS} -b 00000000 -s 00000000 -w -1 -p)" "/tmp/${0##*/}/temp.png" 66 + 67 + case $color_type in 68 + hex ) color=$(convert "/tmp/${0##*/}/temp.png" -format "%[hex:p]\n" info:) ;; 69 + rgb ) 70 + color=$(convert "/tmp/${0##*/}/temp.png" -format "%[pixel:p]\n" info:) 71 + color=${color#*(}; color=${color%)*} 72 + ;; 73 + * ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;; 74 + esac 75 + printf '%s\n' "$color" 76 + 77 + # Copy color to clipboard 78 + [ "$copy_to_clipboard" ] && { 79 + wl-copy -n "$color" || printf '%s\n' "${0##*/}: failed to copy color to clipboard" 1>&2 80 + } 81 + 82 + # Open color image in the user's perfered image viewer 83 + [ "$open_color_image" ] && { 84 + # Create the color image if it doesn't already exist 85 + [ -f "/tmp/${0##*/}/o$color.png" ] || { 86 + case $color_type in 87 + hex ) ocolor="#$color" ;; 88 + rgb ) ocolor="rgb($color)" ;; 89 + esac 90 + 91 + convert -size 150x150 xc:"$ocolor" +size -gravity center \ 92 + \( -background white pango:"<span font_family=\"monospace\" 93 + font_weight=\"bold\"> $color </span>" \) \ 94 + -composite "/tmp/${0##*/}/o$color.png" 95 + } 96 + 97 + xdg-open "/tmp/${0##*/}/o$color.png" > "/tmp/${0##*/}/xdg-open.log" 2>&1 & 98 + } 99 + 100 + # Send a notification with an image of the color aswell as the value 101 + [ "$send_notification" ] && { 102 + [ -f "/tmp/${0##*/}/n$color.png" ] || { 103 + case $color_type in 104 + hex ) ncolor="#$color"; color_prefix="hex:";; 105 + rgb ) 106 + ncolor="rgb($color)" 107 + color_r="${color%%,*}" 108 + color_g="${color#*,}"; color_g="${color_g%,*}" 109 + color_b="${color##*,}" 110 + color_rgb="$color_r$color_g$color_b" 111 + color_prefix="rgb:";; 112 + esac 113 + 114 + convert -size 64x64 xc:"$ncolor" "/tmp/${0##*/}/n$color_rgb.png" 115 + } 116 + 117 + notify-send -a "${0##*/}" -i "/tmp/${0##*/}/n$color_rgb.png" "$color_prefix $color" 118 + }
+147
scritps/prefon
··· 1 + #!/bin/sh 2 + # Script to preview fonts 3 + 4 + usage() { 5 + printf '%b\n' "${0##*/} [-F FILE | -S | -t STRING] [OPTIONS]" \ 6 + "actions:" \ 7 + "\t-F FILE - read from file" \ 8 + "\t-S - read from stdin" \ 9 + "\t-t STRING - use a string" \ 10 + "\noptions:" \ 11 + "\t-b SIZE - border size" \ 12 + "\t-c COLORS - set the color of the text and background" \ 13 + "\t-f FONT - which font to preview" \ 14 + "\t-h - display this message" \ 15 + "\t-i - generate the inverse image (horizontal, vertical, none)" \ 16 + "\t-o FILE - output file for the generated image" \ 17 + "\t-s SIZE - size of the font" \ 18 + "\ndefault values:" \ 19 + "These values can be set before execution to change default values" \ 20 + "\tPREFON_ACTION=text (file, stdin, or text)" \ 21 + "\tPREFON_BORDER_SIZE=16" \ 22 + "\tPREFON_COLORS=\"000000,ffffff\"" \ 23 + "\tPREFON_FONT=\"monospace\"" \ 24 + "\tPREFON_OUTPUT=\"/tmp/prefon.png\"" \ 25 + "\tPREFON_SIZE=16" \ 26 + "\tPREFON_TEXT=\"The quick brown fox jumps\\\n over the lazy dog\"" \ 27 + "\tPREFON_INVERSE=vertical (horizontal, vertical, none)" 28 + } 29 + 30 + info() { 31 + case $1 in 32 + i ) prefix=INFO ;; 33 + w ) prefix=WARNING ;; 34 + e ) prefix=ERROR ;; 35 + * ) printf '%s\n' "sus!" 1>&2; exit 1 ;; 36 + esac; shift 37 + 38 + printf "${0##*/}: $prefix: %b\n" "$*" 1>&2 39 + } 40 + 41 + # Default values 42 + PREFON_ACTION=${PREFON_ACTION:-text} 43 + PREFON_BORDER_SIZE=${PREFON_BORDER_SIZE:-16} 44 + PREFON_COLORS=${PREFON_COLORS:-000000,ffffff} 45 + PREFON_FONT="${PREFON_FONT:-monospace}" 46 + PREFON_OUTPUT="${PREFON_OUTPUT:-/tmp/prefon.png}" 47 + PREFON_SIZE=${PREFON_SIZE:-16} 48 + PREFON_TEXT="${PREFON_TEXT:-The quick brown fox jumps\n over the lazy dog}" 49 + PREFON_INVERSE=${PREFON_WITHOUT_INVERSE:-vertical} 50 + 51 + # Handle arguments 52 + while [ "$*" ] 53 + do 54 + case $1 in 55 + - ) shift; continue ;; 56 + -- ) shift; break ;; 57 + -* ) flag=${1#-}; shift ;; 58 + * ) shift; continue ;; 59 + esac 60 + 61 + while [ "$flag" ] 62 + do 63 + arg=${flag%${flag#?}} 64 + 65 + case $arg in 66 + F ) PREFON_ACTION="file"; PREFON_FILE=$1; shift ;; 67 + S ) PREFON_ACTION=stdin; PREFON_FILE=/dev/stdin ;; 68 + b ) PREFON_BORDER_SIZE=$1; shift ;; 69 + c ) PREFON_COLORS=$1; shift ;; 70 + f ) PREFON_FONT=$1; shift ;; 71 + h ) usage; exit 0 ;; 72 + i ) PREFON_INVERSE=$1; shift ;; 73 + o ) PREFON_OUTPUT=$1; shift ;; 74 + s ) PREFON_SIZE=$1; shift ;; 75 + t ) PREFON_ACTION=text; PREFON_TEXT=$1; shift ;; 76 + * ) printf '%s\n' "${0##*/}: -$arg: invalid argument" 1>&2 77 + usage 1>&2; exit 1 ;; 78 + esac 79 + 80 + flag=${flag#?} 81 + done 82 + done 83 + 84 + _gen_img() { 85 + convert -background "#$2" -bordercolor "#$2" -border "$PREFON_BORDER_SIZE" \ 86 + pango:"<span foreground=\"#$1\" font_desc=\"$PREFON_FONT $PREFON_SIZE\">$4</span>" "$3" 87 + } 88 + 89 + _output_file() { 90 + while IFS= read -r line 91 + do printf '%s\n' "$line" 92 + done < "$PREFON_FILE" 93 + } 94 + 95 + generate_image() { 96 + fgcolor=${PREFON_COLORS%,*} 97 + bgcolor=${PREFON_COLORS#*,} 98 + 99 + _gen_img "$fgcolor" "$bgcolor" "$PREFON_OUTPUT" "$1" || { 100 + info e failed to generate image 101 + exit 1 102 + } 103 + 104 + [ "$PREFON_INVERSE" != "none" ] && { 105 + inverse="${PREFON_OUTPUT%.*}" 106 + inverse="${inverse}-inverse.${PREFON_OUTPUT##*.}" 107 + 108 + _gen_img "$bgcolor" "$fgcolor" "$inverse" "$1" || { 109 + info e failed to generate image 110 + exit 1 111 + } 112 + 113 + case $PREFON_INVERSE in 114 + horizontal ) convert "$PREFON_OUTPUT" "$inverse" +append "$PREFON_OUTPUT" \ 115 + || { info e failed to generate image; exit 1; } ;; 116 + vertical ) convert "$PREFON_OUTPUT" "$inverse" -append "$PREFON_OUTPUT" \ 117 + || { info e failed to generate image; exit 1; } ;; 118 + * ) info e "${PREFON_INVERSE}: is not a valid value for PREFON_INVERSE" 119 + exit 1 ;; 120 + esac 121 + 122 + rm "$inverse" || info w failed to remove temporary file: "${inverse}" 123 + } 124 + 125 + printf '%s\n' "$PREFON_OUTPUT" 126 + } 127 + 128 + read_input() { 129 + input="$(_output_file)" 130 + generate_image "$input" 131 + } 132 + 133 + case $PREFON_ACTION in 134 + file ) 135 + [ -e "$PREFON_FILE" ] || { info e "'$PREFON_FILE' does not exist"; exit 1; } 136 + read_input 137 + ;; 138 + stdin ) 139 + [ -e /dev/stdin ] || { info e "/dev/stdin does not exist"; exit 1; } 140 + read_input 141 + ;; 142 + text ) 143 + [ "$PREFON_TEXT" ] || { info e "string not provided"; exit 1; } 144 + generate_image "$PREFON_TEXT" 145 + ;; 146 + * ) info e invalid action: $PREFON_ACTION; exit 1 ;; 147 + esac
+237
scritps/scr
··· 1 + #!/bin/sh 2 + # shellcheck disable=SC1090,SC1091,SC2154 3 + 4 + # SC1090 & SC2154 5 + # The files sourced are user generated files that should contain the needed 6 + # variables for the script to function correctly. It should be safe to ignore 7 + # these warnings. 8 + 9 + # Required Commands 10 + # ffmpeg - needed for aud 11 + # grim - needed for pic 12 + # mkdir - create missing directories 13 + # pactl - create loopback devices for multi-device audio recording in wf-recorder 14 + # slurp - make a selection 15 + # wf-recorder - needed for rec 16 + # wl-copy - copy images to clipboard 17 + 18 + # This script is intended for use on wayland; however, `scr aud` should work fine without 19 + # wayland. 20 + 21 + # Set required variables if needed 22 + [ "$SCR_CFG_DIR" ] || SCR_CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/scr" 23 + [ "$SCR_CACHE_DIR" ] || SCR_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/scr" 24 + 25 + # Source the configuration file 26 + # A sample configuration can be found in my dotfiles at: 27 + # https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh 28 + # TODO: put an example cofiguration in this repo 29 + . "$SCR_CFG_DIR/config.sh" || { 30 + printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1 31 + } 32 + 33 + # Usage statement for the script 34 + usage() { 35 + printf '%b\n' "usage: ${0##*/} action [options]" \ 36 + "actions:" \ 37 + "\taud - audio" \ 38 + "\tpic - picture" \ 39 + "\trec - record" \ 40 + "options:" \ 41 + "\t-a - record desktop audio (aud,rec)" \ 42 + "\t-c - copy image to clipboard (pic)" \ 43 + "\t-h - display this message" \ 44 + "\t-m - record microphone audio (aud,rec)" \ 45 + "\t-o - output to use (pic,rec)" \ 46 + "\t-d - all displays (pic)" 47 + } 48 + 49 + # Determine the action to run 50 + case $1 in 51 + aud ) action="scr_aud" ;; 52 + pic ) action="scr_pic" ;; 53 + rec ) action="scr_rec" ;; 54 + *h|*help ) usage; exit 0 ;; 55 + * ) printf '%s\n' "${0##*/}: $1: invalid action" 1>&2; usage 1>&2; exit 1 ;; 56 + esac 57 + shift 58 + 59 + # Determine options to run with based on arguments 60 + # (I need to stop) 61 + for flag in "$@" 62 + do 63 + # Make sure arguments start with '-' and are atleast 2 characters long 64 + case $flag in 65 + - ) continue ;; 66 + -- ) break ;; 67 + -* ) ;; 68 + * ) continue;; 69 + esac 70 + 71 + # Split arguments to be 1 character long and determine options to use 72 + args=${flag#-} 73 + 74 + while [ "$args" ] 75 + do 76 + a=${args%"${args#?}"} 77 + 78 + case $a in 79 + a ) desktop_audio=true ;; 80 + c ) copy_clipboard=true ;; 81 + d ) output=all ;; # Kinda redundent lol 82 + h ) usage; exit 0 ;; 83 + m ) microphone=true ;; 84 + o ) aargs=$* 85 + output=${aargs##*"${flag}"}; output=${output#\ }; output=${output%%\ *} 86 + [ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;; 87 + * ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2 88 + usage 1>&2; exit 1 ;; 89 + esac 90 + 91 + args=${args#?} 92 + done 93 + done 94 + unset args arg 95 + 96 + # Simple function to print out an error message and exit 97 + die() { 98 + printf '%s\n' "${0##*/}: $*" 1>&2 99 + exit 1 100 + } 101 + 102 + # Record Audio 103 + scr_aud() { 104 + # Create the directory to store audio recordings if it does not already exist 105 + [ -d "$scr_aud_dir" ] || \ 106 + { mkdir -p "$scr_aud_dir" || die "failed to make directory: $scr_aud_dir"; } 107 + 108 + # Create the directory to store logs if it does not already exist 109 + [ -d "$SCR_CACHE_DIR" ] || \ 110 + { mkdir -p "$SCR_CACHE_DIR" || \ 111 + die "failed to make directory: $SCR_CACHE_DIR"; } 112 + 113 + filename="$scr_aud_dir/$aud_filename" 114 + 115 + # Require atleast one of the arguments: -a or -m 116 + [ "$microphone" ] || [ "$desktop_audio" ] || \ 117 + { die "aud: argument -a or -m is required to record audio"; } 118 + 119 + # Set ffmpeg options based on script options 120 + [ "$microphone" ] && { args="-f pulse -i $aud_source"; } 121 + [ "$desktop_audio" ] && { args="$args -f pulse -i $aud_sink"; } 122 + [ "$microphone" ] && [ "$desktop_audio" ] && \ 123 + { args="$args -filter_complex amix=inputs=2"; } 124 + 125 + # Pressing Ctrl+C will exit the script instead of just ffmpeg. 126 + # Intercept Ctrl+C and do nothing. 127 + trap '' INT 128 + 129 + # shellcheck disable=SC2086 130 + # Word splitting is favorable here 131 + ffmpeg $args "$filename" > "$SCR_CACHE_DIR/aud.log" 2>&1 & 132 + aud_pid=$! 133 + printf '%s' "Press Ctrl+C to stop recording. " 1>&2 134 + wait $aud_pid 135 + 136 + # Reset the trap 137 + trap - INT 138 + 139 + printf '\n%s\n' "$filename" 140 + } 141 + 142 + # Take a screenshot 143 + scr_pic() { 144 + # Create directories if they do not already exist 145 + [ -d "$scr_pic_dir" ] || \ 146 + { mkdir -p "$scr_pic_dir" || die "failed to make directory: $scr_pic_dir"; } 147 + 148 + [ -d "$SCR_CACHE_DIR" ] || \ 149 + { mkdir -p "$SCR_CACHE_DIR" || \ 150 + die "failed to create directory: $SCR_CACHE_DIR"; } 151 + 152 + filename="$scr_pic_dir/$pic_filename" 153 + 154 + if [ "$output" = "all" ] 155 + then 156 + # Grim will screenshot all monitors by default 157 + grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1 158 + else 159 + # Get the geometry of the screenshot from the user and take the screenshot 160 + # shellcheck disable=SC2086 161 + if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp ${SLURP_ARGS})"; fi 162 + grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1 163 + fi 164 + 165 + # Copy the image to the system clipboard 166 + $copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; } 167 + 168 + printf '%s\n' "$filename" 169 + } 170 + 171 + scr_rec() { 172 + # Create directories if they do not already exist 173 + [ -d "$scr_rec_dir" ] || \ 174 + { mkdir -p "$scr_rec_dir" || die "failed to make directory: $scr_pic_dir"; } 175 + 176 + [ -d "$SCR_CACHE_DIR" ] || \ 177 + { mkdir -p "$SCR_CACHE_DIR" || \ 178 + die "failed to make directory: $SCR_CACHE_DIR"; } 179 + 180 + filename="$scr_rec_dir/$rec_filename" 181 + 182 + # Set wf-recorder arguments based on script options 183 + [ "$microphone" ] && args="-a$aud_source" 184 + [ "$desktop_audio" ] && args="-a$aud_sink" 185 + 186 + # If both microphone and desktop_audio is set, create a loopback devices pointing to 187 + # scr_inputs. wf-record does not support multiple audio devices. This is how they 188 + # recomend you record two devices at the same time. 189 + [ "$microphone" ] && [ "$desktop_audio" ] && { 190 + unload_pulse_modules=true 191 + null_sink=$(pactl load-module module-null-sink sink_name=aud_both) 192 + lb_desk=$(pactl load-module module-loopback sink=aud_both source="$aud_sink") 193 + lb_mic=$(pactl load-module module-loopback sink=aud_both source="$aud_source") 194 + args="-aaud_both.monitor" 195 + } 196 + 197 + # Pressing Ctrl+C will exit the script instead of just wf-recorder. 198 + # Intercept Ctrl+C and exit wf-recorder instead of the script 199 + trap '' INT 200 + 201 + # shellcheck disable=SC2086 202 + if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp ${SLURP_ARGS})"; fi 203 + # Word splitting is favorable here 204 + # shellcheck disable=SC2086 205 + wf-recorder $args $rec_extraflags "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 & 206 + rec_pid=$! 207 + printf '%s' "Press Ctrl+C to stop recording. " 1>&2 208 + wait $rec_pid 209 + 210 + # Reset the trap 211 + trap - INT 212 + 213 + # Clean up pulseaudio modules that the script created 214 + [ "$unload_pulse_modules" ] && { 215 + pactl unload-module "$lb_mic" 216 + pactl unload-module "$lb_desk" 217 + pactl unload-module "$null_sink" 218 + } 219 + 220 + printf '\n%s\n' "$filename" 221 + } 222 + 223 + $action 224 + 225 + # Run post scripts 226 + # Scripts in the directory `$SCR_CFG_DIR/scripts` will 227 + # take in `$action` as `$1` and `$filename` as `$2`. 228 + # Sample scripts can be found in my dotfiles at: 229 + # https://github.com/yemouu/setup/blob/master/home/cfg/scr/scripts 230 + for i in "$SCR_CFG_DIR/scripts/"* 231 + do 232 + [ -x "$i" ] && { 233 + printf '%s\n' "# $i --- START" >> "$SCR_CACHE_DIR/scripts.log" 234 + $i "$action" "$filename" > "$SCR_CACHE_DIR/scripts.log" 2>&1 235 + printf '%s\n' "# $i --- END" >> "$SCR_CACHE_DIR/scripts.log" 236 + } 237 + done
+174
scritps/thm
··· 1 + #!/bin/sh 2 + # shellcheck disable=SC1090,SC2154 3 + 4 + # Usage statement 5 + usage() { 6 + printf '%s\n' "usage: ${0##*/} theme" 7 + } 8 + 9 + # Convert hex colors into rgb 10 + hex2rgb() { 11 + hex=$1 12 + hex_r=${hex%????} 13 + hex_g=${hex#??}; hex_g=${hex_g%??} 14 + hex_b=${hex#????} 15 + 16 + printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b" 17 + } 18 + 19 + # Set directory variables 20 + [ "$THM_CONFIG_DIR" ] \ 21 + && conf_dir="$THM_CONFIG_DIR" \ 22 + || conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm" 23 + 24 + [ "$THM_DEST_DIR" ] \ 25 + && dest_dir="$THM_DEST_DIR" \ 26 + || dest_dir="${XDG_STATE_HOME:-$HOME/.local/state}/thm" 27 + 28 + err() { 29 + [ "$*" ] && err_msg="$*" || err_msg="error" 30 + printf '%s%b' "${0##*/}: " "$err_msg\n" 1>&2 31 + exit 1 32 + } 33 + 34 + # Ensure the theme file exist and source it 35 + case $1 in 36 + -h|h|--help|help ) usage; exit 0 ;; 37 + * ) [ "$1" ] || err "missing argument" 38 + [ -f "$conf_dir/themes/$1.theme" ] || err "$1: theme not found" 39 + theme_file="$conf_dir/themes/$1.theme" 40 + . "$theme_file" ;; 41 + esac 42 + 43 + # Create RGB colors from the hex colors 44 + bg_color_rgb="$(hex2rgb "$bg_color")" 45 + fg_color_rgb="$(hex2rgb "$fg_color")" 46 + color0_rgb="$(hex2rgb "$color0")" 47 + color1_rgb="$(hex2rgb "$color1")" 48 + color2_rgb="$(hex2rgb "$color2")" 49 + color3_rgb="$(hex2rgb "$color3")" 50 + color4_rgb="$(hex2rgb "$color4")" 51 + color5_rgb="$(hex2rgb "$color5")" 52 + color6_rgb="$(hex2rgb "$color6")" 53 + color7_rgb="$(hex2rgb "$color7")" 54 + color8_rgb="$(hex2rgb "$color8")" 55 + color9_rgb="$(hex2rgb "$color9")" 56 + color10_rgb="$(hex2rgb "$color10")" 57 + color11_rgb="$(hex2rgb "$color11")" 58 + color12_rgb="$(hex2rgb "$color12")" 59 + color13_rgb="$(hex2rgb "$color13")" 60 + color14_rgb="$(hex2rgb "$color14")" 61 + color15_rgb="$(hex2rgb "$color15")" 62 + 63 + # Make sure the dest_dir and dest_dir/thm_old exist 64 + [ -d "$dest_dir/thm_old" ] || mkdir -p "$dest_dir/thm_old" 65 + 66 + # Try and empty the dest_dir before populating it 67 + mv "$dest_dir/"* "$dest_dir/thm_old" 2> /dev/null 68 + 69 + # Make a file with the name of the new theme 70 + printf '%s\n' "$theme_file" > "$dest_dir/current_thm" 71 + 72 + # Repalce template syntax with the actual colors 73 + for t in "${conf_dir}/templates/"*".template" 74 + do 75 + file_name=${t##*/} 76 + file_name=${file_name%.template} 77 + 78 + sed " 79 + s/{bg_color}/$bg_color/g 80 + s/{fg_color}/$fg_color/g 81 + s/{color0}/$color0/g 82 + s/{color1}/$color1/g 83 + s/{color2}/$color2/g 84 + s/{color3}/$color3/g 85 + s/{color4}/$color4/g 86 + s/{color5}/$color5/g 87 + s/{color6}/$color6/g 88 + s/{color7}/$color7/g 89 + s/{color8}/$color8/g 90 + s/{color9}/$color9/g 91 + s/{color10}/$color10/g 92 + s/{color11}/$color11/g 93 + s/{color12}/$color12/g 94 + s/{color13}/$color13/g 95 + s/{color14}/$color14/g 96 + s/{color15}/$color15/g 97 + s/{bg_color.rgb}/$bg_color_rgb/g 98 + s/{fg_color.rgb}/$fg_color_rgb/g 99 + s/{color0.rgb}/$color0_rgb/g 100 + s/{color1.rgb}/$color1_rgb/g 101 + s/{color2.rgb}/$color2_rgb/g 102 + s/{color3.rgb}/$color3_rgb/g 103 + s/{color4.rgb}/$color4_rgb/g 104 + s/{color5.rgb}/$color5_rgb/g 105 + s/{color6.rgb}/$color6_rgb/g 106 + s/{color7.rgb}/$color7_rgb/g 107 + s/{color8.rgb}/$color8_rgb/g 108 + s/{color9.rgb}/$color9_rgb/g 109 + s/{color10.rgb}/$color10_rgb/g 110 + s/{color11.rgb}/$color11_rgb/g 111 + s/{color12.rgb}/$color12_rgb/g 112 + s/{color13.rgb}/$color13_rgb/g 113 + s/{color14.rgb}/$color14_rgb/g 114 + s/{color15.rgb}/$color15_rgb/g 115 + " "$t" > "${dest_dir}/${file_name}" 116 + done 117 + 118 + # This allows for different configuration for different color schemes. 119 + # Configuration for one theme may not work very well for another theme. To use 120 + # this set theme_type in the theme file to any string and place theme specific 121 + # configuration in `${XDG_CONFIG_HOME:-$HOME/.config}/thm/templates/$theme_type`. 122 + # If not specified, only templates in the base template directory will be generated. 123 + # This will overwrite previously generated template files. 124 + [ "$theme_type" ] && [ -d "${conf_dir}/templates/$theme_type" ] && \ 125 + for t in "${conf_dir}/templates/$theme_type/"*".template" 126 + do 127 + file_name=${t##*/} 128 + file_name=${file_name%.template} 129 + 130 + sed " 131 + s/{bg_color}/$bg_color/g 132 + s/{fg_color}/$fg_color/g 133 + s/{color0}/$color0/g 134 + s/{color1}/$color1/g 135 + s/{color2}/$color2/g 136 + s/{color3}/$color3/g 137 + s/{color4}/$color4/g 138 + s/{color5}/$color5/g 139 + s/{color6}/$color6/g 140 + s/{color7}/$color7/g 141 + s/{color8}/$color8/g 142 + s/{color9}/$color9/g 143 + s/{color10}/$color10/g 144 + s/{color11}/$color11/g 145 + s/{color12}/$color12/g 146 + s/{color13}/$color13/g 147 + s/{color14}/$color14/g 148 + s/{color15}/$color15/g 149 + s/{bg_color.rgb}/$bg_color_rgb/g 150 + s/{fg_color.rgb}/$fg_color_rgb/g 151 + s/{color0.rgb}/$color0_rgb/g 152 + s/{color1.rgb}/$color1_rgb/g 153 + s/{color2.rgb}/$color2_rgb/g 154 + s/{color3.rgb}/$color3_rgb/g 155 + s/{color4.rgb}/$color4_rgb/g 156 + s/{color5.rgb}/$color5_rgb/g 157 + s/{color6.rgb}/$color6_rgb/g 158 + s/{color7.rgb}/$color7_rgb/g 159 + s/{color8.rgb}/$color8_rgb/g 160 + s/{color9.rgb}/$color9_rgb/g 161 + s/{color10.rgb}/$color10_rgb/g 162 + s/{color11.rgb}/$color11_rgb/g 163 + s/{color12.rgb}/$color12_rgb/g 164 + s/{color13.rgb}/$color13_rgb/g 165 + s/{color14.rgb}/$color14_rgb/g 166 + s/{color15.rgb}/$color15_rgb/g 167 + " "$t" > "${dest_dir}/${file_name}" 168 + done 169 + 170 + # Run extra user scripts 171 + [ -d "$conf_dir/scripts" ] || exit 0 172 + for i in "$conf_dir/scripts/"* 173 + do [ -x "$i" ] && $i > /dev/null 2>&1 & 174 + done
-121
thm
··· 1 - #!/bin/sh 2 - # shellcheck disable=SC1090,SC2154 3 - 4 - # Usage statement 5 - usage() { 6 - printf '%s\n' "usage: ${0##*/} theme" 7 - } 8 - 9 - # Convert hex colors into rgb 10 - hex2rgb() { 11 - hex=$1 12 - hex_r=${hex%????} 13 - hex_g=${hex#??}; hex_g=${hex_g%??} 14 - hex_b=${hex#????} 15 - printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b" 16 - } 17 - 18 - # Set directory variables 19 - [ "$THM_CONFIG_DIR" ] \ 20 - && conf_dir="$THM_CONFIG_DIR" \ 21 - || conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm" 22 - [ "$THM_DEST_DIR" ] \ 23 - && dest_dir="$THM_DEST_DIR" \ 24 - || dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm" 25 - 26 - err() { 27 - [ "$*" ] && err_msg="$*" || err_msg="error" 28 - printf '%s%b' "${0##*/}: " "$err_msg\n" 1>&2 29 - exit 1 30 - } 31 - 32 - # Ensure the theme file exist and source it 33 - case $1 in 34 - -h|h|--help|help ) usage; exit 0 ;; 35 - * ) [ "$1" ] || err "missing argument" 36 - [ -f "$conf_dir/themes/$1.theme" ] || err "$1: theme not found" 37 - theme_file="$conf_dir/themes/$1.theme" 38 - . "$theme_file" ;; 39 - esac 40 - 41 - # Create RGB colors from the hex colors 42 - bg_color_rgb="$(hex2rgb "$bg_color")" 43 - fg_color_rgb="$(hex2rgb "$fg_color")" 44 - color0_rgb="$(hex2rgb "$color0")" 45 - color1_rgb="$(hex2rgb "$color1")" 46 - color2_rgb="$(hex2rgb "$color2")" 47 - color3_rgb="$(hex2rgb "$color3")" 48 - color4_rgb="$(hex2rgb "$color4")" 49 - color5_rgb="$(hex2rgb "$color5")" 50 - color6_rgb="$(hex2rgb "$color6")" 51 - color7_rgb="$(hex2rgb "$color7")" 52 - color8_rgb="$(hex2rgb "$color8")" 53 - color9_rgb="$(hex2rgb "$color9")" 54 - color10_rgb="$(hex2rgb "$color10")" 55 - color11_rgb="$(hex2rgb "$color11")" 56 - color12_rgb="$(hex2rgb "$color12")" 57 - color13_rgb="$(hex2rgb "$color13")" 58 - color14_rgb="$(hex2rgb "$color14")" 59 - color15_rgb="$(hex2rgb "$color15")" 60 - 61 - # Make sure the dest_dir and dest_dir/thm_old exist 62 - [ -d "$dest_dir/thm_old" ] || { mkdir -p "$dest_dir/thm_old" || err "failed to create $dest_dir/thm_old"; } 63 - 64 - # Try and empty the dest_dir before populating it 65 - mv "$dest_dir/"* "$dest_dir/thm_old" 2> /dev/null 66 - 67 - # Make a file with the name of the new theme 68 - printf '%s\n' "$theme_file" > "$dest_dir/current_thm" 69 - 70 - # Repalce template syntax with the actual colors 71 - for t in "${conf_dir}/templates/"*".template" 72 - do 73 - file_name=${t##*/} 74 - file_name=${file_name%.template} 75 - 76 - sed " 77 - s/{bg_color}/$bg_color/g 78 - s/{fg_color}/$fg_color/g 79 - s/{color0}/$color0/g 80 - s/{color1}/$color1/g 81 - s/{color2}/$color2/g 82 - s/{color3}/$color3/g 83 - s/{color4}/$color4/g 84 - s/{color5}/$color5/g 85 - s/{color6}/$color6/g 86 - s/{color7}/$color7/g 87 - s/{color8}/$color8/g 88 - s/{color9}/$color9/g 89 - s/{color10}/$color10/g 90 - s/{color11}/$color11/g 91 - s/{color12}/$color12/g 92 - s/{color13}/$color13/g 93 - s/{color14}/$color14/g 94 - s/{color15}/$color15/g 95 - s/{bg_color.rgb}/$bg_color_rgb/g 96 - s/{fg_color.rgb}/$fg_color_rgb/g 97 - s/{color0.rgb}/$color0_rgb/g 98 - s/{color1.rgb}/$color1_rgb/g 99 - s/{color2.rgb}/$color2_rgb/g 100 - s/{color3.rgb}/$color3_rgb/g 101 - s/{color4.rgb}/$color4_rgb/g 102 - s/{color5.rgb}/$color5_rgb/g 103 - s/{color6.rgb}/$color6_rgb/g 104 - s/{color7.rgb}/$color7_rgb/g 105 - s/{color8.rgb}/$color8_rgb/g 106 - s/{color9.rgb}/$color9_rgb/g 107 - s/{color10.rgb}/$color10_rgb/g 108 - s/{color11.rgb}/$color11_rgb/g 109 - s/{color12.rgb}/$color12_rgb/g 110 - s/{color13.rgb}/$color13_rgb/g 111 - s/{color14.rgb}/$color14_rgb/g 112 - s/{color15.rgb}/$color15_rgb/g 113 - " "$t" > "${dest_dir}/${file_name}" 114 - done 115 - 116 - # Run extra user scripts 117 - [ -d "$conf_dir/scripts" ] || exit 0 118 - for i in "$conf_dir/scripts/"* 119 - do 120 - [ -x "$i" ] && $i > /dev/null 2>&1 & 121 - done