Thursday, December 7, 2017

Node.js breadcrumbs

Node.js is not properly installed until it's reliable in command line at the user level. Portions of node.js installed from Arch repositories are, of course, global to command line. The rest of the installation is mostly local to one project or another, as various modules become necessary.

global

For Arch, one can use pacman:
# pacman -S nodejs npm
These will work in any directory.

project

Suppose a user establishes a folder for their node.js project, and is working from that project directory. During their project, they recall that they need to install this or that module, say, express. The user roots up, runs # npm install express, then descends to user and continues working on their script, or some other operation which calls express. Eventually, to verify the express module's working, the user types "express" at the command line. Here's what would happen.
$ express
bash: express: command not found
Unlike pacman, npm is a node.js specific installer with its own directory structure. Node.js is roughly analogous to an independent LaTeX install: you can use $ tlmgr to update or control things, but not until the LaTeX directories are added to PATH. Likewise npm works from the command line, except that one must root-up when using it as an installer (# npm install [some package]). This is because the Arch version of npm places the modules into a root privilege directory /usr/lib/node_modules. This will hinder us throughout anything we do. We can place /usr/lib/node_modules/ in our PATH, which will allow execution, but we can never add or modify files in it. For this reason, I strongly believe that, like LaTeX, node.js should be installed in the HOME directory at user level, never requiring root privileges. If you install node.js with pacman, you'd have to pacman or yaourt every single module installed by node.js, or create PATH additions for each and every one that npm installs. No way, jose.
# pacman -Rs npm nodejs
$ rm -r .npm

nvm

For me, the easiest way to install a user-level node.js application was to use NVM volume manager to import node.js. NVM is upstream from node.js installations, so it can download and install any node.js version, allowing multiple releases to exist simultaneously on a system within the home director: users may select the version they wish to use directly from the user level.

The NVM script at the blog above downloads the latest git version of NVM, or just go directly to the install script here. I opened it with a word editor and reviewed it, then ran the script to download NVM.
$ sh ./install.sh
In addition to installing NVM at the user level, the install script appends to ~/.bashrc so the PATH is updated. I verified the changes, found them acceptable, and then sourced the .bashrc to activate the PATH change. Next, I verified nvm was detected and ran.
$ source .bashrc
$ nvm

npm

The next concept in user-space node.js is managing packages. Since node volumes can be placed using NVM, the packages for any version of node will be with a pacakage manager, NPM. it's good to use

Monday, October 30, 2017

Text-to-speech, multiple card

Overview: Single sound card setup isn't always easy, but this post has more than enough info for single card text-to-speech. As for multiple cards in ALSA, things can become complicated. My prior espeak post on multiple cards is beneficial if all the answers aren't here. Also a great multiple card site for the /usr/share/alsa/alsa.conf file. The deepest problem with two cards and HDMI is that, the cards can be re-ordered for default and less ALSA errors, but then HDMI errors may occur from conflicts of this re-ordering. What does the user want, HDMI errors, or ALSA errors? I prefer ALSA errors, given how difficult HDMI is to re-configure. I mostly take the easy way out and simply comment the lines inside /usr/share/alsa/alsa.conf.
I used this hack, and subbed espeak for festival, since I typically use espeak. Espeak works fine, but there are several potential problems once one gets to the point of xbindkeys. Not mentioned in these tutorials is that both ~/.xbindkeysrc AND ~/.xbindkeysrc.scm may be required for consistent operation.
  1. Verify espeak, eg...
    $ espeak "this is a test"
    This site has loads of options for the line.
  2. Install xsel. Xsel takes any selected text (stdout) and pipes it to any subsequent process we want, in this case, espeak.
  3. Select some text and then:
    $ xsel | espeak -s 100
    ... and whatever other espeak modifiers you want.
  4. Make a script from the two actions.
    $ nano talk.sh
    #!/bin/bash
    xsel | espeak -s 110
    eof
  5. Chmod talk.sh to activate it.
    $ chmod +x talk.sh
  6. Test it. Select/highlight some webpage or document text and then, in a terminal,
    $ ./talk.sh
    This speaks the selected text as many times as it's executed, that is, it's not a "one off" of the selected text.
  7. Here is where it becomes difficult: binding the script to a hotkey, eg, with xbindkeys. We first need to detect the numbers associated with pressing keyboard keys.
    # pacman -S xbindkeys
    $ xbindkeys -k
    xbindkeys -k allows a person to detect the numeric codes needed inside the ~/.xbindkeysrc file. One difficulty was the super-key, aka "windows" key. Eventually, I gave-up on this key and opted for the CTRL key in combination with the letter "k". I was then able to get numbers which worked within the configuration ~/.xbindkeysrc file (see below).
  8. Tie talk.sh to the key combo by creating an ~/.xbindkeysrc file.
    $ nano .xbindkeysrc
    "./talk.sh"
    m:0x4 + c:45
  9. Now start xbindkeys
    $ xbindkeys
  10. When I tried CTRL + k the selected text was spoken only once; the text had to be selected with the mouse each time I wanted it to speak. Somehow the text was being "lost" between usage.
  11. I troubleshot using
    $ xbindkeys -n -v
    which runs it in the foreground and provides info. Here, I received a message that there was no ~/.xbindkeysrc.scm. Accordingly, I next ran xbindkeys_config, the GUI front-end (obtained via yaourt xbindkeys_config-gtk2). Through the GUI, I reran the configuration, which tweaked the ~/.xbindkeysrc file. After that, I had consistent repetitive behavior from the hotkey combination.
  12. (Optional) I could have continued to call the script with the hotkey combination but, since the script was only one line, I didn't truly need a script in this case. I deleted the script. Within .xbindkeysrc, I replaced the script call with the script's contents, "xsel | espeak -s 100".
  13. Once consistent, I added xbindkeys to my windows-manager startup file.
    $ nano .icewm/startup
    xbindkeys &
  14. Exit and restart X, (or do, $ killall xbindkeys and $ xbindkeys) to be certain xbindkeys initializes using the ~/.xbindkeysrc configuration.
  15. Testing any of the configurations above is always the same: select text with the mouse, b) hit your key combination (eg., CTRL + k), and verify it repetitively audibles the text.

other

If there are audible delays for a word or two and you get errors like these...
$ xsel | espeak -s 100
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.HDA-Intel.pcm.front.7:CARD=1'
ALSA lib conf.c:4554:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5033:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
...then your speech datastream is probably moving along as ALSA attempts unsuccessfully to connect to JACK and so on. I have never been able to stop these JACK calls -- they seem embedded in the binary lib files, I've searched with grep throughout the ALSA file kludge. There's also speculation SPDIF sleep modes can do this. I think in my case it's a multiple card issue since I never have the delay on single soundcard issues. Secondly, HDMI validation with the display monitor also handshakes with the sound card and must have the same device numbers named in ALSA, as by UDEV. Think of the HDMI process as one which cascades from the ALSA setup, but has a dotted line to the kernel through the ELD verification. ALSA can rule it: scroll down to the ELD verification process in this prior post.

more about audible delays
Whatever delays from the speaker, the most important delays are to WAV files. We should be able to write...
$ espeak -s 100 "cut back" -w cutback.wav
...without delays. If we have ALSA speaker delays however, we typically have them writing to files also.

Add an extra word. I find the word "delay" takes the right amount of time to initialize SPDIF or perhaps multiple card JACK issues, so that...
$ espeak -s 100 "delay cut back" -w cutback.wav
...will create the file with only "cut back" spoken.
I renamed the unresponsibe ALSA libs for PulseAudio -- I don't ever use PulseAudio anyway...
# cd /usr/lib/alsa-lib/
# mv libasound_module_ctl_pulse.so zz_libasound_module_ctl_pulse.so
# mv libasoud_module_pcm_pulse.so zz_libasound_module_pcm_pulse.so
...this caused error of them not found, but better than not responding.


Friday, October 13, 2017

[solved] diacritics in linux

It's weird. I have to 1) Ctrl-Shift simultaneously with the letter "u". That leaves an underlined "u" in the text. 2) type the last three digits of the hex code, eg...

á = 0e1
é = 0e9
ñ = 0f1
ö = 0f6
ü = 0fc
° = 0b0

...and 3) Enter or Spacebar.

chromium

Specific to Chromium, we often find Cyrillic or Chinese symbols are replaced by boxes. In such cases, we have to go to the evil Adobe empire. So, for example, for some of the Chinese fonts...

# pacman -S adobe-source-han-sans-otc-fonts

...but one simply needs to search on "adobe-source" and one will find their language. Close and reopen Chromium once complete.

Thursday, October 12, 2017

Apache memory, SQLite backup and restore

Running one's (simple) personal-use HTML pages sometimes requires more than a browser, and so you gotta make a little sandbox. Reasons for posts here: 1) Little sandboxes nevertheless require Apache and PHP giants -- they must be minimized or they appropriate significant RAM and CPU desired for normal ops. 2) SQLite is useful, but should be backed up. How?

SQLite backup and restore

From this stack overflow page... "The safe way to backup is to run:
$ sqlite3 my_database.sq3
and then:
$ .backup backup_file.sq3
Result is copy of the database. It's different from regularly file copying, because it takes care of any users currently working on the database. There are proper locks set on the database, so the backup is done exclusively."

That's the proper way, but with one user (no worries about locks), simpler ways are available.

initialization

Apache: Main file httpd.conf. Problem: as noted at top, Apache combined with PHP can sip RAM incrementally. Serverfault.com has pages of helpful forum question answers for a fine-grained approach. One particularly helpful overview is here.

In general for a sandbox, you only need a couple of connections. I set MaxClients (MaxRequestWorkers since Apache 2.4) to "5".

Another thing is to be sure to enable

Monday, September 4, 2017

systemd, annoying since 2010

the problem
The latest in systemd annoyances is during start-up or shutdown.
A start-job is running for....[some shiat]
However added to this will be a counter with
12 secs/no limit
meaning you have to sit there and watch the seconds tick past with no idea when the thing is going to time out, or IF it will time out. So much for a fast boot or expeditious shut-down.

Some investigation shows this is commonly fixed in either
/etc/systemd/system.conf
/etc/systemd/user.conf
But here's the kludge. You go into /etc/systemd/user.conf and this points to yet further information
# You can override the directives in this file by creating files in
# /etc/systemd/user.conf.d/*.conf.
Override the overrides. Can you imagine? No wonder sites like
this one exist.

politics
I never understood the problems with udev, but it's unsurprising to me that systemd was developed at RedHat, which seems to attempt to proprietize various Linux features, perhaps to benefit their Linux support schemes, or to attempt misguided "improvements" to the Linux OS, for who knows what reason(s).

Saturday, June 17, 2017

[solved] A "simple" line and arrow photo mod

Twenty years on in Linux, it's still not easy to take a PNG or JPG and circle something, do a simple straight line, a straight line with an arrow and text, etc, and then resave the file at the same resolution.
  • Xournal will not open PNGs
  • GIMP has rasterized, freehand looking garbage, else you learn to do colored paths with transparent fills, which only works for the circles. Ludicrous.
  • DIA appears unreliable opening PNG's -- it will snap lines to weird locations and so on.
  • Libre Office, could be installed, and then one could add, say, "Draw", which will work on adding arrows, if a person can put up with the immense installation, memory use, and significant updates.
So there's no simple way to note these photos unless one has a large application. Since Inkscape is smaller than Libre Office... OK then, Inkscape it is, though you know it's not going to be easy.

Inkscape: Line and arrow - lots of keystrokes

From this site, there's an unhelpfully incomplete version, to which I've added important steps.
  1. Open the PNG
    "File" -> "Open", then select the PNG
  2. Open "lines mode"
    Select lines from side menu or (Shift+F6)
  3. Make a line
    Click the starting point of the line, click its ending point, and then press "enter" key. The line is not done until "enter" is pressed.
  4. Adjust the line features
    • "Object" --> "Fill and Stroke", or (Shift+Ctrl+F) opens the Fill and Stroke Dialog. A new half-page dialog window appears.
    • Select "Stroke Style" tab. Here you can increase width of the line from 1 pixel to whatever's comfortable.
  5. Select an arrowhead
    Also within the "Stroke Style" tab are "Markers". These are the ending points of the line. Choose an arrow or some other shape for the Start Marker or End Marker of the line.
  6. Save the changes
    "File" --> "Save", or export it to a new file. If exporting, select the entire page or just some selected region.

Thursday, April 20, 2017

[solved] Epson V30 (04b8:0131) v. V370 (04b8:0141a)

nb: 2022 - subbed "yay" for all "yaourt"

short version

Neither scanner will be detected in $ scanimage -L unless correct driver is used. Typically the V30 works well with only the driver, whereas the V370 needs the driver and may also need "epowka" adjustments described further down this page. Neither scanner requires CUPS.

V30 (04b8:0131) - $ yay -S iscan-plugin-gt-f720

V370 (04b8:014a) - $ yay -S iscan-plugin-perfection-v370

If still no proper V370 detection, check the "epowka" and "hpaio" notes further down. I've never been able to configure a box for both scanners so I could hook up either. I remove the driver for the scanner not being used.


prevention

  • check the connection
    $ lsusb
    ID 04b8:0131 Seiko Epson Corp. GT-F720 [GT-S620/Perfection V30/V300 Photo]
  • install and enable cups
    # pacman -S cups
    # systemctl list-unit-files |grep cups
    [if necesary....]
    # systemctl enable cups.service
    # systemctl restart cups.service
  • can play with turning cups on and off or even uninstalling it later, but it's likely to be initially necessary for the scanner to successfully build against
  • install the AUR driver
    $ yay -S iscan-plugin-gt-f720
  • verify it's a detected scanner
    $ scanimage -L
    device `epkowa:interpreter:001:006' is a Epson Perfection V30 flatbed scanner
  • try a test scan with, e.g. xsane

problem

Initiating the GUI xsane application with a USB-connected Epson V30 scanner results in a pause, then termination of the xsane application (without scanning). Connecting an Epson V370, the same actions result in normal xsane scanning operations. Using a known-good, functioning USB-connected Epson V370, let's run similar applications on both the V370 and the non-functioning V30, until we can find a difference, and hopefully solve the V30 non-operation.



CLI software

First, can we at least detect the V30 using the command-line? Two command line interface (CLI) scanner probes, scanimage and sane-find-scanner, verify slightly different features. Scanimage is the more thorough. Scanimage on the V30 pauses, but eventually goes to completion, describing the V30 as "unknown model".
$ scanimage -L
device `epkowa:usb:001:004' is a Epson (unknown model) flatbed scanner
... on the V370 there's no delay and the model name is identified.
$ scanimage -L
device `epkowa:interpreter:001:004' is a Epson Perfection V370 Photo flatbed scanner
Model name aside, the V30 and V370 are properly detected and trigger the kernel to create data files; we can rule-out hardware, firmware, or kernel problems. Since the USB device name for the V370 includes "interpreter", but the V30 device name remains "usb"; the kernel is not receiving additional information for the V30, beyond the simple usb connection. Let's locate the (operational) V370 driver on the hard drive, and see if the V30 is in the same folder and perhaps not working.
Attaching the USB V370, and stracing $ scanimage -T ($ strace scanimage -T 2>&1 |tee V370file.txt) and then searching inside the resulting text file, I noted (~line 1195)
open("/usr/lib/iscan/libiscan-plugin-perfection-v370.la", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/iscan/libiscan-plugin-perfection-v370.so", O_RDONLY|O_CLOEXEC) = 9
The V370 driver inside /usr/lib/iscan, however I could find no driver relevant to the V30 in that folder. It appears we're lacking a V30 driver. A V30 driver would give the kernel more information than "usb".

driver software

I lucked into a premade AUR version of the V30 driver -- one step with yaourt. A conversation about this driver exists on the forums. Apparently, the creator downloaded a DEB file from the Epson site and then converted the DEB into a pacman/yaourt package. It's probably also worth noting that DEB's can be directly installed on Arch with a couple of steps. In this case, I had the premade AUR version I could install more easily using yaourt.
$ yaourt Ss v30
aur/iscan-plugin-gt-f720 0.1.1-1 (8) (0.01)
EPSON Image Scan! plugin for Epson Perfection V30 scanner
$ yaourt -S iscan-plugin-gt-f720
After installation, the V30 should appear with its model information and "interpreter" instead of "usb"...
$ scanimage -L
device `epkowa:interpreter:001:004' is a Epson Perfection V30 flatbed scanner
...and scan images via xsane.

possible tweaks

If there are still problems, check the following.
  • Uncomment "usb" inside /etc/sane.d/epowka.conf, but without adding any make or model information, just leave it as "usb". If you add make or model, scanimage may generate a second, conflicting, instance of the V30.
  • Comment "epowka" in /etc/sane.d/dll.conf, or conflicts will occur.
  • The scanner libs directory should include softlinks to the main lib, libesci-interpreter-gt-f720.so, eg
    $ ls /usr/lib/iscan/
    libesci-interpreter-gt-f720.so
    libesci-interpreter-gt-f720.so.0
    libesci-interpreter-gt-f720.so.0.0.0
  • Run
    $ iscan-registry -a 0x04b8 0x0131 libesci-interpreter-gt-f720.so
See bottom of this page for more configuration file info.

Troubleshooting prior to yaourt

block hpaio

Sometimes hpaio loads when there's no HP scanner. Like many Linux apps, they either don't work at all or they can never be disabled. Hpaio won't stop the V30 or other scanners, but it's a hardcore annoyance since it's impossible to turn off via any interface, by disabling CUPS, etc. I got tired of this fast and blacklisted the sumb*tch. Find the names of the hp-related libsane files in /lib/sane.d/, because you can't find it and its dependencies the normal way...
# modinfo -F depends libsane-hp
modinfo: ERROR: Module libsane-hp not found.
... and then blacklist them via /etc/modprobe.d/blacklisted.conf (you can call the file anything).
# nano /etc/modprobe.d/blacklisted.conf
# stop hpaio annoyance when no hp scanner connected
install libsane-hpaio /bin/true
install libsane-hp /bin/true

xsane also loads hpaio

Any time xsane is initiated, xsane finds these hpaio drivers and loads them directly. Stracing xsane
open("./dll.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/sane.d/dll.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 7
fstat64(7, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents(7, /* 4 entries */, 32768) = 76
1572:stat64("/etc/sane.d/dll.d/hpaio", {st_mode=S_IFREG|0644, st_size=6, ...}) = 0
1573:open("./dll.d/hpaio", O_RDONLY) = -1 ENOENT (No such file or directory)
1574:open("/etc/sane.d/dll.d/hpaio", O_RDONLY) = 8
1576:read(8, "hpaio\n", 4096) = 6
4071:open("/usr/lib/sane/libsane-hpaio.so.1", O_RDONLY) = 19
4073:open("/usr/lib/sane/libsane-hpaio.so.1", O_RDONLY|O_CLOEXEC) = 19
so you will also have to disable xsane from activating hpaio.
# nano /etc/sane.d/dll.d/hpaio
# comment the following so hpaio doesn't load.
#hpaio
Note: don't forget that, if an HP scanner is ever connected, you'll need to undo these changes to both /etc/sane.d/dll.d/hpaio and to /etc/modprobe.d/blacklisted.conf.
But back to yaourt. Yaourt was the end-point, yet I had proceeded through several troubleshooting steps to determine the driver issue. A couple of workday's worth of effort were spent ruling-out any physical connection, firmware, kernel, or configuration files. Some of that is noted above, the remainder is below.

lsub -vv (v370)

Partial information from lsusb -vv:
idVendor 0x04b8 Seiko Epson Corp.
idProduct 0x014a
bcdDevice 1.00
iManufacturer 1 EPSON
iProduct 2 EPSON Perfection V37/V370
iSerial 0

lsub -vv (v30)

Partial information from lsusb -vv
idVendor 0x04b8 Seiko Epson Corp.
idProduct 0x0131 GT-F720 [GT-S620/Perfection V30/V300 Photo]
bcdDevice 1.00
iManufacturer 1 EPSON
iProduct 2 EPSON Scanner
iSerial 0

sane-find-scanner

Running sane-find-scanner (lsusb -vv also would have been fine) against both models, both scanners properly return hexadecimal model/product codes.
(vendor=0x04b8 [EPSON], product=0x014a [EPSON Perfection V37/V370])
... and for the V30, sane-find-scanner returns...
(vendor=0x04b8 [EPSON], product=0x0131 [EPSON Scanner])
I also attempted to get attributes and do tests on the V30, prior to yaourt.
$ scanimage -A -d 'epkowa:usb:001:004'
$ scanimage -T -d 'epkowa:usb:001:005'
Both of these time-out, returning nothing however, since we have the hexidecimal model code on both scanners (0131 for the V30 and 014a for the V370), firmware, hardware detection, and/or physical USB connection problems are ruled-out. There are three remaining categories of variables for this V30 problem. 1) Kernel software, application software, configuration files.

Kernel side

The kernel creates and destroys files inside the directory /run/udev/data/ whenever a USB device is connected or disconnected to a UNIX system. User-level applications, such as xsane, then read these files for operating parameters. So we'd like to check the /run/udev/data/ files for the V30. If they're good, we know xsane is malfunctioning. If they're bad, we know the kernel is malfunctioning (or not receiving enough V30 info).

/run/udev/data

How do we find the names of the files created when the V370 or the V30 are connected by USB? Sane-find-scanner is helpful, but we'll need to strace it to gather enough information. We'll send the two results to text files we can parse. First, the operating scanner, V370. Connect it to the USB port and, ($ strace sane-find-scanner 2>&1 |tee V370file.txt). At line 700 (YMMV) of V370file.txt, we find a call to the data file c189:5:
$ grep -rn "/run/udev/data"
open("/run/udev/data/c189:5", O_RDONLY|O_CLOEXEC) = 8
Next, the non-scanning V30. Connect it via USB and, $ strace sane-find-scanner 2>&1 |tee V30file.txt . At line 700 (again, YMMV) of V370file.txt, we find a call to the data file c189:4:
$ grep -rn "/run/udev/data"
open("/run/udev/data/c189:4", O_RDONLY|O_CLOEXEC) = 8
Now we have the names of the two data files the kernel creates, 189:5 for the V370, and 189:4 for the V30. Here's the content for the two files. The (functioning) V370
$ cat /run/udev/data/c189:5
I:97119577141
E:ID_VENDOR=EPSON
E:ID_VENDOR_ENC=EPSON
E:ID_VENDOR_ID=04b8
E:ID_MODEL=EPSON_Perfection_V37_V370
E:ID_MODEL_ENC=EPSON\x20Perfection\x20V37\x2fV370
E:ID_MODEL_ID=014a
E:ID_REVISION=0100
E:ID_SERIAL=EPSON_EPSON_Perfection_V37_V370
E:ID_BUS=usb
E:ID_USB_INTERFACES=:ffffff:
E:libsane_matched=yes
E:ID_VENDOR_FROM_DATABASE=Seiko Epson Corp.
E:ID_PATH=pci-0000:00:12.2-usb-0:2
E:ID_PATH_TAG=pci-0000_00_12_2-usb-0_2
E:ID_FOR_SEAT=usb-pci-0000_00_12_2-usb-0_2
G:uaccess
G:seat
...and, when the V30 is attached
$ cat /run/udev/data/c189:4
I:138131813751
E:ID_VENDOR=EPSON
E:ID_VENDOR_ENC=EPSON
E:ID_VENDOR_ID=04b8
E:ID_MODEL=EPSON_Scanner
E:ID_MODEL_ENC=EPSON\x20Scanner
E:ID_MODEL_ID=0131
E:ID_REVISION=0100
E:ID_SERIAL=EPSON_EPSON_Scanner
E:ID_BUS=usb
E:ID_USB_INTERFACES=:ffffff:
E:libsane_matched=yes
E:ID_VENDOR_FROM_DATABASE=Seiko Epson Corp.
E:ID_MODEL_FROM_DATABASE=GT-F720 [GT-S620/Perfection V30/V300 Photo]
E:ID_PATH=pci-0000:00:12.2-usb-0:2
E:ID_PATH_TAG=pci-0000_00_12_2-usb-0_2
E:ID_FOR_SEAT=usb-pci-0000_00_12_2-usb-0_2
G:uaccess
G:seat
Since both the V370 and the V30 files are properly created inside /run/udev/data/, the kernel is now ruled-out as a problem. Secondly, these presence of these data files also probably excludes the rules the kernel uses to write data files for /run/udev/data/. These rules for helping the kernel translate a physical USB connection into a data file are in /lib/udev/rules.d/. In the case of the scanner rules, the rules file is /lib/udev/rules.d/49-sane.rules. So far, everything has checked-out normally, and now we have ruled out the kernel's USB firmware detection and data propagation processes.

Unsolved

Our current unsolved clues related to the non-scanning are 1) the pause and eventual time-out when V30 is queried, 2) the unnamed model "Scanner", 3) the name "usb", instead of "interpreter" inside scanimage -L results.
# echo -1 >/sys/module/usbcore/parameters/autosuspend
Still, EAGAINs and the pauses did not stop, and this led me, finally, to a driver.

Other rule-outs: configuration files

  • /etc/sane.d/epson.conf - possibly could add the make and model to identify the V30, however if a yaourt or pacman solution is available, remove it.
  • /etc/sane.d/saned.conf - Should not be a problem, since V370 is operating
  • /etc/sane.d/dll.conf - No problems since V370 is working
  • /etc/sane.d/epkowa.conf - No problems since V370 operates
  • /usr/share/iscan-data/usb - Neither the 014a or the 0131 models are in this file. This file is opened during scanimage tests however.

[solved] Xerox WorkCentre 5875 on network

This is an interesting case. The only PPD at the Xerox driver site seemed to be embedded in a Windows EXE file -- this may have been complicated to access via, say, Wine. However, I eventually Googled upon an Italian site which provided the generic 5875 PPD, xrx5875.ppd. This version is considered to have only basic functionality, and it was compressed into a ZIP. I was unable to find a full-feature PPD.

Pressing onward, 1) unzip the ZIP to extract the PPD, 2) put the PPD into /usr/share/cups/model, 3) walk to the Xerox and retrieve the machine's IP address from its printer menu (in this case, 192.168.1.101), then....
# cp xrx5875.ppd /usr/share/cups/model/xrx5875.ppd
# chmod 644 /usr/share/cups/model/xrx5875.ppd
# systemctl enable org.cups.cupsd.service
# systemctl start org.cups.cupsd.service
# lpadmin -p WorkCentre5875 -E -v socket://192.168.1.101 -m xrx5875.ppd
After this, if the 5875 is the main copy/printer a person uses at work, they might consider going back into CUPS (http://localhost:631) and setting the Xerox to be the default printer.

Tuesday, March 21, 2017

GiMP - delete areas outside an image

GIMP mostly does exactly the opposite of what I want in a few steps, or takes many many steps to do what I want, or the tutorials leave out one critical step that costs my weekend. In other words, I hate GIMP, but it's free. Take the following image of an old duct-taped surfboard that I found online.


Suppose I wanted to delete the background and keep the foreground surfboard. You'd think, OK, 3 minutes,3 steps: take the magic wand/select, add transparency, then bucket fill the selected parts. Two problems: 1) the surfboard has black fins, so fuzzy select goes into the surfboard, 2) bucket fill fills a selected area, not areas outside a selected areas. So now I have to do this differently, and with a shitload of steps.

Tutorials (10 minutes):

  1. Do all the selection steps, click click path nodes, then hit edit and bend them. Then Select by Path
  2. Add alpha transparency layer
  3. Delete key
Your image will be deleted and your background will be left, just as if you used the bucket fill tool.

2 hours later, the Real (10 minutes):

  1. Do all the selection steps, click click path nodes, then hit edit and bend them. Then Select by Path
  2. Select-->Invert. This swaps what's selected with what's not selected or, say, the background with the foreground.
  3. Add alpha transparency layer
  4. Delete key

Wednesday, March 15, 2017

Locale miasma

Linux has so many problems and so many solutions, but if you've been in it for years, two of the biggest little issues that turn into patience cancers are sound and locales. Note from this page the number of variables which can be accepted.

But there are memory (aka "speed") concerns involved with locale selection, which is why I typically only use "C", by uncommenting it inside /etc/locale.conf. To check:
$ locale
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

However, suppose I want to do something as simple as play solitare.
$ sol v=Klondike
Non UTF-8 locale (ANSI_X3.4-1968) is not supported!

What's needed is a fast way to switch locales, obviously, but without the downstream issues of perhaps font regeneration and other failures.

Monday, February 13, 2017

tcpdump in userspace

Many times we'll have inexplicable collisions -- eg 2000ms pings -- on our home LAN. Is someone squatting on our LAN? Is it a configuration problem?

1. squatting

If I'm not at the LAN's router terminal to view the DHCP table...

# nmap -sn --max-rate 100 192.168.1.0/24

Slow-down the rate to 100 to catch cell phones, which otherwise may not have time to respond. The generic 192 net will obviously vary depending on setup.

2. weird collisions

If possible switch from channel 1 on the Wi-Fi of course. And if our client is at the outer range of the router, we'd expect more interference and might have to move things around.

If these are not the causes, we'd want to capture some traffic and review it for suspicious activity. This is not typically trivial. To access traffic, we need to install tcpdump and reconfigure it for user-level execution, so that its files (.PCAP) are easy to manage. Next, we attempt to constrain tcpdump's enormous PCAP captures to a manageable size and format. Finally, we could evaluate the PCAP network data. Let's do the last two first, since many readers already have tcpdump configured.

A. use and constrain PCAP

As usual, StackOverflow closes the most relevant questions as irrelevant, lol. But you can scroll down to bro to see how its done with bro. Wireshark and some others , Zeek are additional options.

Try to pre-simplify by limiting tcpdump. Obviously, tcpdump unhelpfully only outputs to the screen, so a person has to tee its output to a file, let's start there...

The command gets long, but we can get a good PCAP.

time limit

Tcpdump doesn't have an inherent duration flag. Users typically must CTRL-C which can corrupt the output file -- the program was natively designed to STDOUT to the screen. However the "-c" flag tells it how many packets to capture before quitting.

$ tcpdump [other filters] -c -w filename.$(date +%Y-%m-%d.%Z.%H.%M.%S).pcap

B. evaluate PCAP

Problematic areas include

C. configure tcpdump for user

Users must root-up to operate tcpdump as installed:

$ tcpdump
tcpdump: wifi01: You don't have permission to capture on that device

Of course, to see the error messages more completely:

$ strace tcpdump 2>&1 | tee file.txt

after initial setup

Typically problems only occur after a restart and/or an update. The steps for initial setup follow this section and users can refer to those if anything needs to be reset. Otherwise...

  1. attempt a user-level simple usage.
    $ tcpdump
  2. if all goes well, use the more complex commands discussed in section A.

initial setup

Generally, know which tcpdump location executes, and add the user to any created groups. General instructions.

For location, run $ strace tcpdump and note whether if fails in /bin, /usr/bin, /usr/sbin. For groups, verify inside /etc/group. Then...

  1. create pcap group and add the user
    # groupadd pcap
    # usermod -a -G pcap user
  2. give pcap group permissions to tcpdump and make it group executable (750). Let's suppose tcpdump executes from /usr/bin.
    # chgrp pcap /usr/bin/tcpdump
    # chmod 750 /usr/bin/tcpdump
  3. We modify executable (binary) file capabilities, in this case tcpdump, using setcap. The specified group, (not just root) can then operate the wifi in promiscuous mode.
    # setcap cap_net_raw,cap_net_admin=eip /usr/bin/tcpdump
  4. Verify the binary capabilities were updated
    $ getcap /usr/bin/tcpdump
    /usr/bin/tcpdump cap_net_admin,cap_net_raw=eip

problems

There can be other permission problems. The initial problem is user permission to the wifi device. That is handled above. A secondary problem is user access to run tcpdump. This gives the following failure.

$ tcpdump
bash: /usr/bin/tcpdump: Permission denied

One site adds this line to ensure tcpdump is receiving root access for the user. Suppose we verify by strace that our execution of tcpdump is from /usr/bin/tcpdump. His would be...

# groupadd tcpdump
# usermod -a -G tcpdump user
# chown root.tcpdump /usr/bin/tcpdump
# chmod 0750 /usr/sbin/tcpdump
# setcap cap_net_raw,cap_net_admin=eip /usr/bin/tcpdump

last resort

If everything is set, getcap is returning everything proper and the error still appears, we can change the execution from group level only (750), and add it to the user also (755). I consider this a last resort because, at that point, there is essentially zero security on the wifi card. However, a person could run 755 when they want to run wireshark or some such and

Saturday, January 28, 2017

[solved] evince not printing, not displaying printers

Googling around, this post appeared helpful and pointed toward the undocumented dependency problem. Solved with:
# pacman -S gtk3-print-backends
As someone noted on the post, "great catch"; this is a detail which can evaporate a person's weekend. Surprising that the packager wouldn't see it as a necessary dependency for evince, but that's life.