Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, April 17, 2021

Linux print nth line of file

I have to google this all the time. I guess that the following article answered it for me back in Nov 2020. The answer includes piping the output of head into tail, using sed, or using awk.
https://linuxhandbook.com/display-specific-lines/
Honestly, the unrelated hits from searching for this are fascinating in their own right:
https://www.bing.com/search?q=linux+print+nth+line+of+file

Friday, December 27, 2019

Trim characters from the end of all directory names in a folder

On my windows system, I had a folder with only other folders in it, and all of them had three characters on the ends of their names that I wanted to delete. I started up a Cygwin Bash shell to do the job.

I first attempted to use 'find' to create a one line command to rename all of these folders, but it turns out bash for and do were the answer, thusly:
for file in *; do mv "$file" "${file%???}"; done

The syntax for doing the trimming came from this thread (although sadly the pythonesqe method of trimming with colons and a negative end position didn't work in cygwin bash for some reason): https://stackoverflow.com/questions/19530429/rename-file-by-removing-last-n-characters
The example of using for/do came from here: https://stackoverflow.com/questions/7450818/rename-all-files-in-directory-from-filename-h-to-filename-half

Friday, April 12, 2019

Add folder name to file name linux

I had a bunch of misnamed files throughout a directory tree that I had to fix the names of to have a common prefix with the name of their folder appended. Actually it was the name of a folder two levels up.

Theoretically a single-line 'find' command with the right -exec should be possible. However, encapsulating an awk script within a mv command hanging off of find, even with xargs proved to be too tricky, and I ended up just creating an echo statement with the mv commands and then taking the echoed output and putting it into a shell script.

Here is the final find-xargs-awk command line which generated the stdout that I pasted into my shell script. In this case, the original files are in ./$TL/$SL/ and $TL is a date code and I wanted to find the oldfile which had the wrong date code on the front and rename it to a new file prefix with the desired datecode on the end:
find . -name "*oldfile.csv" | xargs -I '{}' echo {} | awk -F'/' '{SL = NF-1; TL = NF-2; print "mv " $FILENAME "./" $TL "/" $SL "/newfile_" $TL ".csv"}'

Here are some relevant links turned up during researching this:

Here's a super simple example of using find to rename files. The commenter here likes xargs too much when it's unnecessary: https://unix.stackexchange.com/questions/227662/how-to-rename-multiple-files-using-find
I tried using SED to split up the directory path but it's way too hard to get it to treat slashes as delimiters, plus the result keeps the delimiter for some reason: https://stackoverflow.com/questions/16643288/sed-to-extract-text-between-two-strings
Still trying to get sed to work, here is a nice comparison of the same task with parentheses in different languages: https://unix.stackexchange.com/questions/108250/print-the-string-between-two-parentheses
Here is an example that is a lot of what I needed with my two directory levels, but aside from generally reminding me how to use awk I didn't end up stealing a lot of this: https://unix.stackexchange.com/questions/277231/how-to-get-second-directory-name-in-the-perforce-file-path
Here is the example that I stole most of my awk code from. It has several great examples, including using a for loop (which turned out to be largely unnecessary for me) and the kint of using the built-in swk variable FILENAME. https://unix.stackexchange.com/questions/134212/extract-file-name-from-path-in-awk-program
Here is where I got the other part of my awk code using the NF built in variable. The example is in a for loop but I was able to do the same thing with find and xargs: https://stackoverflow.com/questions/643372/append-name-of-parent-folders-and-subfolders-to-the-names-of-the-multiple-files
Here is an example of a super fancy xargs command with find: https://stackoverflow.com/questions/10972002/batch-renaming-files-in-command-line-and-xargs
Here is an example where somebody was just not doing xargs correctly, and the answers eventually converge on just using the -exec feature of find: https://unix.stackexchange.com/questions/90886/how-can-i-find-files-and-then-use-xargs-to-move-them
Here is another example of a for loop for somebody that is trying to do something remarkably similar to what I want to do, but these examples weren't actually very helpful: https://superuser.com/questions/516082/add-folder-name-to-beginning-of-filename



Friday, April 5, 2019

Copy files using find, dirname

I wanted to find files that existed in several but not all branches of a directory tree and make a copy of each file within its directory to a new (constant) filename.

The key was in using the magical -execdir option to find rather than just -exec.

Info on dirname and basename: https://stackoverflow.com/questions/2536046/extract-directory-path-and-filename

This StackExchange answer provided the key information which is that dirname wasn't going to help me because it is evaluated before find! Also the backwards quotes for using the evaluation of a command inside a command line. https://unix.stackexchange.com/questions/339880/cp-not-evaluating-dirname-properly-in-find-operation?rq=1

Here are some harder ways to do it with xargs: https://stackoverflow.com/questions/17368872/how-to-move-or-copy-files-listed-by-find-command-in-unix

My final command line:
find . -name "Prefix*.txt" -execdir cp -p `basename {}` newfilename.txt \;

Wednesday, March 20, 2019

Find files, list contents with line length maxium

I needed to parse a directory tree and list all the files of a particular type, list the directory name, print the first few lines of each file, with long line lengths trimmed. I also wanted to only get the particular types of lines out of that initial listing, which are ones with the date in the first few characters.

Here is my massive final command:
find . -name "*.csv" -exec echo {} \; -exec head -n 21 {} \; | cut -c -70 | grep 2018 | grep -v DATE | grep -v UTEND

The beautiful parts of this were: 1) two -exec functions for my find command. Yep you can do that. 2) The cut command 3) a chain of greps to get the date and cut out other lines that had the date that I didn't want.

Saturday, November 17, 2018

PCMANFM deleting bookmarks

I accidently hit the eject symbol for the MicroSD card on a file browser in Raspbian. To my surprise, the system continued to function, contrary to what I'd read elsewhere. I think that what happened was not an ejection of the OS but it deleted a link which opens the browser to the OS top level. After some frantic searches, I was reminded that this browser is called PCMANFM and learned that the links in the side panel are "bookmarks". The following article provide enough info for me to manually reestablish the bookmark. It seems like the browser app remembers changes to the list of bookmarks even through restarts. Here is the article that helped me get a handle on what was going on: https://www.raspberrypi.org/forums/viewtopic.php?t=107216

Monday, November 12, 2018

Using SCP under Putty-CAC with PIV

Our Linux host is now PIV login only, so I have to use PuTTY-CAC to access it. The default procedure that I was handed was to also install WinSCP and use that with Pageant selected as a session handler once PuTTY-CAC was set up, but I didn't have an option to install WinSCP. Starting a PuTTY-CAC session with PIV causes Pageant to be started in the background. Theoretically I should be able to use that Pagent session to run pscp.exe but it didn't work the way that I expected.

Here's how to run and install PuTTY-CAC as required by our security policy: https://piv.idmanagement.gov/engineering/ssh/


Here's one of many identical readouts of the pscp man page. Pscp can normally just be run from a CMD window. Way down at the bottom of thie man page it has suggestions for linking up pscp with Pageant. Pscp didn't automatically authenticate using Pageant as advertised, and the -agent argument seemed to have no effect. The one which worked was using a saved PuTTY session name in place of the host. The example was confusing because it showed a download from a remote host, which I hadn't realized was a thing, but just substituting the session name for the upload host name worked just fine. ftp://ftp.fu-berlin.de/pc/network/putty/putty-0.56/htmldoc/Chapter5.html
Also here: http://www.straightrunning.com/puttymanual/Chapter5.html



Here's what my command line looked like with all the paths to things hard coded:
"C:\Program Files\PuTTY\pscp.exe" -r directory host-piv:/home/user

Thursday, February 2, 2017

Raspberry Pi Thumb Drive Not Mounting

After reassembling our Raspberry Pi 3 system, thumb drives plugged into the USB port are recognized and the dialog box appears that asks if you want to open it in a file browser, but when the browser window opens it fails with a dialog box that says "The specified directory /media/pi/[name of drive] is not valid." The troubling thing is that it used to work fine before.

The answer, after trying dozens of approaches, turned out to be that the permissions on the /media/pi directory weren't set right. Finding this answer was made tricky because I was comparing the directory permissions to those on another pi that didn't have the problem, and the directory permissions matched. I learned however that the other system had an Access Control List set on the directory that gave additional permissions to the pi user. Setting up the original pi to have an access control list to match the working one fixed the problem of the thumb drive not being mounted correctly when plugged in, but then for some reason whenever an eject was done from the file browser the eject widget on the task bar would show an error that the drive had been removed without being ejected. That problem was fixed by updating the lxpanel package on the old pi; it turns out that the eject widget is part of the lxpanel and not a stand-alone app.

Troubleshooting notes taken during the course of figuring all this out follow:

This result from googling the error message is somebody who eventually figured out that his system was missing usbmount. I could try installing usbmount, but it doesn't seem like this would be my problem because USB drives used to mount on my system (unless something somehow got messed up when I cloned the SD card): http://unix.stackexchange.com/questions/325962/the-specified-directory-media-fa-faf9-c03-is-not-valid-error-when-trying-to

By following these instructions, I am able to mount the drive into a new location, access it, and unmount it. I found that the strange serial number in the error message appeared in the list of devices by id, and that a /dev/sda1 device had been created, so all of the assumptions in these instructions about what I would find were true: http://www.raspberrypi-spy.co.uk/2014/05/how-to-mount-a-usb-flash-disk-on-the-raspberry-pi/

Here's another set of instructions on mounting a thumb drive that look good but I haven't really looked at them yet because the first one worked so well: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=35695

Another tutorial about USB drive mounting. Doesn't cover the automounter but has an amazing assortment of tips and tricks that I haven't seen elsewhere:

https://pimylifeup.com/raspberry-pi-mount-usb-drive/


Trying to enable the wifi:

"It should just work" meaning there's a graphical tool from the menu bar (which I can't find): https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=138137

Gorgeous step by step instructions on enabling the wifi from the command line, which worked right up to the point of configuring the wifi password in a plain text file. The problem is that our guest network requires authentication via a web page with a form. But I was able to scan for local networks at least using these steps:

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md


http://www.makeuseof.com/tag/setup-wi-fi-bluetooth-raspberry-pi-3/

So trying to login this type of network is basically impossible in Pi: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=152447

The problem is so bad that all of the serious suggestions on this page are ridiculous: raspberrypi.stackexchange.com/questions/34008/connect-to-public-wifi-hotspot

Here's somebody who actually finds an answer, but later on somebody points out that I can just use the portable hot spot from my phone: unix.stackexchange.com/questions/118289/how-do-i-authenticate-to-a-wireless-providers-open-network-without-using-a-br

Just turning on the hotspot on my phone, the hotspot wasn't found when scanning. This set of instructions involves tethering the phone to the Pi over USB before making the connection to the hotspot. Why? I don't know! But it didn't work; the Pi never found the phone, possibly due to whatever problem is occuring with the USB in the first place.

http://www.daveconroy.com/how-to-tether-your-raspberry-pi-with-your-iphone-5/

Returning to working on why automount is failing, looking in the message logs, there are strange error messages such as: "error opening /media/pi/9005-048F/BDMV/index.bdmv"

Somebody reports that these are file types for blu-ray disks? https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=154836

This thread's resolution seems to suggest that it's a power starvation issue (if so this is bad news for my system): https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=124532

About the 'action 17' errors also seen in the log (apparently unrelated stuff):
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=155803
https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=152405


So, I downloaded usbmount, and a thumb drive is now mounted and opens in file browser when plugged in.

But it can't be ejected without a dialog asking for the password for the user account (there isn't one, which means that this dialog can't be answered! A couple of search results for the dialog came up with suggestions to change some policy settings:

askubuntu.com/questions/552503/stop-asking-for-authentication-to-mount-usb-stick

Now the eject buttons for the drive in the file browser seem to unmount the drive, but a message appears from tbe eject app saying that the drive was removed wirhout being ejected.

(along the way, found this interesting thread about somebody having problems booting from a usb hd, solved by adding a config parameter for a wait before first access to an external drive:

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=109589 )



Things that are different between the working and nonworking images:

File permissions for working system:

/media: drwxr-xr-x root:root
/media/pi: drwxr-x---+ root:root
/media/pi/SETTINGS: drwxr-xr-x root:root

File permissions for the nonworking system:

/media drwxr-xr-x root:root
/media/pi: drwxr-x--- root:root
ls /media/pi: Permission Denied

The SETTINGS directory is apparently the NOOBS config files.

http://raspberrypi.stackexchange.com/questions/60609/settings-drive-accidentally-renamed/60683

Looking at all files under /etc, SETTINGS is mentioned in the mtab file, which is the list of all presently mounted file systems.

the (+) on the file permissions for the working system means that it's an access control list?

https://ubuntuforums.org/showthread.php?t=2206434
https://wiki.archlinux.org/index.php/Access_Control_Lists

Again, in the following example /media/pi has a (+). His drive doesn't automount though and he never gets an answer to his question

https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=135178B

Results from getfacl /media/pi in the working system:

#file: media/pi
#owner: root
#group: root
user::rwx
user:pi:r-x
group::--
mask::r-x
other:---

Added an ACL to /media/pi using the example in this page (this page is filled with extremely easy-to-follow instructions BTW):

http://www.htpcguides.com/properly-mount-usb-storage-raspberry-pi/

Now I can access /media/pi as user pi, and when I plug the thumb drive in, it comes up in the browser without error!!! Also, the drive is not greyed out in the eject widget!!!

But there's still something not right that works using the new NOOBS configuration! When I eject it using the eject button in the browser, the eject widget still says "...was removed without ejecting Please use menu to eject before removal" This does not happen in the working system.

Apparently the button in the file manager is separate from the button in the eject widget. There are many, many posts online from people who have problems using the button in the file manager but they are almost all people who don't have the "eject" package installed. I triple checked and it is installed on both of my systems.

Here's are some of those people who simply had to run sudo apt-get install eject. How jealous these links make me!
http://raspberrypi.stackexchange.com/questions/14843/how-to-eject-usb-device-on-raspberry-pi-not-just-unmount
http://kj-til.blogspot.com/2013/11/eject-usb-drive-error-and-fix.html
https://www.raspberrypi.org/forums/viewtopic.php?t=18364

Here's a guy who wants to have the eject buttons in the file browser be removed or disabled. It seems like this would be pertinent to helping me find out how to change their behavior, but sadly nobody answers this forum question! Also this would be pertinent because the file browser is including eject buttons for the main SD card which makes no sense and probably would be bad if somebody hits them: http://askubuntu.com/questions/862592/remove-or-disable-eject-button-in-files-file-manager-for-second-internal-hdd

I did a bunch of googling of how to configure the file browser.

I learned that it's called "File Manager" and it has a menu option for "Preferences" which has settings for how to respond to a USB volume being plugged in!!!!! Strangely there doesn't seem to be settings in preferences for how to respond to requesting and eject? I don't understand why that wouldn't be there. However, I discovered that the File Manager program has a name; it's named PCManFM. Amazingly it was developed in Taiwan, released under GNU public license, and is the default file browser in LDXE which Raspbian is a flavor of.

This wiki article on pcmanfm goes out of its way to mention that pcmanfm handles thumb drives (the keyword is "volumes") but does not point to any specifics about how it is configured. Also the original page seems to have been hacked so this link is to an archived version: https://webcache.googleusercontent.com/search?q=cache:2Sk4YDcqHgEJ:https://wiki.lxde.org/en/PCManFM+&cd=2&hl=en&ct=clnk&gl=us

Here is an overview of what pcmanfm is, with a hint that it handles automounting but it doesn't say anything here about unmounting. It mentions that there is a daemon mode for detecting new removable media, and specifically mentions my USB automounting problem with a link to a different article: https://wiki.archlinux.org/index.php/PCManFM

The link from the pcmanfm link about USB drive authorization problems. This actually is about the policy settings that were discussed in a different answer that I found during my disastrous experiment with installing usbmount; this wiki page is for something called "polkit" which seems to be a tool for modifying the policies that I was manually editing to get usbmount to allow an unmount without a password: https://wiki.archlinux.org/index.php/Polkit#Mounting_storage_without_password

This github README mentions that Volume management is done with glib, which relies on gvfs. Also that there is an --enable-udisks configure option, but doesn't go into detail about how those are setup.https://github.com/lxde/libfm

This blog post from a pcmanfm developer in 2010 gives the hint that the configuration file is named libfm.conf, and there are also relevant configuration parameters in ~/.config/libfm/libfm.conf. Worryingly, a commenter asks downthread if there will be an "unmount safely option," so maybe one didn't get implemented in 2010? https://webcache.googleusercontent.com/search?q=cache:5ufMWNwOmn0J:https://blog.lxde.org/2010/07/04/direct-udisks-support-for-libfm-and-pcmanfm-is-finished/+&cd=2&hl=en&ct=clnk&gl=us

Searching my working unit, I find a virtual pile of applicable .conf files under /etc! These are not necessarily in the locations hinted at by the 2010 blog post, so some tweaking has apparently occured
/etc/xdg/libfm/libfm.conf
/etc/xdg/pcmanfm/default/pcmanfm.conf
/etc/xdg/pcmanfm/LDXE/pcmanfm.conf
/etc/xdg/pcmanfm/LDXE-pi/pcmanfm.conf

Of those, libfm.conf doesn't have anything particularly interesting except for a flag for "use_trash" which means that if I ever need to turn that on or off I now know where to do it. The contents of the other three .conf files vary with respect to each other, with the default and LDXE-pi pcmanfm.conf containing three scant configuration lines in a [volume] block of parameters, none of which seem to include anything about unmounting or what code gets run for mounting! The LDXE pcmanfm.conf oddly doesn't contain a [volume] section. All three have parameters different from each other that seem mostly to do with the look and feel.

This git repository lists the --enable-udisks option as a parameter for building it (sad) but says that it is defaulted to yes (happy)!!! https://github.com/raspberrypi/libfm-1.2.3/blob/master/configure

This man page for udisks indicates that detach and eject are both options, with parameters that are not listed in this page: https://udisks.freedesktop.org/docs/1.0.5/udisks.1.html

This github code indicates that there is a utility named udisks-eject; perhaps this is what is called by pcmanfm on my working system (Update, it's unlikely). If so I wonder how to find the option that specifies it? https://github.com/patrikf/udisks-eject/blob/master/udisks-eject

Unrelatedly, here is an interesting developer's discussion on what context menus to put on the eject options for Nautilus, a similar file browser to pcmanfm. They're talking about the same thing so there's probably interesting stuff to learn here, but it's mostly argument about GUI philosophies.https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/28835

Having learned all that, I keep finding hints that the configuration for pcmanfm is in .desktop files, which I don't know much about but have to learn now I guess.

This guy researched how to customize the pcmanfm option. This is getting soooo close! He's trying to set it up to use udisksctl which I've also seen in other links. He is advised to put something in ~/.local/share/file-manager/actions/umount.desktop http://askubuntu.com/questions/633027/eject-usb-drive-action-for-pcmanfm

Sadly, I don't seem to have ~/.local/share/file-manager/actions/umount.desktop. Actually my ~/.local/share directory doesn't have a file-manager directory, just applications, desktop-directories, gvfs-metadata, and Trash, none of which even contain anything interesting.

This page, which I actually found a while ago, mentions config files in ~/.config! It mentions a .config/pcmanfm directory, which I have! I have a LXDE-pi directory instead of the lubuntu directory mentioned in the post but that all makes sense! And there's pcmanfm.conf! Its contents are a little different from the one in /etc/xdg/pcmanfm/LXDE-pi though. There's some wind size, then interestingly the local one has a parameter close_on_unmount=1! This parameter isn't in any of the three pcmanfm.conf files under /etc/xdg. I wonder where it came from? https://ubuntuforums.org/showthread.php?t=2214272

OMG this link referred to from the previous link has so much relevant information! https://ubuntuforums.org/showthread.php?t=2214389&p=12973843#post12973843

But wait! This post under the pi forums has somebody adding a behavior to pcmanfm by creating a ~/.local/share/file-manager/actions out of thin air and then putting stuff into it. Well, since my working system doesn't have a ~/.local/share/file-manager directory, I know that this can't be how it is doing it, but this still seems like a really potentially useful trick: https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=146711

This is all very well and good, but I checked /var/log/syslog on both the working and now-only-slightly-not-working system and they show nearly identical log messages when a drive is ejected from pcmanfm. Both systems have the following messages from udisksd:
udisksd[task number]: Cleaning up mount point /media/pi/ (device 8:1 is not mounted)
udisksd[task number]: Unmounted /dev/sda1 on behalf of uid 1000

Also, that is the message on both systems whether the drive is ejected from pcmanfm or the ejector widget.

So, perhaps the problem that's causing the ejector desktop widget to throw an error message when a drive is ejected from pcmanfm isn't in pcmanfm after all, but in the ejector widget instead.

Could this problem be solvable by adjusting the ejector's configuration? The first step is to find the ascii config files that govern the configuration.

This page doesn't talk about the configuration files, it's about an exercise in setting up the configuration of a generic LXDE desktop to look like the Raspbian desktop, but it's delightfully geeky. www.zdnet.com/article/how-to-customise-your-linux-desktop-lxde/

This page however does go into great specifics on where to find the setup files under /etc/xdg/lxsession/LXDE-pi and ~/.config/lxsession/LXDE-pi.www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/

Interestingly, the actual setup seems to be under ~/.config/lxpanel/LXDE-pi/panels. The file which establishes the ejector is ~/.config/lxpanel/LXDE-pi/panels/panel, and at the end there is just a section as follows:

Plugin {
type=ejecter
Config {
}
}

So, on the working system at least, the Config for "ejecter" is empty. It is interesting that it is spelled "ejecter" though. Googling for more information about it reveals github repositories for ejecter.c. This seems to indicate that, bad news, this is a compiled part of the kernel. Interestingly though the checkin notes in these repositories seem to show that the file might have been updated recently to specifically address the error messages that I'm seeing. It could be that thanks to the horrible old NOOBS that we were shipped that the problem might be just that the problem kernel is old enough not to have recent updates to ejecter.c!

https://github.com/raspberrypi/lxpanel/commits/master/plugins/ejecter

https://github.com/raspberrypi/lxpanel/blob/master/plugins/ejecter/ejecter.c

Reading through the code on the above repositories, I can see that it contains the text from the dialog messages that show up whenever something is ejected either "wrong" or "right" on my troublemaking distro. But there just don't seem to be arguments. It is an internally complicated, but seemingly stand-alone and toasterlike tool. There are calls in the code to a DEBUG routine which probably does stuff if the appropriate compile flags are set, this isn't going to help me. All I've got to pin my hopes to now is that there might be a way to upgrade the app on my crappy system with the version of the app on my good system. But how?

This thread is just some neckbeards helping a noob bang on an only slightly related problem, but lots of minor clues like ways to figure out version numbers of installed packages (debsums? dpkg's -S flag? apt-file?) and the locations of the desktop setup files: https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=148101&sid=7830622a975fc16cd8e9db8ec742aceb

Here's a github repo that shows ejecter.c being under the lxpanel app: https://github.com/raspberrypi/lxpanel/blob/master/plugins/ejecter/ejecter.c

Some background on lxpanel and its configuration files, but nothing that specifically mentions ejecter: https://wiki.lxde.org/en/LXPanel#Main_Config_File

A pretty nice introductory tutorial about lxpanel which describes how the applets work (again without specifically mentioning ejecter). It does say something to the effect of "The configuration is stored in ascii files, but it's not a good idea to muck around with them directly." Which is probably a good idea but I can't stop myself. http://pclosmag.com/html/Issues/201010/page07.html

Another description of lxpanel that mentions "volume control" with no further details like if it's built-in or separate. Maybe I have to update all of lxpanel to update ejecter? This was from a search of "lxpanel" on this site, where a search of "ejector" produced no results: https://packages.debian.org/jessie/lxpanel

Alright, now we're getting close: Here's a guy who had a problem in lubuntu running ejecter specifically, and to troubleshoot it he was able to run it from a command line! His problem was that it crashed though, and it's not clear if this was due to a bug or because you can't run it from a command line. The forum thread ends with the discovery that there is a bug report out on ejecter and it is recommended that it not be used! Not sure why there wouldn't be better google hits if this actually happened. https://forum.lxde.org/viewtopic.php?f=8&t=31726

Ok this is interesting: A guy asks if there's an app in ubuntu that will unmount USB drives, and somebody describes in perfect detail how to add ejecter as an "indicator" that can be started at login by adding a config file to ~/.config/autostart. This is the clearest implication that ejecter is a complete and stand-alone executable, and furthermore the responder also show it being downloaded using apt-get! (Note: somebody else replied with a link to a list of file browsers that can be run under ubuntu. It was inapplicable to the original question but actually still interesting): http://askubuntu.com/questions/145087/lubuntu-panel-applet-or-indicator-to-display-mounted-volumes

So now I need to ask, if ejecter is a stand-alone package that can be downloaded using apt-get, is there a way for me to update one of my copies of ejecter? Can I find out what version is running on each of my systems first?

This link has many answers! Apparently I can use sudo apt-get --only-upgrade install [package name]. Some say that just sudo apt-get install is necessary to update. The Synaptic Package Manager has a "mark for upgrade" option but it is not clear if this will upgrade a single package or the entire distro. Apparently sudo apt-cache policy [package name] will get the list of all version numbers, and then it's possible to specify a particular version number when doing sudo apt-get install!!! Someone reported that the syntax for only-upgrade is apt-get --only-upgrade true install [package]. And then there are examples of using dpkg -s to find if something is installed, complete with a gloriously terse one-liner. http://askubuntu.com/questions/44122/how-to-upgrade-a-single-package-using-apt-get

Wow! Hints for how to list available versions! There's a package called rmadison that does it, and apparently the "policy" argumement might apply to apt-cache not apt-get: http://askubuntu.com/questions/447/how-can-i-see-all-versions-of-a-package-that-are-available-in-the-archive

More of the above hints. Also the question is asked how to tell what version is installed but the answer is that unless a -v argument was coded in there's no way to tell: http://askubuntu.com/questions/428772/how-to-install-specific-version-of-some-package/428778

This link, however seems to indicate that aptitude or dpkg will work just fine to get a list of the version numbers of installed packages: http://askubuntu.com/questions/17823/how-to-list-all-installed-packages

Not directly pertinent but still very interesting, this forum thread contains a discussion of how to use the list of version numbers of installed packages to make an exact clone of an installation: http://askubuntu.com/questions/9135/how-to-backup-settings-and-list-of-installed-packages

An unrelated other example of using apt-cache policy to get version numbers: https://www.raspberrypi.org/forums/viewtopic.php?t=136412&p=907548

Based on all of the above, I was able to itereate through getting the installed versions of the lxpanel on both the old and the new pi, then update lxpanel on the old pi, and the error message from the eject plug-in no longer appears when the thumb drive is ejected from the browser!!!

On the new system:
$ lxpanel -v
lxpanel 0.7.2

$apt list --installed | grep lxpanel
lxpanel/stable.now 0.7.2-1+rpi12 armhf [installed]
lxpanel-data/stable.now 0.7.2-1+rpi12 all [installed.automatic]

$apt-cache madison lxpanel
lxpanel | 0.7.2-1+rpi12 | http://archive.raspberrypi.org/debian/ jessie/ui armhf Packages
lxpanel | 0.7.2-1 | http://mirrordirector.raspbian.org/raspian/ jessie/main armhf Packages

$apt-cache policy lxpanel
lxpanel:
Installed: 0.7.2-1+rpi12
Candidate: 0.7.2-1+rpi12
Version table:
*** 0.7.2-1+rpi12 0
500 http://archive.raspberrypi.org/debian/ jessie/ui armhf Packages
100 /var/lib/dpkg/status
0.7.2-1 0
500 http://mirrordirector.raspbian.org/raspian/ jessie/main armhf Packages

On the old system:
$ lxpanel -v
lxpanel 0.7.2

$apt-cache madison lxpanel
lxpanel | 0.7.2-1+rpi16 | http://archive.raspberrypi.org/debian/ jessie/ui armhf Packages
lxpanel | 0.7.2-1 | http://mirrordirector.raspbian.org/raspian/ jessie/main armhf Packages

$apt list --installed | grep lxpanel
lxpanel/now 0.7.2-1+rpi4 armhf [installed,upgradable to: 0.7.2-1+rpi16]
lxpanel-data/now 0.7.2-1+rpi4 all [installed,upgradable to: 0.7.2-1+rpi16]

The above results show that the old system has an older version of lxpanel (0.7.2-1+rpi4 versus 0.7.2-1+rpi12) and furthermore apt-list shows that there is an upgrade waiting (0.7.2-1+rpi16)!

Performed the upgrade using:
sudo apt-get --only-upgrade install lxpanel

checked for any signs of errors in the update, and rebooted. The system came back up, and lxpanel didn't look any different, but now I am able to insert the thumb drive, open it in a file browser, then eject it without getting any alerts from the eject widget in lxpanel. Checking the installed version using apt list --installed shows that the new version is 0.7.2-1+rpi16. Mission accomplished!

Now that that's done, here are a few links to unrelated but interesting learning that I encountered along the way:
Here's how to add a command to an lxpanel menu: https://forum.lxde.org/viewtopic.php?t=31110
Here's how to add a CD eject button (not even remotely close to what I am trying to do, but interesting) to a desktop widget:https://forum.lxde.org/viewtopic.php?f=8&t=36444
Here's another one on adding commands to an lxpanel menu: http://unix.stackexchange.com/questions/177386/how-can-i-add-applications-to-the-lxpanel-application-launch-bar-via-cli
How to write C code to build a new plugin for lxpanel! https://wiki.lxde.org/en/How_to_write_plugins_for_LXPanel:_pre-0.7_version
The wiki for lxpanel itself: https://wiki.lxde.org/en/LXPanel
Some discussions of commands for safely ejecting and unmounting a USB drive. Interesting stuff about the lsblk command and udisksctrl: http://unix.stackexchange.com/questions/178638/eject-safely-remove-vs-umount
Some man pages for the the udisks command line tool: http://manpages.ubuntu.com/manpages/trusty/en/man1/udisks.1.html
http://linuxreviews.org/man/udisks/
https://udisks.freedesktop.org/docs/1.0.5/udisks.1.html
Some C code for something called udisks-eject. Is this somebody's wet dream or actually a standard feature? https://github.com/patrikf/udisks-eject/blob/master/udisks-eject

Friday, September 30, 2016

debian set file browser default view to list

Duh, it's a setting for the browser. Find "Preferences" under "Edit" and set it there.

The link that helped me realize this simple answer. The funny part is that this forum thread is for Ubuntu: https://ubuntuforums.org/showthread.php?t=1179613

Wednesday, September 28, 2016

raspberry pi 3 switch between touchscreen and hdmi

Research into running a touch screen and an external monitor either at the same time or switchable between them.

Bottom line: With Raspian you can't run two screens at once, and can't hot-switch screens. However, it is possible to tweak configuration files such that the Pi comes up using the desired screen after a reboot, basically the same solution that I used with the Beagle Bone. The configuration files to tweak are different though.

Links:

Background: it is possible to turntbe backlight on and off live by writing a value to a particular dev file.

It's also possible for the version 1.1 screen to adjust the brightness, by writing a value between 0-511 to a slightly different dev file, with 256 being a nice default brightness:

http://raspberrypi.stackexchange.com/questions/46225/adjusting-the-brightness-of-the-official-touchscreen-display

Here is a sort of officialish FAQ about the touchscreen which repeats the statement that I've often seen that certain apps (Ok just omxplayer) can use the HDMI port while the touch screen is in use. It seems to be a lucky side-effect of the configurability of xserver somehow. Also covered in this FAQ are the mailbox system for enabling/disabling the backlight, and rotating the screen, http://forums.pimoroni.com/t/official-7-raspberry-pi-touch-screen-faq/959

Here's the google search: https://www.google.com/#q=raspberry+pi+switch+between+touchscreen+and+hdmi

This thread contains some hints about using the "tvservice" function as I've seen in other forum answers, but as I've also seen on forum threads some users have reported that trying it trashed their OS installation. The OP for this forum thread ended up just living with fully removing power from his touch screen when he wanted to use the external monitor, which would be a desperation-only solution for my application: http://raspberrypi.stackexchange.com/questions/41417/how-can-i-switch-between-a-built-in-display-and-hdmi

Here is the thread with the answer, which is to add "ignore_lcd=1" to /boot/config.txt and rebooting when wanting to use HDMI rather than the touchscreen. To go back to the LCD, remove that line. The way I did this on the BeagleBone was to have two versions of the file, and a little shell script that copies the desired one over top of the last configuration file to set up for the next reboot. Interestingly, another commenter on this thread mentions that something called PINN appears to make hot-swapping screens work as I would want. I need to investigate this further: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=147962

Here's the same answer about "ignore_lcd=1" on a forum thread where somebody who tried something slightly different in config.txt was wrong: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=121591#p846271

Here's the same information in reverse, in some of Adafruit's documentation on a github page where the process for enabling the display with "ignore_lcd=0" in the config.txt file: https://github.com/raspberrypi/documentation/tree/master/hardware/display


Here's a crazy looking answer which apparently involves killing and restarting the xservice (and checking that tvservice is running? Not clear yet). This is another viewpoint of the answers that I saw concerning tvservice I think. http://raspberrypi.stackexchange.com/questions/39960/touchscreen-w-hdmi-output-only-when-a-display-is-attached

The suggestion above also points to the amazingly long and technically detailed online discussion of how to get both a TFT and HDMI working simultaneously, the thing some other forum threads claim is not possible. Lots of uses of tvservice. Here's the link from the thread above which links to page 2 of the thread at a photo proving that it has been done. It's not clear if any of this applies to the 7-inch touch screen but this is clearly the master class: https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=91764&start=25#p661085

Another difference between the BeagleBone and the pi seems to be in how the /boot partition is mounted. It's still, oddly enough, an FAT partition on the SD card just like for BeagleBone, but for the Pi it has only root write permissions, making swapping the config.txt files around initially impossible either manually or by shell script. The solution was to edit the /etc/fstab file to change the permissions assigned to the entire partition at time of mounting by adding umask=0. The result is a little ungainly in that from experimenting with it I had to set the executable permission as well as the write permission for group and other, which oddly makes every file in the partition executable not just the directories. I can live with that though. Here are a bunch of links on how to do it:

Here's a very nice article that describes all the fstab parameters: http://www.omaroid.com/fstab-permission-masks-explained/

Half of the articles on the subject of fstab concern how to set it up to provide the desired user access to USB sticks, like this page: http://www.techjawab.com/2013/06/how-to-setup-mount-auto-mount-usb-hard.html

The other half of the articles are about setting up NAS, like this one. However, this also has, down in the comments, the solution to the all files executable problem in that instead of using umask, it's possible to use dmask and fmask to set permissions for directories and files separately! Another comment explains how FAT partitions are different and ideas on how to mount them differently. https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=40402

Having implemented the solution of having two versions of /boot/config.txt and swapping them as needed, I discovered that unlike on the BeagleBone, the backlight does not turn off on the touch screen when booting to the HDMI, leaving a pulsing random pattern on the screen. Not a bad reminder to switch back to the LCD when done, but not aesthetic looking. Is it possible to turn off the backlight when not configured to use the LCD? A whole lot of additional research ensued.

The problem comes from when setting ignore_lcd=1 in config.txt, the mailbox directories in /dev for the backlight controls aren't being set up during boot. Clearly the software module that reads the mailboxes and sets the appropriate control lines in the display is not being loaded.

I looked into what the i2c chip is that is being used to control the backlight and if it would be possible to directly access it. Here are some links:



I also did yet another review of how to load drivers in Device Tree, and was able to learn that the backlight has its own Device Tree driver, and get it to load such that it created the mailboxes on boot, but then writing to the mailboxes did nothing (maybe because the part that services the mailboxes is maybe in other drivers for the display or something).



Here are some links from people that want to use the i2c0 bus for HATs or other add-ons. The people writing these articles are pretty clear on how the i2c0 bus has been subordinated for use on the display connector, and just want to take it back. My thought was that there might be clues here for how to get the bus enabled so that I could get a successful scan of the ATTiny88 chip using i2cdetect as the first step to writing some kind of utility to directly program the output of the chip to turn the backlight off.

Here is a forum thread where the answer is to add "dtparam=i2c_vc=on" to config.txt. It didn't work for me, but that may be because I failed to do the other thing that I see also recommended, which is to add "bcm2708.vc_i2c_override=1" to cmdline.txt. In any case, the person who asked the question in this thread did both things and it didn't seem to work for him: http://stackoverflow.com/questions/32021924/raspberry-pi-2-cannot-enable-dev-i2c-0

Here is a thread from around 2016 specific to the previous release of Raspbian ("Wheezy", it is apparently now "Jessie") in which somebody is trying to enable the i2c0 bus. The hints of adding the kernel parm bcm2708.vc_i2c_override=1 to /boot/cmdline.txt and dtparam=i2c_vc=on to /boot/config.txt are discussed, plus the OP has added a few other interesting dtparam lines to his config.txt file. The OP is encouraged to open a ticket on the problem, and it seems like some discussion takes place on the ticket. Somebody else mentions how the i2c0 bus goes to two sets of pins simultaneously, although his description of why that would be a problem isn't in synch with what I've read elsewhere; he had some commands to execute that he says fixes it. Then the OP says that his problem is solved by a "firmware update" which doesn't exactly make sense. Somebody else joins the thread with a slightly similar problem, in that they want to use the i2c on GPIOs 28 and 29. Apparently the solution is to somehow disable the bus on GPIOs 1 & 0, and somebody proposes making a Device Tree overlay to do it. There is some other "Master Class" discussion further down:
https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=102130


The above forum thread has a link to this other forum thread where somebody is trying to get both i2c busses running. He has i2cdetect -y 0 working, but his devices on the bus are not detected. He's got all the modules loading, and has installed i2c-tools. He made sure that the bcm2708 drivers are not blacklisted and added some dtparam statements to his config.txt file. Somebody comments that there is a reason not to edit config.txt directly but I don't get it and in my previous edits for enabling or ignoring the LCD my edits seem to work. However apparently there is a configuration editor and it might produce live results without the need for rebooting. The forum thread dies without an answer apparently being found, but it is notable that the OP uses GPIOs 27 & 28 instead of 28 & 29, and the GPIOs don't have external pull-up resistors so some may need to be added. Again, it doesn't seem like this is going the right direction for me since I know that the ATTiny88 is being controlled fine by i2c0 already, but this thread still seems to have useful info.
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=115709&p=789932&hilit=i2c0#p789932




This thoughtful and measured article, entitled "How to get the second i2c bus to work" seems to describe the problems encountered by many others in forum threads, where they've gotten the bus to scan using i2cdetect but aren't reading any of their hardware that they know is connected. It starts off with a nice review of the history of i2c (in TVs in the 1970's!), goes into the history of how in the original Pi both buses were on the GPIO but when the Pi2 came out the bus 1 i2c got put on the bus 0 GPIO pins and bus 0 was sent to two other connectors. He even knows something about i2c0 being present on GPIO 28 and 29. Unfortunately, after that it becomes unclear to me; he describes his solution which is to use a C library to reprogram the BCM2835 processor to send the i2c0 signals to GPIO 28 and 29. Here is the link in hopes that this will become clearer with a little bit more research: https://martin-jones.com/2013/08/20/how-to-get-the-second-raspberry-pi-i2c-bus-to-work/

Here is an article which completely rewrites the above article in an easier to read how-to step-by-step format. It also discusses "WiringPi" which is mentioned in earlier links also:
https://xdevs.com/article/adding-i2c0-port-raspberry-pi-b-rev-20/




iPhone links:

awesome tutorial on enabling and using spi and both i2c busses. Goes over all of the same info but in tne easiest possible step-by-step format. Uses raspi-config to enable things, which is probably the best way. Goes over how to enable and use i2c0 as if it was easy:

https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial

Adafruit's tutorial on enabling the i2c. From the closest source possible and in the usual nice educational format except that it is only concerned with bus i2c1 and glosses over what happened to i2c0.

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

how to download noobs onto sd card:

https://www.raspberrypi.org/documentation/installation/noobs.md


The google search for raspberry pi i2c install which seems to have a lot of good hits:
https://www.google.com/search?q=raspberry+pi+i2c+install&rlz=1CDGOYI_enUS705US706&oq=raspberry+pi+i2c+ins&aqs=chrome.1.69i57j0l3.17044j0j8&hl=en-US&sourceid=chrome-mobile&ie=UTF-8


The incredible link for the page published before the backlight driver had been added to Raspbian, where the driver chip gor the backlight is identified and traces are cut and wires added to the display board so that the backlight enable can be controlled from a gpio. All to hide the grub loader, apparently. I originally hoped that this link would aid me in figuring out how to send commands to the ATTiny88 once I got the ability to address it directly, but now I'm beginning to like this as a final solution to tbe difficulties in turning off the backlight when ignore_lcd=1.

www.raspberry-projects.com/pi/pi-hardware/raspberry-pi-touch-display/backlight-control


An interesting forum thread where somebody is trying to control what seems to be the rpi backlight and having trouble. This link needs to be further reread to find out if the OP is doing something I might be interested in trying, what the stuff mixed in for screen "blanking" is all about and whether it's useful to me, and also whether this is really all about the 7" touch screen or something wlse:

also why he is using 4 to write to the mailbox, and if the problem got solved in the kernel.

https://github.com/raspberrypi/linux/issues/1179


A github page with what might be source code for the backlight control! Also, one of the early clues that there was a self-contained overlay for the backlight:

https://github.com/raspberrypi/linux/pull/1173/files

Note that the conversation section seems to indicate that what this code is for is setting up the mailbox, and the GPU (Graphics Processor Unit?) firmware is needed to process the mailbox request. The conversation has lots of other potentially useful info in it too:

https://github.com/raspberrypi/linux/pull/1173


Here is the raspberry pi documentation for Device Tree overlays that gives the name of the rpi-backlight overlay! I added it as a dtparam in my config.txt file and it caused the pi to create the mailboxes at boot ti
e but writing to them had no effect if I also had ignore_lcd=1. In any case, this guide os probably the clearest that I have yet encountered on the subject of Device Tree.

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README


The above couple of links were found due to the following Google search:

https://www.google.com/search?q=raspberry+pi+touchscreen+backlight+github&rlz=1CDGOYI_enUS705US706&oq=raspberry+pi+touchscreen+backlight+github&aqs=chrome..69i57.36459j0j9&hl=en-US&sourceid=chrome-mobile&ie=UTF-8

Also note that this search produces more info about i2c setup options from the perspective of Device Tree that might be useful:

https://www.google.com/search?rlz=1CDGOYI_enUS705US706&hl=en-US&ei=PaT3V5WOM8nZjwTYuZXQCA&q=dtoverlay+i2c0&oq=dtoverlay+i2c0&gs_l=mobile-gws-serp.3..33i160k1l2.29604.48539.0.49276.49.43.6.6.6.0.410.6204.10j27j3j2j1.43.0....0...1.1.64.mobile-gws-serp..19.25.2445.3..0j41j0i67k1j0i131k1j0i10k1j0i13k1.drZTiGGdGG0


Here is an online discussion with the developers at the time that the backlight control overlay got added. There is an explanation of why the GPU has to do the backlight controlling (I think because the same i2c bus is used for a camera also), and then some discussion where interested users are having trouble getting the update.

https://www.raspberrypi.org/forums/viewtopic.php?f=45&t=120296

Here is the datasheet for the ATTiny88. The chip has massive functionality so it is not clear why it is being wasted controlling a single on/off line for the backlight driver. It's also clear that I won't easily be able to figure out how to control just that one line over the i2c without some hints:

www.atmel.com/images/doc8008.pdf








raspberry pi 3 switch between touchscreen and hdmi

Research into running a touch screen and an external monitor either at the same time or switchable between them.

Bottom line: With Raspian you can't run two screens at once, and can't hot-switch screens. However, it is possible to tweak configuration files such that the Pi comes up using the desired screen after a reboot, basically the same solution that I used with the Beagle Bone. The configuration files to tweak are different though.

Links:

Here's the google search: https://www.google.com/#q=raspberry+pi+switch+between+touchscreen+and+hdmi

This thread contains some hints about using the "tvservice" function as I've seen in other forum answers, but as I've also seen on forum threads some users have reported that trying it trashed their OS installation. The OP for this forum thread ended up just living with fully removing power from his touch screen when he wanted to use the external monitor, which would be a desperation-only solution for my application: http://raspberrypi.stackexchange.com/questions/41417/how-can-i-switch-between-a-built-in-display-and-hdmi

Here is the thread with the answer, which is to add "ignore_lcd=1" to /boot/config.txt and rebooting when wanting to use HDMI rather than the touchscreen. To go back to the LCD, remove that line. The way I did this on the BeagleBone was to have two versions of the file, and a little shell script that copies the desired one over top of the last configuration file to set up for the next reboot. Interestingly, another commenter on this thread mentions that something called PINN appears to make hot-swapping screens work as I would want. I need to investigate this further: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=147962

Here's the same answer about "ignore_lcd=1" on a forum thread where somebody who tried something slightly different in config.txt was wrong: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=121591#p846271

Here's the same information in reverse, in some of Adafruit's documentation on a github page where the process for enabling the display with "ignore_lcd=0" in the config.txt file: https://github.com/raspberrypi/documentation/tree/master/hardware/display


Here's a crazy looking answer which apparently involves killing and restarting the xservice (and checking that tvservice is running? Not clear yet). This is another viewpoint of the answers that I saw concerning tvservice I think. http://raspberrypi.stackexchange.com/questions/39960/touchscreen-w-hdmi-output-only-when-a-display-is-attached

The suggestion above also points to the amazingly long and technically detailed online discussion of how to get both a TFT and HDMI working simultaneously, the thing some other forum threads claim is not possible. Lots of uses of tvservice. Here's the link from the thread above which links to page 2 of the thread at a photo proving that it has been done. It's not clear if any of this applies to the 7-inch touch screen but this is clearly the master class: https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=91764&start=25#p661085

Another difference between the BeagleBone and the pi seems to be in how the /boot partition is mounted. It's still, oddly enough, an FAT partition on the SD card just like for BeagleBone, but for the Pi it has only root write permissions, making swapping the config.txt files around initially impossible either manually or by shell script. The solution was to edit the /etc/fstab file to change the permissions assigned to the entire partition at time of mounting by adding umask=0. The result is a little ungainly in that from experimenting with it I had to set the executable permission as well as the write permission for group and other, which oddly makes every file in the partition executable not just the directories. I can live with that though. Here are a bunch of links on how to do it:

Here's a very nice article that describes all the fstab parameters: http://www.omaroid.com/fstab-permission-masks-explained/

Half of the articles on the subject of fstab concern how to set it up to provide the desired user access to USB sticks, like this page: http://www.techjawab.com/2013/06/how-to-setup-mount-auto-mount-usb-hard.html

The other half of the articles are about setting up NAS, like this one. However, this also has, down in the comments, the solution to the all files executable problem in that instead of using umask, it's possible to use dmask and fmask to set permissions for directories and files separately! Another comment explains how FAT partitions are different and ideas on how to mount them differently. https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=40402

Having implemented the solution of having two versions of /boot/config.txt and swapping them as needed, I discovered that unlike on the BeagleBone, the backlight does not turn off on the touch screen when booting to the HDMI, leaving a pulsing random pattern on the screen. Not a bad reminder to switch back to the LCD when done, but not aesthetic looking. Is it possible to turn off the backlight when not configured to use the LCD? A whole lot of additional research ensued.

The problem comes from when setting ignore_lcd=1 in config.txt, the mailbox directories in /dev for the backlight controls aren't being set up during boot. Clearly the software module that reads the mailboxes and sets the appropriate control lines in the display is not being loaded.

I looked into what the i2c chip is that is being used to control the backlight and if it would be possible to directly access it. Here are some links:



I also did yet another review of how to load drivers in Device Tree, and was able to learn that the backlight has its own Device Tree driver, and get it to load such that it created the mailboxes on boot, but then writing to the mailboxes did nothing (maybe because the part that services the mailboxes is maybe in other drivers for the display or something).



Here are some links from people that want to use the i2c0 bus for HATs or other add-ons. The people writing these articles are pretty clear on how the i2c0 bus has been subordinated for use on the display connector, and just want to take it back. My thought was that there might be clues here for how to get the bus enabled so that I could get a successful scan of the ATTiny88 chip using i2cdetect as the first step to writing some kind of utility to directly program the output of the chip to turn the backlight off.

Here is a forum thread where the answer is to add "dtparam=i2c_vc=on" to config.txt. It didn't work for me, but that may be because I failed to do the other thing that I see also recommended, which is to add "bcm2708.vc_i2c_override=1" to cmdline.txt. In any case, the person who asked the question in this thread did both things and it didn't seem to work for him: http://stackoverflow.com/questions/32021924/raspberry-pi-2-cannot-enable-dev-i2c-0

Here is a thread from around 2016 specific to the previous release of Raspbian ("Wheezy", it is apparently now "Jessie") in which somebody is trying to enable the i2c0 bus. The hints of adding the kernel parm bcm2708.vc_i2c_override=1 to /boot/cmdline.txt and dtparam=i2c_vc=on to /boot/config.txt are discussed, plus the OP has added a few other interesting dtparam lines to his config.txt file. The OP is encouraged to open a ticket on the problem, and it seems like some discussion takes place on the ticket. Somebody else mentions how the i2c0 bus goes to two sets of pins simultaneously, although his description of why that would be a problem isn't in synch with what I've read elsewhere; he had some commands to execute that he says fixes it. Then the OP says that his problem is solved by a "firmware update" which doesn't exactly make sense. Somebody else joins the thread with a slightly similar problem, in that they want to use the i2c on GPIOs 28 and 29. Apparently the solution is to somehow disable the bus on GPIOs 1 & 0, and somebody proposes making a Device Tree overlay to do it. There is some other "Master Class" discussion further down:
https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=102130


The above forum thread has a link to this other forum thread where somebody is trying to get both i2c busses running. He has i2cdetect -y 0 working, but his devices on the bus are not detected. He's got all the modules loading, and has installed i2c-tools. He made sure that the bcm2708 drivers are not blacklisted and added some dtparam statements to his config.txt file. Somebody comments that there is a reason not to edit config.txt directly but I don't get it and in my previous edits for enabling or ignoring the LCD my edits seem to work. However apparently there is a configuration editor and it might produce live results without the need for rebooting. The forum thread dies without an answer apparently being found, but it is notable that the OP uses GPIOs 27 & 28 instead of 28 & 29, and the GPIOs don't have external pull-up resistors so some may need to be added. Again, it doesn't seem like this is going the right direction for me since I know that the ATTiny88 is being controlled fine by i2c0 already, but this thread still seems to have useful info.
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=115709&p=789932&hilit=i2c0#p789932




This thoughtful and measured article, entitled "How to get the second i2c bus to work" seems to describe the problems encountered by many others in forum threads, where they've gotten the bus to scan using i2cdetect but aren't reading any of their hardware that they know is connected. It starts off with a nice review of the history of i2c (in TVs in the 1970's!), goes into the history of how in the original Pi both buses were on the GPIO but when the Pi2 came out the bus 1 i2c got put on the bus 0 GPIO pins and bus 0 was sent to two other connectors. He even knows something about i2c0 being present on GPIO 28 and 29. Unfortunately, after that it becomes unclear to me; he describes his solution which is to use a C library to reprogram the BCM2835 processor to send the i2c0 signals to GPIO 28 and 29. Here is the link in hopes that this will become clearer with a little bit more research: https://martin-jones.com/2013/08/20/how-to-get-the-second-raspberry-pi-i2c-bus-to-work/

Here is an article which completely rewrites the above article in an easier to read how-to step-by-step format. It also discusses "WiringPi" which is mentioned in earlier links also:
https://xdevs.com/article/adding-i2c0-port-raspberry-pi-b-rev-20/




iPhone links:

awesome tutorial on enabling and using spi and both i2c busses. Goes over all of the same info but in tne easiest possible step-by-step format. Uses raspi-config to enable things, which is probably the best way. Goes over how to enable and use i2c0 as if it was easy:

https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial

Adafruit's tutorial on enabling the i2c. From the closest source possible and in the usual nice educational format except that it is only concerned with bus i2c1 and glosses over what happened to i2c0.

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

how to download noobs onto sd card:

https://www.raspberrypi.org/documentation/installation/noobs.md


The google search for raspberry pi i2c install which seems to have a lot of good hits:
https://www.google.com/search?q=raspberry+pi+i2c+install&rlz=1CDGOYI_enUS705US706&oq=raspberry+pi+i2c+ins&aqs=chrome.1.69i57j0l3.17044j0j8&hl=en-US&sourceid=chrome-mobile&ie=UTF-8


The incredible link for the page published before the backlight driver had been added to Raspbian, where the driver chip gor the backlight is identified and traces are cut and wires added to the display board so that the backlight enable can be controlled from a gpio. All to hide the grub loader, apparently. I originally hoped that this link would aid me in figuring out how to send commands to the ATTiny88 once I got the ability to address it directly, but now I'm beginning to like this as a final solution to tbe difficulties in turning off the backlight when ignore_lcd=1.

www.raspberry-projects.com/pi/pi-hardware/raspberry-pi-touch-display/backlight-control


An interesting forum thread where somebody is trying to control what seems to be the rpi backlight and having trouble. This link needs to be further reread to find out if the OP is doing something I might be interested in trying, what the stuff mixed in for screen "blanking" is all about and whether it's useful to me, and also whether this is really all about the 7" touch screen or something wlse:

also why he is using 4 to write to the mailbox, and if the problem got solved in the kernel.

https://github.com/raspberrypi/linux/issues/1179


A github page with what might be source code for the backlight control! Also, one of the early clues that there was a self-contained overlay for the backlight:

https://github.com/raspberrypi/linux/pull/1173/files

Note that the conversation section seems to indicate that what this code is for is setting up the mailbox, and the GPU (Graphics Processor Unit?) firmware is needed to process the mailbox request. The conversation has lots of other potentially useful info in it too:

https://github.com/raspberrypi/linux/pull/1173


Here is the raspberry pi documentation for Device Tree overlays that gives the name of the rpi-backlight overlay! I added it as a dtparam in my config.txt file and it caused the pi to create the mailboxes at boot ti
e but writing to them had no effect if I also had ignore_lcd=1. In any case, this guide os probably the clearest that I have yet encountered on the subject of Device Tree.

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README


The above couple of links were found due to the following Google search:

https://www.google.com/search?q=raspberry+pi+touchscreen+backlight+github&rlz=1CDGOYI_enUS705US706&oq=raspberry+pi+touchscreen+backlight+github&aqs=chrome..69i57.36459j0j9&hl=en-US&sourceid=chrome-mobile&ie=UTF-8

Also note that this search produces more info about i2c setup options from the perspective of Device Tree that might be useful:

https://www.google.com/search?rlz=1CDGOYI_enUS705US706&hl=en-US&ei=PaT3V5WOM8nZjwTYuZXQCA&q=dtoverlay+i2c0&oq=dtoverlay+i2c0&gs_l=mobile-gws-serp.3..33i160k1l2.29604.48539.0.49276.49.43.6.6.6.0.410.6204.10j27j3j2j1.43.0....0...1.1.64.mobile-gws-serp..19.25.2445.3..0j41j0i67k1j0i131k1j0i10k1j0i13k1.drZTiGGdGG0


Here is an online discussion with the developers at the time that the backlight control overlay got added. There is an explanation of why the GPU has to do the backlight controlling (I think because the same i2c bus is used for a camera also), and then some discussion where interested users are having trouble getting the update.

https://www.raspberrypi.org/forums/viewtopic.php?f=45&t=120296










Monday, April 11, 2016

Debian how to enable pcf8563 in device tree

Clearing browser tabs from an old effort to try again to get the pcf8563 RTC chip to install into my Debian OS using Device Tree. I was never able to figure out how to get the chip installed this way, instead I got the driver module compiled. These links mostly don't make sense to me but I'm saving them for future reference if I eventually grow to understand Device Tree better.

An email or forum thread from somebody who made some changes to the commonly available driver for some reason associated with Device Tree interfaces. I'm not sure what lkml is though: https://lkml.org/lkml/2012/7/18/241

Another message from the same thread from somebody who made changes to the driver because of Device Tree needs: https://lkml.org/lkml/2012/7/18/241

A list which seems to indicate that the pcf8563 is "trivial" and supported by Device Tree. But I have no idea how that helps: http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/i2c/trivial-devices.txt?v=3.14

More about Device Tree and I2C, in this case for Raspberry Pi. This should help somehow with the pcf8563 which is an i2c device. This document seems to show how to enable RTCs including the pcf8563, and may actually work but I couldn't figure it out: https://www.raspberrypi.org/forums/viewtopic.php?t=97314

This seems to be a tutorial on how to write Device Tree overlays, and mentions the pcf8563 but again I wasn't sure what to do here: https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README





Thursday, February 25, 2016

Linux write message to log file from .service

As part of trying to debug the .service that I set up for installing the RTC chip on my BeagleBone at boot time, I was interested in writing messages to the Linux system logs from the shell script that it called. This turns out to be fantastically easy; there seems to be a couple of different commands that can be used, I went with the 'logger' command, as described in this link:

http://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html

Tuesday, February 16, 2016

Notes from compiling a kernel module from scratch

Found the debian SD image for BeagleBone that I started testing with so long ago. It's probably obsolete by now, but at least I know that it works.

Its name is bone-debian-7.8-lxde-4gb-armhf-2015-03-01-4gb.img

Used Win32DiskImager to write it to a blank 4G SD card from AdaFruit.

Beaglebone booted to LXDE desktop after a worrying 45 second pause (It might have been setting up the ethernet connection)

perform apt-get update

sudo apt-get update

Update Tkinter just because

sudoe apt-get install python-tk

start python, verify tkinter installed to make sure that the last installs worked.

$ which python
$ python
import os
import Tkinter
^d

get my kernel version:

$ uname -r
3.8.13-bone70

attempt to get the source tree headers:

$ sudo apt-get install kernel-headers-$(uname -r)
E: Unable to locate package kernel-headers-3.8.130bone70
E: Couldn't find any package by regex 'kernel-headers-3.8.13-bone70'

$ sudo apt-get install kernel-headers
E: Unable to locate package kernel-headers

Try searching the cache for anything that might be what I'm looking for:

$ apt-cache search kernel | grep headers
$apt-cache search headers | grep bone70
linux-headers-3.8.13-bone70

Note: from above searches, I discovered that the cache had headers up to and probably past bone79.
trying again to get the source tree headers:

$ sudo apt-get install linux-headers-$(uname -r)

Worked great.

Download hello.c and Makefile from google cached version of this site (which seems to be not responding right now for some reason) http://www.cyberciti.biz/faq/add-remove-list-linux-kernel-modules/

Copy Makefile and hello.c to new folder under /home/debian, cd to folder, run 'make'. Compiled .ko file as promised.

Run the following commands. Kernel module seems to be installed, although there is an extra message in the /var/log/messages file saying: "hello: module license 'unspecified' taints kernel"

$ modinfo hello.ko
$ sudo insmod hello.ko
$ lsmod
$ rmmod hello
$ tail -f /var/log/messages

Pulled raw rtc-pcf8563.c file from https://github.com/jeffegg/beaglebone/tree/master/drivers/rtc and tried to put it in its own directory under /home/debian with the Makefile from the hello example, changing the name of the object to compile, got some compile errors. Specifically it doesn't like THIS_MODULE and the module property declarations at the end.

The makefile at https://github.com/jeffegg/beaglebone/tree/master/drivers/rtc has a bunch of options for compiling other things like rtc-lib.o, rtc-core.o, all of which seem like I might need them.

Looking at the linux headers directory that I downloaded earlier, I am surprised to find the exact same makefile under /usr/src/linux-headers-3.8.13-bone70/drivers/rtc!!!! This may indicate that I might be able to find the kernel module in the source tree and just build it after all. The question is how to get the source tree. After a lot of fiddling, trying:

$sudo apt-get install linux-source

This seems to be getting me the 3.2 source instead of the 3.8 for unknown reasons, but that might be sufficient to get a drivers build directory that matches the drivers header directory.

Tuesday, January 12, 2016

Debian set system time

To set the system time in Linux is very easy; the date command allows setting of the system date and time. This does not affect any time kept by a hardware clock, the hwclock command is needed for that. The BeagleBone does not come with a hardware clock, however, so the hwclock command fails out gracefully.

sudo date --set 1998-11-02
sudo date --set 21:08:00

Reference link:
https://wiki.debian.org/DateTime

Thursday, January 7, 2016

BeagleBone RTC Cape

So, it turns out that the BeagleBone (or the BeagleBone Black for that matter) does not have a battery back-up for its clock, so it loses the time every time I turn it off. It is mentioned on some websites that you have to set up an NTP access to fire on bootup to keep the clock set to the current time, but of course my application is off the network. It turns out that a few people have made something called a Real Time Clock cape that has a button cell and a particular single-chip solution to act as the Beagle Board's hardware clock. Unfortunately, the nicest of these, originally sold by BeagleBoard Toys, is no longer being made.

Presently, a multipurpose board sold by Waveshare has an RTC chip and a battery. It can be bought from the company, or interestingly from Amazon.

It is also possible to either hook up the Adafruit RTC stamp to a cape protoboard as described in this article, or completely build the BeagleBoard Toys design on a protoboard.

This article shows what commands to use to set the time on the adafruit RTC stamp once the RTC cape using it is assembled.

This forum thread has more info about different RTC chips that can be used for this sort of project.

Wednesday, January 6, 2016

Linux how to make an icon that launches a python program

This turns out to be ridiculously easy. In most Linux distros, you can just put a text file where you want the launcher (like on the desktop), give it a .desktop extension, and add in text lines that define the location of the program to run and even the icon for the launcher file to show. Some links:

https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=71468

This one is particularly nice because it's the actual standard, plus it's well-written to boot.

http://standards.freedesktop.org/desktop-entry-spec/latest/index.html


http://ubuntuforums.org/showthread.php?t=2221617

https://www.raspberrypi.org/forums/viewtopic.php?f=27&t=9817


Wednesday, November 18, 2015

A python app with Tcl/Tk gui file selection on a BeagleBone with LCD7 touch screen

Trying to pull together a demo user interface for my GSE box, making use of the python code from the previous demo and the hardware that I have on hand which is a BeagleBone with the LCD7 touchscreen. Along the way, a whole lot of involuntary education is occurring, so I'm documenting the journey here.

The plan:
1. Get the BeagleBone powered and figure out how to get the touchscreen working
2. Figure out if the OS for the BeagleBone has python.
3. Study the python code from the demo and glue in tcl/tk file selection dialogs where appropriate to make it more user friendly.
4. Migrate everything over to the Raspberry Pi. Supposedly all the python will be nicely portable.

Notes for each step:

1. Get the BeagleBone powered and figure out how to get the touchscreen working:

Fortunately for me, this was all already working. The hardest part was making sure that I had the polarity of my power chord correct (center positive) and that I was using a supply capable of powering the screen (needed to be 2A). In the end, I am temporarily fudging it with my cut USB chord with power plug wired on that I made for testing the GSE circuit board. The first USB power block that I tried was only 1.2A and this was insufficient, but most dual power blocks supply 2A and one of those runs it just fine. The Beagle Board website actually has very helpful links to recommended power supplies from DigiKey (http://beagleboard.org/peripheral). The Beagle Board powered up fine over USB and I'm able to use my trusty PuTTY to log into it using the default password over the USB cable. With the 2A power to the LCD7, the board finds the screen automatically, and loads a desktop GUI without any fiddling required. It turns out that the microSD card that came with the BeagleBone has a Linux distribution called "Angstrom" that is fully integrated with a Gnome desktop. The only disappointment is that the touchscreen is barely able to control this GUI without a keyboard and mouse. It is possible to drag the mouse pointer around with a finger to the screen, click by pressing, but the resolution of the GUI is so high that it's difficult to position the mouse pointer precisely enough by touch, and there doesn't seem to be an on-screen keyboard (I got an on-screen keyboard in a later Angstrom distribution that I tried, but it's not like an iPhone where it pops up when needed and is optimized for mobile use).

2. Figure out if the OS for the BeagleBone has python.

Once I got a USB keyboard and mouse connected, starting a terminal window and typing "which python" answered the question of whether python was installed. Directly starting python by just typing "python" got me the python prompt. But then, shockingly, "import Tkinter" failed. I could import other standard libraries and execute other python commands, but no Tkinter, tkinter, or _tkinter. Googling has revealed that everybody else has this problem as well. A variety of solutions have been tried, apparently. These include: a) Doing package updates in Angstrom to get Tkinter, but it seems that a simple package update is not sufficient and "rebuilding python" is required! That sounded like way too much, but somebody on a forum thread suggested b) trying out Ubuntu instead. Sadly, I've learned that the BeagleBone distribution of Ubuntu does not come with a desktop interface installed by default like in Angstrom, and its python distribution doesn't come with Tkinter either. However, in the process I learned how to get disk images for both Angstrom and Ubuntu and load them to a microSD card from the safety of my Windows laptop. Notes follow:

b. Get Ubuntu:

I started by first trying to download a new distribution of Angstrom and booting the BB from it, and it worked great. The following link contained perfect handholding for how to get the image file, where to get 7Zip for unpacking it, and where to get a Windows app for writing it to an SD card:

http://beagleboard.org/getting-started#update

Interestingly, the SD card writer app is apparently distributed by Ubuntu. Here is Ubuntu's own page about the App (and other methods of writing SD card images that don't apply to my attempts to do it from Windows):

https://help.ubuntu.com/community/Installation/FromImgFiles

The new Angstrom distribution booted up to the desktop like the original Angstrom distribution that came with the Beagle Board, but still didn't have Tkinter installed.

I was able to repeat the same image installation steps from the above guide while using the Ubuntu image pointed to from here:

http://elinux.org/BeagleBoardUbuntu#BeagleBone_White.2FBlack.2FGreen

Trying it out, I got the familiar screenfuls of grubloader lines on the LCD7, which means that it found the screen. However, no GUI! I logged in using the default password for the distribution, did a "which python" and "python" and to my surprise, still no Tkinter! While I had learned how to get Ubuntu, it hadn't solved my problem, and it turns out that I have to install a gui manually. As far as I can tell, this also means doing the step which I've so far tried to avoid which is putting the BeagleBone on a network. This is something that can't do at work, ironically enough, because of our locked-down IP assignments, and I don't have a Wi-Fi cape for the Beagle Bone, which means the only place I have to plug it into is my router at home.

Here's probably the best link which explains which packages to download and install to get Tkinter in Ubuntu and mentions the command to do the rebuild (the first comment mentions it, but scroll down to the nicer example in the second comment). This thread in particular applies to my case because I noticed that my distribution of Ubuntu had python 2.7 like the OP of this thread:

http://stackoverflow.com/questions/11752174/how-to-get-tkinter-working-with-ubuntus-default-python-2-7-install

This is the link that describes needing to install tk-dev!

The above link points to this sort of unrelated thread which has a very nice reply from someone about the general process for building Python in Ubuntu:

http://stackoverflow.com/questions/6171210/building-python-and-more-on-missing-modules

So, I read a bunch of threads about how to get a GUI for Ubuntu. Most of them agree that for BeagleBone the best one to try is LXDE. Sadly, a lot of people out there trying to make this work are using a Beagle Bone Black which is not what I have and also has on-board flash memory for the OS which I don't have.

Here is a long forum thread with a lot of clues about downloading the LXDE package and getting it to install. The scripts described from the "tools" directory seem to be on the Beagle Bone Black and not on the Ubuntu distro that I have. There's also some warnings about problems with Gnome utilities, which wouldn't affect me trying to install LXDE but I have Gnome in the Angstrom distribution and you never know when a customer is going to try to open something:

https://groups.google.com/forum/#!msg/beagleboard/TtcD9vfOzT8/1stwCBZqNRAJ

This link is mostly about BBB but is hopefully still instructional for my case:

http://elinux.org/Beagleboard:Installing_LXDE

A third option, c, is to try the BeagleBone distribution of Debian from the following link. There might be more of a chance that it will come up with a GUI desktop; BeagleBone's Angstrom distribution which had a GUI comes from the same page, and the Ubuntu distribution actually didn't come from any of BeagleBone's pages. Although reading the comments it seems that the latest Debian image from the BeagleBone page is corrupted so going down this path my end up sucking.

http://beagleboard.org/latest-images

However, when I tried it, the Debian image downloaded and booted fine and went to a GUI. It's a lot faster than Angstrom and looks nicer but doesn't have a lot of applications. It seems to be LXDE. It still doesn't have Tkinter, producing the exact same error message when I try to import it. Supposedly Debian is derived from Ubuntu or vice versa. So I launched into some more online searches:

Keying off of the specifics of the message:

Some search results from the message: File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42:
This thread which describes the exact message, plus the "Package python-tk has no installation candidate" message I get when trying to do the installation: http://ubuntuforums.org/showthread.php?t=1959073
A thread in which somebody solved the problem by installing the library using "Synaptic", and there's also some rage about why they wouldn't just include the library. Note that I don't seem to have Synaptic on my two working Beagle Bone distros: http://askubuntu.com/questions/513981/tkinter-on-ubuntu-14-04-seems-not-to-work
A page about How to install Tkinter, however it doesn't seem to mention needing tk-dev as another search seems to have turned up: http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter

Some search results from: E: Package 'python-tk' has no installation candidate:
A thread that describes what I'm seeing exactly, but no apparent solutions. A link to a python man page about Tkinter, some suggestions to check the repository list (which is probably my issue since I'm not even on a network)http://ubuntuforums.org/showthread.php?t=361342
The python wiki page mentioned above, which includes such interesting categories as "Tkinter Folklore"https://wiki.python.org/moin/TkInter
An interesting thread with a newbie in which it is eventually resolved that he's not getting to the mirrorshttp://ubuntuforums.org/showthread.php?t=1629083

Searching for Sneakernet options for doing package updates:
A thread full of different ideas, like using Synaptic, an offline repository program, apt-mirror, using apt-get with some kind of verbose arguments, and other hints: http://askubuntu.com/questions/974/how-can-i-install-software-or-packages-without-internet-offline
A short thread where somebody gives a link to Ubuntu's packages web page: http://ubuntuforums.org/showthread.php?t=1488395
A hint which seems to be to run apt-get while navigated to the thumb drive, an interesting idea. Also mentions running dpkg: http://www.linuxquestions.org/questions/linux-newbie-8/install-new-packages-from-usb-drive-using-apt-get-4175417568/
Another instructional about using dpkg: http://www.pendrivelinux.com/how-to-install-deb-packages/

So, in the end, I brought the board home and plugged it into my FiOS router with the Debian OS installed; it got a DHCP address immediately and got on the network with no issues. I began following the instructions for doing package updates for Ubuntu using apt-get, and they worked very smoothly. I had to do the following:

sudo apt-get update
sudo apt-get install python-tk

And that seemed to fix it! From within the python prompt, I was able to import Tkinter and launch dialog boxes like I plan to do with my final program. Apparently, rebuilding python as described in the Ubuntu links was not required.

After getting that to work, I was curious to see if I could get it to work for Angstrom. Angstrom doesn't seem to use apt-get, it uses opkg. I did

opkg update
opkg list | grep tkinter
opkg install tkinter

(I have to check that the last line is exactly the one that I did). Anyhow, it didn't work. I also tried:

opkg install tk-dev

It downloaded and installed, but still no love from "import Tkinter". I was unable to "rebuild" python according to the instructions in the one link that explained it because Make failed with some error message that didn't make any sense, and I couldn't find a "configure" script in the python lib directory. It is probably likely that I haven't actually downloaded the python source directory.

Rather than address that problem directly, I decided to turn back to getting a GUI for the Ubuntu distribution, now that I'd overcome my fear of putting the Beagle Bone on my home network and had gotten through a cycle or two of downloading and installing packages. One of the many web searches I'd done had shown some much nicer-looking Tcl/Tk dialog boxes for a Ubuntu desktop which makes sense since Tkinter uses whatever API is native to the OS. After some searching through links like the following:

http://www.makeuseof.com/tag/10-top-linux-desktop-environments-available/
http://www.javacodegeeks.com/2014/02/5-most-awesome-desktop-environments-for-ubuntu.html

I decided that the desktop I saw must have been the "Unity" desktop which is the one that is most often used with Ubuntu anyhow. It looks like this:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgokrjrPlbVvsolhVc4Gvl5Fx9-RealsRXfJbUyT-QS-s0v8WZEKjLhHAE_8H8fGGD8UgBqAmvyIiHdfTqQwt64RQRKcwEKLW_tHwI0cEk83i_IMjwegtL7qMzDX7hDgiSMC9wPChIeHEvB/s1600/ubuntu-precise-apps-screenshot.png

So to get Unity, there seems to be a circle of links describing how to install it on an SD card for Beagle Bone. Some of these are for BBB which I don't have, and some talk about "expanding" the disk partition on the SD which again sounds like a lot of work. I guess I should try these though:

http://elinux.org/Beagleboard:Ubuntu_On_BeagleBone_Black#Ubuntu_Precise_On_Micro_SD
http://elinux.org/Beagleboard:Desktops_On_Ubuntu/Debian#Ubuntu_Precise_On_A_microSD_With_Ubuntu_Desktop

I'm not sure yet what the difference is between Unity and Precise. Unity is supposedly the default desktop, while the links mention Precise, and they both look the same in Google image searches.

Here's an instructible about installing Ubuntu with LXDE, presumably the procedure for installing Unity would be similar. Since I apparently already have LXDE with my Debian install, my interest is in trying to experiment with something visually different:

http://www.instructables.com/id/BeagleBone-Ubuntu-OS-LXDE-GUI/