Quantize clipboard screenshots

This commit is contained in:
Nox Sluijtman 2024-07-23 11:20:44 +02:00
parent 7f0e165ae6
commit bafb134702
4 changed files with 12 additions and 14 deletions

View file

@ -2,16 +2,17 @@
, scdoc , scdoc
, xclip , xclip
, maim , maim
, pngquant
, stdenvNoCC , stdenvNoCC
, nushell , nushell
, xdotool , xdotool
, ... , ...
}: }:
stdenvNoCC.mkDerivation rec { stdenvNoCC.mkDerivation {
pname = "irs"; pname = "irs";
version = "0.3"; version = "0.3";
src = ./src; src = ./src;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = [
scdoc scdoc
nushell nushell
]; ];
@ -39,6 +40,7 @@ stdenvNoCC.mkDerivation rec {
substituteInPlace $out/bin/* \ substituteInPlace $out/bin/* \
--replace "xclip" "${xclip}/bin/xclip" \ --replace "xclip" "${xclip}/bin/xclip" \
--replace "maim" "${maim}/bin/maim" \ --replace "maim" "${maim}/bin/maim" \
--replace "pngquant" "${pngquant}/bin/pngquant" \
--replace "xdotool" "${xdotool}/bin/xdotool" --replace "xdotool" "${xdotool}/bin/xdotool"
''; '';

View file

@ -1,8 +1,8 @@
{ {
description = "A few random scripts"; description = "A few random scripts";
inputs = { inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixos-23.05; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = github:numtide/flake-utils; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:

View file

@ -15,7 +15,7 @@ fullscreen(){
selection(){ selection(){
maim -su "$filename" maim -su "$filename"
notify-send 'Maim utils' "Shot selection and saved output to:\n\n$filename\n\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status." notify-send 'Maim utils' "Shot selection and saved output to:\n\n$filename\n\n"
} }
focus(){ focus(){
@ -24,23 +24,23 @@ focus(){
} }
clip_fullscreen(){ clip_fullscreen(){
maim -ui root | xclip -sel clip -t image/png maim -ui root | pngquant - | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot entire screen and sent it to the clipboard." notify-send 'Maim utils' "Shot entire screen and sent it to the clipboard."
} }
clip_selection(){ clip_selection(){
maim -su | xclip -sel clip -t image/png maim -su | pngquant - | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status." notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status."
} }
clip_focus(){ clip_focus(){
maim -ui "$(xdotool getactivewindow)" | xclip -sel clip -t image/png maim -ui "$(xdotool getactivewindow)" | pngquant - | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot focussed window and sent it to the clipboard." notify-send 'Maim utils' "Shot focussed window and sent it to the clipboard."
} }
fancy_clip(){ fancy_clip(){
# nicked straight from the maim README (https://github.com/naelstrof/maim#examples) # nicked straight from the maim README (https://github.com/naelstrof/maim#examples)
maim -st 9999999 | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage PNG:- | xclip -sel clip -t image/png maim -st 9999999 | pngquant - | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage PNG:- | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status." notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status."
} }

View file

@ -1,9 +1,5 @@
#!/usr/bin/env nu #!/usr/bin/env nu
# (ls).name | each {|item| (cat $"($item)/capacity") } | lines
# open uevent | lines | parse "{key}={value}" | transpose -r
# let batteries = ( (ls /sys/class/power_supply).name | each {|item| open $"($item)/uevent" } | each {|item| $item | lines | parse "{key}={value}" | transpose -r })
let dateString = ^date let dateString = ^date
let discordianDate = ^ddate let discordianDate = ^ddate
@ -26,7 +22,7 @@ def get_batteries [] {
} | each {|| $in} } | each {|| $in}
$batteries | each {|i| $batteries | each {|i|
[ $i.POWER_SUPPLY_MANUFACTURER $i.POWER_SUPPLY_MODEL_NAME $i.POWER_SUPPLY_CAPACITY ] [ $i.POWER_SUPPLY_MANUFACTURER $i.POWER_SUPPLY_MODEL_NAME $i.POWER_SUPPLY_STATUS $i.POWER_SUPPLY_CAPACITY ]
| each {|j| | each {|j|
$j | first $j | first
} }