Compare commits

...

4 Commits

Author SHA1 Message Date
rhiannon morris e60a61ee76 add make-sizes 2023-11-10 02:26:26 +01:00
rhiannon morris ae7e6c796d various tablet-setup tweaks 2023-11-10 02:26:21 +01:00
rhiannon morris 4adf34027f make nix develop less annoying 2023-11-10 02:25:44 +01:00
rhiannon morris 92a86afffe add ( ) to little 2023-11-10 02:25:32 +01:00
4 changed files with 97 additions and 16 deletions

View File

@ -20,7 +20,7 @@ my %num = (
0 => '⁰', 1 => '¹', 2 => '²', 3 => '³',
([4..9] Z ['⁴'..'⁹']).Map
);
my %other = ('!' => 'ꜝ', '.' => '·');
my %other = ('!' => 'ꜝ', '.' => '·', '(' => '⁽', ')' => '⁾');
# }}}
my %caseless = %lc, %num, %other;
my %cased = %uc, %caseless;

80
bin/make-sizes Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env raku
enum Format <DEFAULT skip png webp jpg>;
#| resize images for uploading to gallery sites
unit sub MAIN(
#| number of concurrent jobs (default min{10, # cores})
Int :j(:$jobs) = min(10, $*KERNEL.cpu-cores),
#| format to use for mastodon (png, webp, jpg, skip)
Format :m(:$mastodon) is copy = DEFAULT,
#| format to use for itaku
Format :i(:$itaku) is copy = DEFAULT,
#| format to use for furaffinity/weasyl
Format :f(:$furaffinity) is copy = DEFAULT,
#| webp/jpg quality setting (default 98)
Int :Q(:$quality) = 98,
#| only run conversions explicitly mentioned
Bool :O(:$only) = False,
Bool :n(:$dry-run) = False,
Bool :v(:$verbose) = False,
#| out dir, default ./out
IO :o(:$outdir) = 'out'.IO,
#| defaults to all *.png & *.jpg files in the current dir
*@files,
);
sub cmd(*@args) {
say "> @args[]" if $dry-run || $verbose;
run @args unless $dry-run;
}
sub verbose(*@args) { say "> @args[]" if $verbose }
# fixup args
die "furaffinity/weasyl don't know what webp are" if $furaffinity == webp;
$mastodon ||= $only ?? skip !! webp;
$itaku ||= $only ?? skip !! webp;
$furaffinity ||= $only ?? skip !! png;
(@files .= map: *.IO) ||= $*CWD.dir: test => /:i \.[jpe?g|png]$/;
for @files { die "$_ is not a regular file" unless .f; }
# running imagemagick (and oxipng sometimes) 🪄
sub convert($in, $site, $format, *@flags) {
my $out = $outdir.child($in.basename).extension("$site.$format");
cmd <convert>, $in, @flags, $out;
cmd <oxipng -q>, $out if $format == png;
}
constant $SIZE = 2800;
constant $SQUARE = "{$SIZE}x{$SIZE}";
constant $MASTO-SIZE = "{1280**2}@";
my @sites = [
{:name<mastodon>, :format($mastodon), :size($MASTO-SIZE)},
{:name<itaku>, :format($itaku), :size($SQUARE)},
{:name<furaffinity>, :format($furaffinity), :size($SQUARE)},
].grep: *<format> != skip;
# go go go
sub parallel(@vals, &f) {
my $sem = Semaphore.new: $jobs;
my @tasks = @vals.map: { start { $sem.acquire; f $_; $sem.release } };
@tasks».result;
}
cmd <mkdir -p>, $outdir;
my @todo = @files X @sites;
parallel @todo, -> ($file, % (:$name, :$format, :$size)) {
state $i++;
say "[$i/@todo.elems()] $name $file.basename()";
convert $file, $name, $format, '-resize', $size, '-quality', $quality;
};

2
bin/nd
View File

@ -14,6 +14,6 @@ ifelse { test $nixdir = "" } {
}
cd $nixdir
nix develop $@ -c execlineb -c "cd ${cwd} ${shell}"
nix develop --no-warn-dirty $@ -c execlineb -c "cd ${cwd} ${shell}"
# vim: set ft=execline :

View File

@ -4,6 +4,8 @@
unit sub MAIN(
#| Don't run the commands, just print them (implies -v)
Bool :n(:$dry-run),
#| Don't turn on the screens
Bool :S(:$no-screens),
#| Print each command before running it
Bool :v(:$verbose) is copy,
#| Print the output of queries too (implies -v)
@ -113,7 +115,7 @@ my $did-something = False;
my $external = external-connected;
with $external { say-prefix "using display '$_'" }
with $external { say-v "using display '$_'" }
with Tablet.find: 'Intuos4' {
say-v "Setting up \"$_\"";
@ -129,7 +131,7 @@ with Tablet.find: 'Intuos4' {
for .stylus, .eraser, .cursor {
.set: :Rotate<half> :Area<0 0 65024 36576>; # full 65024x40640
with $external -> $ { .set: :MapToOutput($external); }
if defined $external { .set: :MapToOutput($external); }
}
for .stylus, .eraser {
@ -141,20 +143,20 @@ with Tablet.find: 'Intuos4' {
# circle
1 => {map => key('tab')},
# upper four, top to bottom
13 => {map => key('shift'), screen => 7, label => 'Sh/Rotate'},
12 => {map => key('ctrl'), screen => 6, label => 'Ctrl/Zoom'},
11 => {map => key('m'), screen => 5, label => 'Mirror'},
10 => {map => key('5'), screen => 4, label => 'Rotate 0°'},
13 => {map => key('shift'), screen => 7, label => "🠙 \xF0E2"}, # rotate
12 => {map => key('ctrl'), screen => 6, label => "⌃ \xF002"}, # magnifying glass
11 => {map => key('m'), screen => 5, label => '⌽'},
10 => {map => key('5'), screen => 4, label => '⦜'},
# lower four
9 => {map => key('.'), screen => 3, label => 'Brush +'},
8 => {map => key(','), screen => 2, label => 'Brush '},
3 => {map => key('insert'), screen => 1, label => 'Layer +'},
2 => {map => key('XF86AudioPlay'), screen => 0, label => 'Pause'},
9 => {map => key('.'), screen => 3, label => '●'},
8 => {map => key(','), screen => 2, label => '⋅'},
3 => {map => key('insert'), screen => 1, label => '⏥'},
2 => {map => key(:ctrl, <'>), screen => 0, label => '𝞪'},
);
update <sudo i4oled-chgrp>, $screen-dir;
spurt "$screen-dir/buttons_luminance", 15;
spurt "$screen-dir/buttons_luminance", ($no-screens ?? 0 !! 8);
given .pad {
.set: :AbsWheelDown(key('shift')) :AbsWheelUp(key('shift'));
@ -162,11 +164,10 @@ with Tablet.find: 'Intuos4' {
for %buttons.kv -> $button, % (:$map, :$screen, :$label) {
.set: :Button($button, $map);
next without $label & $screen;
next if $no-screens or not defined $label & $screen;
my $path = "$screen-dir/button{$screen}_rawimg";
fail "!!! no such device $path" unless $path.IO.f;
update <i4oled -l -t>, $label, '-d', $path;
}
}
@ -183,7 +184,7 @@ with Tablet.find: 'H420' {
# FIXME do this properly
.set: :MapToOutput<960x540+480+270>;
with $external -> $ { .set: :MapToOutput($external); }
if defined $external { .set: :MapToOutput($external); }
}
my %buttons = (