Pi cheat-sheet (LxTerminal)

For stand-alone microprocessors

Pi cheat-sheet (LxTerminal)

Postby Doug Coulter » Thu Mar 05, 2015 10:01 pm

While this is a rather lame beginning, I like to keep cheat-sheets for obscure things I've done to make linux (or whatever else) work just the way I want. Usually there is a lot of googling to find what actually works, then a one-liner. The trouble is, next time you have to do that - you remember the stuff you saw in hours of googling, and not the one line that worked. I figured I'd start keeping that kind of stuff up here so others can use it too.

Today's trick: I just put Ada's 800x480 touchscreen on a pi-2, and the terminal shows much too large once I increased the default font (in the terminal settings) large enough to read (and that, with reading glasses). Since I plan to use this a lot with just the touch screen, I wanted the tic-tac-toe buttons and so on to always be reachable, and to do that, I wanted to reduce the default size of the terminal to about 70x19.
(and BTW, there are bugs in their .pdf file on how to make it work, and I'll post the fixes later on this thread)

Well, there's a command line option for that... it goes kinda like this: $lxterminal --geometry=70x19
Easy, but what about the shortcut in the taskbar? Yes, if you put one on the desktop, you can edit the Exed= line and add this, but I wanted the taskbar one to work like that too.
To make things extra confusing, there's a hidden config file under home/pi/.config/lxterminal/lxterminal.conf - which does absolutely nothing I can discover. That's what makes this a worthy tip.

The one that matters is at /usr/share/applications/lxterminal.desktop - and it's owned by root. Fix it there and it's fixed all over. Gheesh.

I'll have a lot more to add to this thread (and anyone else chime in here if you've got a good one) later on. Ada's pdf on how to make this display work has typos, and they are different typos from the online one...neither work, and I'll get to that soon, because I did figure it out.

I have NGINX, MySQL, PhpMyAdmin and some interesting pi-camera stuff going now. Those all didn't quite work out easily, so there will be tips for those. NGINX blows apache off totally - but needs all kinds of different configuration than apache (one of the reasons it's better, actually) to make things like phpmyadmin work with it, and so on. The cool camera live streaming thing I have going on apache, I still have to get working with NGINX, which will be yet another post.

For those who don't know - the pi-2 is a quad core and TONS faster than the old raspberry pi. It'll even run iceweasel (firefox by another name) instead of the crap browser the old one would barely run...and so on. It's about eqivalent to a modern haswell i3. The old one? Well, it runs. That's about what you can say for it. Streaming 320x240 video out of it took 100% cpu....It couldn't play music over USB dongles without dropouts on every single buffer....and so on. The new one, now this is a real computer...

I'll try to put what the tip is about in this thread in the title...so we can find stuff quicker. You can change the title in each post on a thread...
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Pi cheat-sheet (synaptic)

Postby Doug Coulter » Thu Mar 05, 2015 10:32 pm

When I'm first building a new pi image, I usually have some work to do - raspian comes with a bunch of "kid stuff" and I'm not a kid. I get rid of the games, mathematica (really, on a pi?) and add a bunch of the stuff I really use.
First step is to say:$sudo apt-get install synaptic (note, when I'm telling you what to put on a command line, I use the $ to indicate whatever your prompt is, you don't type that, it's already there, usually with your username etc before it).
Once you have that, which is really just a gui over apt-get - things are a lot easier, since it can search for you.
I remove scratch, wolfram, sonic-pi, minecraft, python-games (that one, you can just delete the folder), and anything else useless (for me). Not a gamer, I play in real life.
I often then add:
cpanminus (called cpanm at the terminal later) which lets you use the original perl names to install perl modules from the terminal. I often get a few of these, like DBI, Device::SerialPort, Time::HiRes - it can be a long list, and cpanm makes that really easy.
Gnuplot - yup, all my data aq and analysis stuff will run here if you get the right things, so GnuplotIF also (the perl module that can drive it).
MySQL (and various addons to taste)
NGINX - is far more useful than apache for the resources a Pi has - that's why the really big boys (google, facebook etc) use it - it's fast and light.
PhpMyAdmin (there will be a separate post on making that work with NGINX, as well as one on NGINX config for a pi).
|Iceweasel - the midori web browser that comes with a pi is a joke, and unstable on top. This is Firefox...and with a pi-2, it'll go fast enough to be useful. I usually get some add-ons for that as well (movie player plugins and so on).
Scrot - the pi doesn't have a built-in screen saver...so you get one to catch nice screens for posting here and elsewhere.
The Gimp...any linux head knows this one.
locate - this is a linux utility that finds things for you. You use updatedb (have to be root/sudo) and it makes an index of all your stuff - it's a lot easier to use than "find" and just plain works better. If you've got a lot of external stuff mounted it can take awhile to build the database...but it's still worth it (I usually have around 120gb of share from my WAP mounted, for example, but again - that's just the stuff I often need fo locate...).

Various other things as they come to mind. By removing the absolute crap, you wind up about even in used storage and have the good stuff instead. I'v already mentioned elsewhere that you can setup a USB stick with a few partitions and mount it automatically from /etc/fstab, but I'll do a tutorial on that. Turns out a USB3 stick is faster than the fastest SD card (even though the pi only uses USB2) for a lot of things, and it's easier to back up later, and replace once you wear it out writing on it. This way, your harder to deal with system image on the SD card stays simple and read-mostly, and you only have to back it up once in awhile - it's only got downloadable stuff on it, not your personal things that you'd have to re-create.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Pi cheat-sheet (add sceenshot to taskbar)

Postby Doug Coulter » Fri Mar 06, 2015 7:03 pm

Adding things to the menu and taskbar

If a program is already in the main menu, adding it to the taskbar can be done various ways, fairly simply. First, try showing it in the main menu, then right clicking it - often "add to taskbar" will show up. But what if you have something that didn't have the install for an icon and menu entry that *really* wants a taskbar entry?

Here, I'm thinking of scrot, a screen capture utility that is, as installed, command-line only. Do I really want a screen shot of my typing in of the screen capture command?
To be fair, scrot does allow for a delay so you can hide that before the shot is taken..but it's a pain. Set the delay long, and it's wearisome, set it short and you've got to move fast. Lose-lose.

I started with this link: http://wiki.lxde.org/en/Main_Menu
which gives some of the info on how to do this, though if you look at most of the system-supplied .desktop files, you'll find a lot of other things in them, often translations to many languages. I'm not going to do that here, as I speak US English (sorta).

Obviously, to show an icon, you need to have one. By looking for the name of a relatively rare app I have installed that works correctly, I found a whole directory of tons of icons, most of which aren't in use and probably will never be - who's going to run virtual-box on a Pi, for example? Or use this tiny thing to capture raw many-megapixel camera data? Fair game to use icons no one else is using, and saves you the trouble of making your own.
Here's where to look: /usr/share/app-install/icons
(there are probably other spots as well)
I'm going to use this one: /usr/share/app-install/icons/gtkam-camera.png

The SD card in my camera is bigger than most in Pi's, I won't be using them to store what they can't hold anyway. That said - I can get pix from my camera and put them on my big wifi share, then post them from the pi, like this:
AnotherMessyDesk.JPG
Yes, we are setup for maximum fun here. Pi's, cameras, kludge boards, big USB sticks....touchscreens...


Well, it turns out some of the info at the links above is just plain wrong. The menuing system has changed,, and following the directions on the *official LXDE site* doesn't work! Hence the value of this series of posts - this works.
Install the program, in this case, scrot (I used synaptic).
Make the .desktop file. Here is mine for this case:
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Exec=scrot
Icon=/usr/share/app-install/icons/gtkam-camera.png
Type=Application
Terminal=false
Name=scrot
GenericName=Screenshot
StartupNotify=false
Categories=Accessories

I was too lazy to make my own icon, and found a bunch of unused ones at the directory shown in the scrot.desktop file above, which I put where the LXDE site said (both places, actually, while I was thrashing round trying to make their way work). Then I tried their commands for adding it to the menu. No go, no matter what I used for categories...it did show up as an "Other" which the new LXDE won't display anymore (maybe good, it tended to be very cluttered and have absolutely everything in it). What do do? Ah, totally unmentioned in all the dox is where the taskbar setup file is, and its syntax, though it's fairly easy to guess given an example (thank heavens, as there appears to be zero documentation out there).
Here's my copy after editing:
Code: Select all
# lxpanel <profile> config file. Manually editing is not recommended.
# Use preference dialog in lxpanel to adjust config when you can.

Global {
  edge=bottom
  allign=left
  margin=0
  widthtype=percent
  width=100
  height=36
  transparent=0
  tintcolor=#ffffff
  alpha=0
  autohide=1
  heightwhenhidden=2
  setdocktype=1
  setpartialstrut=1
  usefontcolor=0
  fontsize=12
  fontcolor=#b25d5d
  usefontsize=1
  background=0
  backgroundfile=/usr/share/lxpanel/images/background.png
  iconsize=36
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=menu
  Config {
    name=Menu
    image=/usr/share/raspberrypi-artwork/raspitr.png
    system {
    }
    separator {
    }
    item {
      name=Run...
      image=gnome-run
      command=run
    }
    separator {
    }
    item {
      name=Shutdown...
      image=gnome-logout
      command=logout
    }
  }
}
Plugin {
  type=space
  Config {
    Size=8
  }
}
Plugin {
  type=launchbar
  Config {
    Button {
      id=/usr/share/applications/iceweasel.desktop
    }
    Button {
      id=/usr/share/applications/pcmanfm.desktop
    }
    Button {
      id=/usr/share/applications/lxterminal.desktop
    }
    Button {
      id=/usr/share/applications/arduino.desktop
    }
    Button {
      id=/usr/share/applications/gedit.desktop
    }
    Button {
      id=/usr/share/raspi-ui-overrides/applications/galculator.desktop
    }
    Button {
      id=/usr/share/applications/geany.desktop
    }
    Button {
      id=/usr/share/applications/ghex.desktop
    }
    Button {
     id=/usr/share/applications/scrot.desktop
   }
  }
}
Plugin {
  type=space
  Config {
    Size=8
  }
}
Plugin {
  type=taskbar
  expand=1
  Config {
    tooltips=1
    IconsOnly=0
    ShowAllDesks=0
    UseMouseWheel=1
    UseUrgencyHint=1
    FlatButton=0
    MaxTaskWidth=200
    spacing=1
    GroupedTasks=0
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=tray
  Config {
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=cpu
  Config {
    ShowPercent=1
  }
}
Plugin {
  type=dclock
  Config {
    ClockFmt=%R
    TooltipFmt=%A %x
    BoldFont=0
    IconOnly=0
    CenterText=0
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}


The part I added is in color. (well, I tried, the board sofware evidently doesn't color things inside code tags. Here is is outsite them:
Button {
id=/usr/share/applications/scrot.desktop
}

Obviously, the other stuff had to be done for this to be able to point to it. the filepath is:
/home/pi/.config/lxpanel/LXDE-pi/panels/panel (no kidding, and thet period in the front of the .config means it's hidden and you have to use ctrl-h in the file browser to even see it or anything under it). Of course, most apps do all this and more - just in case, due to the changing standards and shall I call it bloat? typical of all modern opsys - we leave some old junk in there just in case someone has an older version for backward incompatability just in case.

Two for the price of one - the above pic but shown on the pi screen via this mechanism at work:
2015-03-06-184331_1600x1200_scrot.png
Heh, take a picture of yourself...


This post was generated on the pi-2 using iceweasel, gimp, scrot, gedit...all the usual suspects. A little slower than my super-machines, but not enough to make me get up and do it over there.
The sharp eyed will notice some wratten IR pass filters in the picture, so we can have more fun with that NOIR filter camera...
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Pi cheat-sheet (extended storage and wireless)

Postby Doug Coulter » Fri Mar 06, 2015 7:27 pm

Wireless was a snap - just follow the directions after plugging in your dongle. My WAP has a share on it, which I mount later in fstab (where linux keeps track of how to map available storage onto the directory structure at boot time).

The other thing of interest here, is that I've added a 64 gb (well, nominal, you know how they lie) USB stick, partitioned into two chunks, and mounted then over /home and over /var.
Those are the two most written-on places in a normal linux box that is running things like webservers, development stuff, and basic regular usage.

In this case, what I did first was make a directory under /home/pi called /home/pi/amped to have something to mount the share over. The basic install already has a /var and a /home.
But the tricky part is that once you mount something over a dir, what might have been "underneath" in the first place is now invisible. So before I could mount the nice new USB stick, I had to put the existing content of /home and /var on the two partitions, so they'd not be lost (well, hidden as long as the stick was there, kind of giving one a chicken-egg situation for copying them). You have to do this and then edit fstab with no intervening writing if you don't want to lose anything, it's usually best to do this right after the initial opsys install.
Only then could I mount the USB stick (from /etc/fstab), and then the wireless share, since it's under home and would have been hidden itself, thus the order of things in the fstab file shown here. I note the pi is more or less loafing, with this browser (iceweasel), gparted (to show the USB partitions), task manager (actually a cycle hog), wpa_gui to set up the wireless, a terminal, gedit (to show fstab) and a file browser...could be worse.

Here's what it all looks like. Don't hesitate to ask for more detail if you need it. The object of all this is to avoid ruining the SD card we boot from - they are fragile when written too often. Not that USB sticks are super-robust, but without the requirements for special UEFI boots and special partitions, they're a lot easier to backup and restore if/when they go bad.
2015-03-06-191725_1600x1200_scrot.png
Screen shot of a really expanded pi...it's also running NGINX and MySQL among other things...


In case someone sharp-eyed notices and questions why I used ext2 as the USB file system - it writes less - not being a journaling file system. The "noatime" also writes less, since it doesn't keep track of the last time a file was read by WRITING on something so as to remember that. Duh. Someday we'll have a flash-friendly file system that works - they've been saying we have for a couple years now, but then say "oops, not yet".
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Embedded software

Who is online

Users browsing this forum: No registered users and 2 guests

cron