• Too many trolls -- starve 'em!

    From vallor@vallor@vallor.earth to comp.os.linux.advocacy on Sat Oct 18 21:15:31 2025
    From Newsgroup: comp.os.linux.advocacy

    One abusive ignoramous wasn't enough, now we have the return of
    "Mr. Woopsie-daisy".

    Only one thing to do: Ignore them, and talk about Linux, until they fade away.

    A user service set up on my workstation:

    In ~/.config/systemd/user:

    $ cat blink_daemon-env.service
    [Unit]
    Description=Resolve Scroll Lock LED path and write env Before=blink_daemon.service

    [Service]
    Type=oneshot
    ExecStart=%h/bin/blink_daemon_env.sh

    $ cat blink_daemon.service
    [Unit]
    Description=Blink Scroll Lock LED (using generated env) After=blink_daemon-env.service
    Requires=blink_daemon-env.service
    # Optional: only start if the generated path file exists ConditionPathExists=%t/blink_daemon.path

    [Service]
    Type=simple
    EnvironmentFile=%t/blink_daemon.env
    ExecStart=%h/bin/blink_daemon.pl ${LED_PATH}
    Restart=on-failure
    RestartSec=2s

    [Install]
    WantedBy=default.target

    ...and then in ~/bin:

    $ cat blink_daemon_env.sh
    #!/usr/bin/env bash
    set -euo pipefail
    shopt -s nullglob

    # Resolve the runtime dir that maps to %t in systemd user units RUNDIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"

    # Find the first Scroll Lock LED brightness knob matches=(/sys/class/leds/*scrolllock/brightness)
    if (( ${#matches[@]} == 0 )); then
    echo "No /sys/class/leds/*scrolllock/brightness found" >&2
    exit 1
    fi
    LED="${matches[0]}"

    # Write the env + path files used by the main unit
    printf 'LED_PATH=%s\n' "$LED" > "$RUNDIR/blink_daemon.env"
    printf '%s\n' "$LED" > "$RUNDIR/blink_daemon.path"

    $ cat blink_daemon.pl
    #!/usr/bin/perl

    use strict;
    use warnings;

    use Time::HiRes qw(nanosleep);
    use IO::Socket::UNIX qw(SOCK_STREAM);
    use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK :mode);
    use IO::Select;

    our $fn_led=`eval echo /sys/class/leds/*scrolllock/brightness`;
    chomp($fn_led);
    our $delay = 250_000_000;
    our $fd_led;

    our $unix_path = $ENV{'XDG_RUNTIME_DIR'} || '/tmp';
    $unix_path .= '/blink_daemon';

    $SIG{INT} = $SIG{TERM} = sub { unlink $unix_path; exit 0 };

    umask 0077;

    my $srv = IO::Socket::UNIX->new(
    Type => SOCK_STREAM,
    Local => $unix_path,
    Listen => 128,
    ) || die "create/listen $unix_path: $!";

    my $flags = fcntl($srv, F_GETFL, 0) || die "F_GETFL: $!";

    fcntl($srv, F_SETFL, $flags | O_NONBLOCK) || die "F_SETFL: $!";

    my $sel = IO::Select->new($srv);

    my $counter = 0;

    SVC:
    while(1)
    #<<<
    {
    my @ready = $sel->can_read(0);

    for my $s (@ready)
    {
    while(1)
    {
    my $cli = $s->accept();
    last unless $cli;
    my $line = <$cli>;
    close($cli);
    chomp($line);
    $counter=int($line+0);
    if($counter < 0) { $counter = 0; }
    }
    }

    blink($counter);
    sleep(3);
    } # SVC loop


    sub blink
    {
    my $counter = shift || 0;
    for(my $i=0;$i<$counter;$i++)
    {
    set_led(1);
    nanosleep($delay);
    set_led(0);
    nanosleep($delay);
    }
    }

    sub set_led
    {
    my $val = shift || '0';
    open($fd_led,">$fn_led") || die("$!");
    (print $fd_led "$val\n");
    close($fd_led);
    }

    ##

    Then after starting the service (systemctl --user start blink_daemon),
    you can write a number to it with a simple client that calls socat:

    $ cat blink.sh
    #!/bin/bash

    if [ "$1" == "" ]
    then
    counter=0
    else
    counter=$1
    fi

    echo $counter | socat - UNIX-CONNECT:$XDG_RUNTIME_DIR/blink_daemon
    --
    -v System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090Ti 24G
    OS: Linux 6.17.3 D: Mint 22.2 DE: Xfce 4.18
    NVIDIA: 580.95.05 Mem: 258G
    "How many weeks are there in a light year?"
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From pothead@pothead@snakebite.com to comp.os.linux.advocacy on Sat Oct 18 22:52:10 2025
    From Newsgroup: comp.os.linux.advocacy

    On 2025-10-18, vallor <vallor@vallor.earth> wrote:
    One abusive ignoramous wasn't enough, now we have the return of
    "Mr. Woopsie-daisy".

    Only one thing to do: Ignore them, and talk about Linux, until they fade away.

    A user service set up on my workstation:

    In ~/.config/systemd/user:

    $ cat blink_daemon-env.service
    [Unit]
    Description=Resolve Scroll Lock LED path and write env Before=blink_daemon.service

    [Service]
    Type=oneshot
    ExecStart=%h/bin/blink_daemon_env.sh

    $ cat blink_daemon.service
    [Unit]
    Description=Blink Scroll Lock LED (using generated env) After=blink_daemon-env.service
    Requires=blink_daemon-env.service
    # Optional: only start if the generated path file exists ConditionPathExists=%t/blink_daemon.path

    [Service]
    Type=simple
    EnvironmentFile=%t/blink_daemon.env
    ExecStart=%h/bin/blink_daemon.pl ${LED_PATH}
    Restart=on-failure
    RestartSec=2s

    [Install]
    WantedBy=default.target

    ...and then in ~/bin:

    $ cat blink_daemon_env.sh
    #!/usr/bin/env bash
    set -euo pipefail
    shopt -s nullglob

    # Resolve the runtime dir that maps to %t in systemd user units RUNDIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"

    # Find the first Scroll Lock LED brightness knob matches=(/sys/class/leds/*scrolllock/brightness)
    if (( ${#matches[@]} == 0 )); then
    echo "No /sys/class/leds/*scrolllock/brightness found" >&2
    exit 1
    fi
    LED="${matches[0]}"

    # Write the env + path files used by the main unit
    printf 'LED_PATH=%s\n' "$LED" > "$RUNDIR/blink_daemon.env"
    printf '%s\n' "$LED" > "$RUNDIR/blink_daemon.path"

    $ cat blink_daemon.pl
    #!/usr/bin/perl

    use strict;
    use warnings;

    use Time::HiRes qw(nanosleep);
    use IO::Socket::UNIX qw(SOCK_STREAM);
    use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK :mode);
    use IO::Select;

    our $fn_led=`eval echo /sys/class/leds/*scrolllock/brightness`; chomp($fn_led);
    our $delay = 250_000_000;
    our $fd_led;

    our $unix_path = $ENV{'XDG_RUNTIME_DIR'} || '/tmp';
    $unix_path .= '/blink_daemon';

    $SIG{INT} = $SIG{TERM} = sub { unlink $unix_path; exit 0 };

    umask 0077;

    my $srv = IO::Socket::UNIX->new(
    Type => SOCK_STREAM,
    Local => $unix_path,
    Listen => 128,
    ) || die "create/listen $unix_path: $!";

    my $flags = fcntl($srv, F_GETFL, 0) || die "F_GETFL: $!";

    fcntl($srv, F_SETFL, $flags | O_NONBLOCK) || die "F_SETFL: $!";

    my $sel = IO::Select->new($srv);

    my $counter = 0;

    SVC:
    while(1)
    #<<<
    {
    my @ready = $sel->can_read(0);

    for my $s (@ready)
    {
    while(1)
    {
    my $cli = $s->accept();
    last unless $cli;
    my $line = <$cli>;
    close($cli);
    chomp($line);
    $counter=int($line+0);
    if($counter < 0) { $counter = 0; }
    }
    }

    blink($counter);
    sleep(3);
    } # SVC loop


    sub blink
    {
    my $counter = shift || 0;
    for(my $i=0;$i<$counter;$i++)
    {
    set_led(1);
    nanosleep($delay);
    set_led(0);
    nanosleep($delay);
    }
    }

    sub set_led
    {
    my $val = shift || '0';
    open($fd_led,">$fn_led") || die("$!");
    (print $fd_led "$val\n");
    close($fd_led);
    }

    ##

    Then after starting the service (systemctl --user start blink_daemon),
    you can write a number to it with a simple client that calls socat:

    $ cat blink.sh
    #!/bin/bash

    if [ "$1" == "" ]
    then
    counter=0
    else
    counter=$1
    fi

    echo $counter | socat - UNIX-CONNECT:$XDG_RUNTIME_DIR/blink_daemon

    Nice !

    I have a somewhat odd request. I have about 2TB of files that have been compressed as
    RAR files.
    The majority of them have associated PAR files as well.
    They are all in different directories under a single top level directory called "compressed".

    So how can I run something like "QuickPar" under Linux to traverse the directories and automatically
    repair what is broken?
    And once that completes, how can I do the same with the RAR files to combine them back into their
    original form which is mostly PDF and mp4?
    Using a gui will not work due to the number of files, directories and having to anwer the prompts?

    Any ideas?
    --
    pothead
    "I have a lot of friends who are Democrats, and they’re idiots.
    I always say they have big hearts and little brains.
    Almost every single policy rolled out failed.”

    -- Jamie Dimon CEO JPMorgan Chase.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From vallor@vallor@vallor.earth to comp.os.linux.advocacy on Sat Oct 18 23:20:26 2025
    From Newsgroup: comp.os.linux.advocacy

    At Sat, 18 Oct 2025 22:52:10 -0000 (UTC), pothead
    <pothead@snakebite.com> wrote:
    I have a somewhat odd request. I have about 2TB of files that have
    been compressed as RAR files. The majority of them have associated
    PAR files as well. They are all in different directories under a
    single top level directory called "compressed".

    So how can I run something like "QuickPar" under Linux to traverse
    the directories and automatically repair what is broken? And once
    that completes, how can I do the same with the RAR files to combine
    them back into their original form which is mostly PDF and mp4? Using
    a gui will not work due to the number of files, directories and
    having to anwer the prompts?

    Any ideas?

    Without knowing how your tree is laid out, it's hard to know, but any solution will probably use either parchive (for legacy PAR) or par2 (for PAR 2.0), along with find and unrar.

    unrar is shareware, as is rar, so you have to register it after 40 days (or so says synaptic).

    The way I'd do it is come up with a script where you can cd into one of your archive directories, run parchive (or par2), then run unrar. After you've satisfied youself that
    your script is working, you can use find . -type d to get a list of directories, possibly
    using -exec to run your script in each directory. Note that your script will probably
    need to accept a directory name as an argument, so it can chdir there to work your par/unrar magic.

    (Of course, this assumes you have just one archive per directory. If you have more
    than one, your find command will have to be that much smarter...)

    perl being my go-to language, I'd probably end up writing it in perl. I don't expect
    others to know perl, though, because it's gone out of style...alas. But if you're feeling
    adventurous, you can ask an LLM to write the script for you. (This newsreader is
    written in tk/perl, and large chunks of it are output from ChatGPT5.)

    Or if you want to be more modern about it, you might want to try python -- but first,
    try a shell script. It may be easier than you think.
    --
    -v System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090Ti 24G
    OS: Linux 6.17.3 D: Mint 22.2 DE: Xfce 4.18
    NVIDIA: 580.95.05 Mem: 258G
    "My other computer is a HAL 9000."
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From pothead@pothead@snakebite.com to comp.os.linux.advocacy on Sat Oct 18 23:56:11 2025
    From Newsgroup: comp.os.linux.advocacy

    On 2025-10-18, vallor <vallor@vallor.earth> wrote:
    At Sat, 18 Oct 2025 22:52:10 -0000 (UTC), pothead
    <pothead@snakebite.com> wrote:
    I have a somewhat odd request. I have about 2TB of files that have
    been compressed as RAR files. The majority of them have associated
    PAR files as well. They are all in different directories under a
    single top level directory called "compressed".

    So how can I run something like "QuickPar" under Linux to traverse
    the directories and automatically repair what is broken? And once
    that completes, how can I do the same with the RAR files to combine
    them back into their original form which is mostly PDF and mp4? Using
    a gui will not work due to the number of files, directories and
    having to anwer the prompts?

    Any ideas?

    Without knowing how your tree is laid out, it's hard to knoNew Boiler Reccomendations w, but any solution
    will probably use either parchive (for legacy PAR) or par2 (for PAR 2.0), along
    with find and unrar.

    unrar is shareware, as is rar, so you have to register it after 40 days (or so
    says synaptic).

    The way I'd do it is come up with a script where you can cd into one of your archive directories, run parchive (or par2), then run unrar. After you've satisfied youself that
    your script is working, you can use find . -type d to get a list of directories, possibly
    using -exec to run your script in each directory. Note that your script will probably
    need to accept a directory name as an argument, so it can chdir there to work your par/unrar magic.

    (Of course, this assumes you have just one archive per directory. If you have more
    than one, your find command will have to be that much smarter...)

    perl being my go-to language, I'd probably end up writing it in perl. I don't expect
    others to know perl, though, because it's gone out of style...alas. But if you're feeling
    adventurous, you can ask an LLM to write the script for you. (This newsreader is
    written in tk/perl, and large chunks of it are output from ChatGPT5.)

    Or if you want to be more modern about it, you might want to try python -- but first,
    try a shell script. It may be easier than you think.

    Thank you for your wonderful suggestions.
    I'm working on it as we speak.

    TIA.
    --
    pothead
    "I have a lot of friends who are Democrats, and they’re idiots.
    I always say they have big hearts and little brains.
    Almost every single policy rolled out failed.”

    -- Jamie Dimon CEO JPMorgan Chase.
    --- Synchronet 3.21a-Linux NewsLink 1.2