Posted on Leave a comment

RaspberryPi – Keyboard and Mouse Sharing 2

How to start the Keyboard and Mouse sharing tool Barrier from a SSH Command line.

Nothing is worse than having your Keyboard and Mouse sharing working but having to USB swap your keyboard when, for some reason or another, your Barrier install disconnects. With a few pieces of knowledge, you can ditch the second Keyboard and never USB swap again.

Pre-Requisites

  • ssh server running on the target RaspberryPi
  • Ability to login as the same user running the desktop on your RasberryPi
  • barrier installed on both machines.

Bare Bones Attempt

If all is well on your systems, this “might” work. Each line is a command. You will have to take the IP address from line 2 and plug it in to line 4 where you see my IP.

barrier
hostname -I
ssh pi@raspberrypi
barrierc --name raspberrypi --enable-crypto --display :0 192.168.0.185:24800

barrier, barrierc, barriers

The barrier tool is in actuality multiple programs.

barrier – A “wrapper” that runs th GUI

barrierc – The Barrier client

barriers – The Barrier server

The barrier command does not have an command line ability and simply launches the GUI which in turn launches the client or server as per chosen options. We will run the barrier client on the raspberry pi

To begin SSH to your RaspberryPi, it should looks something like this:

ssh pi@192.168.0.100

Identify the Client “Screen”

RaspberryPi runs a system called X. In order to connect the client to the proper desktop display we need to get something known as the display number. We can use the command w to get this information. Simply type W at the command line

pi@raspberrypi:~ $ w
 11:37:04 up  6:24,  3 users,  load average: 0.04, 0.10, 0.09
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
pi       tty7     :0               08:19    6:24m 39.88s  1.03s /usr/bin/lxsess
pi       tty1     -                07:04    4:31m  1.38s  0.51s -bash
pi       pts/0    192.168.0.185    11:35    0.00s  0.58s  0.04s w
pi@raspberrypi:~ $ 

The two most important pieces of information are from the columns USER and FROM

We want the first entry in the list, it is the user on tty7, user pi, you can see it is connected to the display :0 under the FROM column. This is why we used pi from ssh, to guarantee we have the same permission and access to the screen.

Let’s see the command and breakdown each option.

barrierc -f –debug INFO –name raspberrypi –enable-crypto –display :0 192.168.0.185:24800

barrierc – This is client binary

-f

Runs the command in the foreground, useful for getting things going so we can kill the client easily.

–debug INFO

provides information about what is happening, feedback.

–name raspberrypi

This is the name that you must add on the server config

–enable-crypto

The transmission of the mouse and keyboard data should be encrypted to avoid interception. The server is enabled by default and you will not be able to connect the client without this turned on.

–display :0

This is the X-Server display number the client is going to control keyboard and mouse for. This is the key difference when executing a graphically element from a desparate console. The barrierc program needs to be told what Desktop it is going to work with.

Normally the barrierc program is executed from within the desktop/windowing system that it is targeting so you don’t need to tell it, but as we are starting it remotely we need indicate the display number.

192.168.0.185:24800

Barrier Server IP and Port Number

Posted on Leave a comment

If you have not learned systemctl, you need to!

My server for this machine is low memory and the msyql piece craps out all the time. At this point when the site is unresponsive, I don’t even question what the issue will be. One command later and it is running again. After a largely useless legal warning.

Here is the magic command:

systemctl -H prandall@mathcodeprint.com restart mysql

The -H is the magic. This new service controller for system has built in ssh-ing abilities. You will need to provide a password if you have not set up your private keys.

And if I need to check up on the service, same command just with status:

systemctl -H prandall@mathcodeprint.com status mysql

For reference the old process would have been

ssh prandall@mathcodeprint.com
password
service mysql restart
exit

I know it doesn’t seem like a lot but, some of you will understand.

Posted on Leave a comment

WordPress Next Stage Social Sharing – Using AddToAny alongside Jetpack.

In my previous post, I walked through a description of the built-in sharing provided by Jetpack. Jetpack adds sharing directly to the publishing workflow. It also adds some helpful preview features. What it lacks is a large selection of social media sites.

To compensate I have added AddToAny as part of my must-have plugins. AddToAny provides easy to use icons for many Social Sharing websites. In particular, I was looking for a plugin that included MeWe, and AddToAny did not disappoint.

Jetpack automates my most prominent social sites, with AddToAny I need to click on the link and manually share, but add2any makes this a seamless process with only a few clicks.

The setup is very straight forward with a large number of services to choose from. You can activate each service with a single click.

I chose a handful of common services

There are a significant number of display options. I have it set only for posts.

If you are looking to get direct follows from your Website Add2Any includes a follow widget for users of your website to click. The widget includes additional services like Instagram, YouTube, and others:

AddToAny is a very popular add on and a great addition to your arsenal of tools.

Posted on Leave a comment

Maximize your WordPress Efforts

Using Jetpack to “echo” your blog post to various platforms like Facebook and Twitter.

As any WordPress user, you have probably been through the routine. Create a post, share to Twitter, share to Facebook, share to a hundred sites to try to improve your traffic. I am here to tell you there is a solution. It is a service offered by WordPress themselves, it is called Jetpack.

You can find the plugin here:

Jetpack is sort of a Backend to WordPress that adds a good number of features and services that make it pretty much indispensable. It has a free tier and a paid tier. For most of my sites, I simply use the free tier and fill in the voids with other plugins.

While Social Sharing can be handled by many other plugins I have found the dead-simple integration by Jetpack to hit the mark. I have tested out other plugins only to be frustrated by a cumbersome interface or process or even outcome.

When you connect to Jetpack you will get a new icon in your post properties, it is a little green circle with two triangles:

Selecting the Jetpack icon swaps out the panel and shows the Jetpack panel. The first detail on the panel is the “Share this post.” Section. As you can see this site automatically shares four social sites that are included in the free version of Jetpack.

Once these are set, nothing else needs to be done. All your posts will be automatically shared on all these social sites. There are more available in the paid version.

The next item available is Social Previews. In the past, I played the post/delete/post again game when my post did not appear correctly on the social site. Now I have the habit of checking the preview before I post.

The preview for this post looks like this:

If you have added a post that is more narrowly targeted, you can disable sharing and only include the social sites that are appropriate for that post.

It seems that Jetpack only supports these four platforms, I had hoped for more but I’ll take what I can get.

Posted on Leave a comment

A Walk in the NextCloud – Docker Rescues NextCloud

Pi 3 on a 30 Year old Green Screen

A first look at running NextCloud in a Docker Container on a Raspberry Pi. The short answer is yes, it is simple. The qualified answer is, it is likely only useful for fun, testing, and one user.

Trying to set up a NextCloud server on a spare Raspberry PI in part of my journey away from the public cloud. An older Raspberry Pi I got stuck on the PHP 7.2 requirement. Spent more than an hour trying to upgrade and felt I wasn’t getting anywhere so I decided to turn to Docker. After all, this is what Docker excels at, package up all the dependencies that each piece of software needs.

So I hit up Docker hub to see if an image was available. Sure enough, there is and it has 500M downloads !!!!

One run command later and I am getting the image onto my aging Raspberry Pi 3 ( let’s see how it handles this. ) I had previously test openhab on this machine, which should explain the name. Eventually, I think I need to rename it to randallcloud or something more clever.

After a bit, I list the containers and boom, NextCloud is running.

It seems the Docker instance of Next Cloud took awhile to settle but after a few minutes ( Raspberry PI3 seems too slow for this. ) I can browse to the login page.

Based on the warning I thinking moving off of SQLLite will be one of the next steps.

So now I just need to add a Admin User name and password, and I think that is all.

The user is created and NextCloud moves on to install the default apps.

In a short time I am presented with a Dashboard, time to test it out!

Next I added an account to be used with my phone and I was able to login. This couldn’t have been easier.

Posted on Leave a comment

Arduino – Control a Servo

Materials

  • Arduino Uno
  • Micro-Servo
  • Hookup Wire

Coding

In order to easily code for a Servo motor, it is best to use a library. This example uses the Servo.h library from barraganstudio.com

The code below is from the example, but with the pin changed and the comments removed.

/* Sweep
by BARRAGAN http://barraganstudio.com
This example code is in the public domain.modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup() {
  myservo.attach(10);
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { 
    myservo.write(pos);  
    delay(15); 
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos); 
    delay(15);
  }
}

Wiring

The wiring for this example is very simple

  1. Connect +5v on the Arduino UNO to the Red wire on the Servo ( or +5v / Vcc if marked )
  2. Connect GND on the Arduino UNO to the Black wire on the Servo ( or GND if marked )
  3. Connect Pin 10 on the Arduino UNO to the remaining wire on the Servo

Posted on Leave a comment

CNCjs – Gcode Sender

The magical language that runs most 3D Printers and other CNC machines are called g-code. G-Code is a language that describes positioning and actions to be taken by many types of CNC machinery. In lower-end machines and in earlier 3d printers, the machine was unable to hold and process these instructions on its own and needed a computer to complete that work. Thus we have the G-Code sender and a modern incarnation CNCjs.

The g-code sender speaks to the CNC machine over a USB/Serial connection. It communicates motion and actions while negotiating how much data to send and when to send it.

CNCjs is a web based G-Code sender. It can run on a variety of computers including the Raspberry-Pi. This article will be installing the CNCjs onto a Linux Mint machine. It will be focused on installing the software for use from a web page and with a degree of permanance.

Try it out First

If you want to try the software out before doing a full installation you can use the AppImage. This is a self-contained bundle of all the software and dependencies needed to run the title. You can download the AppImage, use it from the list below.

Pre-paring your machine

The only listed requirement is nodejs version 4 or higher, and npm if you are not installing from git

For nodejs, you can check which versions are available on your repository by typeing

apt-cache show nodejs | grep Version

If the versions shown are greater than 4 you are good to install by typing:

sudo apt install nodejs

If you think it is already installed just type:

nodejs --version

For npm you can do the sam process

apt-cache show npm | grep Version
sudo apt install npm 
npm --version

Obtain the Software

If you would like to run the software on your desktop like a piece of regular software ( not web-based ) there is a version that treats the entire cncjs web service as a desktop App. It uses something called Electron, and is avaiable in Windows, Mac and Linux

https://github.com/cncjs/cncjs/wiki/Electron-App

Then pick the download in the “Asset” list. There are debs for Debian Linux, rpms for Redhat based, Windows exe, and Mac dmg

For the AppImage you can use the linux-x86_64.AppImage

For running on a server:

The easiest way to install this software is via npm

Use the following command

npm install -gcncjs@latest

The comand will retrieve the software and isntall it

To run the software use:

cnc

Then visit

http://127.0.0.1:8000/

It’s that simple!

Posted on Leave a comment

Add Closed Caption to Videos – Part Two

The Bottleneck – Transcription File to Captioning file

After processing through the Watson – Amara approach It became clear that there is a piece missing. Watson does a decent job of creating a transcript. It even has something it calls a “Timing File”. Unfortunately, from the demo page, it is not possible to easily save either this file or the JSON file that is also available. I am presuming this is due to the fact that the Watson Speach-To-Text is a paid service and I am using a demo. So I will have to try to full-fledged service.

Trying out Watson Speach-to-Text API

The biggest question is “Can the Watson speech API output a Caption file format?” I went over to Wikipedia for some background and a list of the different formats.

A short simple introduction can be found here: https://en.wikipedia.org/wiki/Timed_text

A more in-depth article on Subtitles can be found here: https://en.wikipedia.org/wiki/Timed_text

What I was looking for, a chart of the formats is here:

https://en.wikipedia.org/wiki/Subtitles#Subtitle_formats

From the Amara.com upload dialog the accepted formats are:

Our site accepts SRT, SSA, SBV, DFXP, TXT, and VTT format. Only files ending in .srt, .ssa, .sbv, .dfxp, .txt, .vtt or .xml (for dfxp) are accepted.

Attempt 1 – Github, SubtitleMe

I did what all of us do, I googled “Watson Speach API convert to subtitles.” Some of the first entries returned where GitHub entries so I tired the first.

It is a program called “SubtitleMe” its claim is that it will use the Watson Speach API to create a subtitle file. Here is my first attempt:

This certainly could be user failure, but I definitely want the easiest solution. I will try the second Github entry.

Attempt 2 – Github, Subtitler

So, it turns out that, Subtitler is a fork of the first one, but it did seem to get a little further. I fed it a one minute file. After more than a minute of streaming the file, I was getting no results. I set that window aside and moved on to the next approach.

Attempt 3 – Using IBM-Watson Nodes for Node-RED

In the next article, I will be going through how I used Node-RED to query IBM Watson’s Speech-to-Text API. For now, here is a screenshot: