Search This Blog

Saturday, 18 August 2012

2740p input devices, part 2

matt@MES-2740p:~$ sudo lsinput
/dev/input/event0
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x3
   version : 0
   name    : "Sleep Button"
   phys    : "PNP0C0E/button/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event1
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x5
   version : 0
   name    : "Lid Switch"
   phys    : "PNP0C0D/button/input0"
   bits ev : EV_SYN EV_SW

/dev/input/event2
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x1
   version : 0
   name    : "Power Button"
   phys    : "LNXPWRBN/button/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event3
   bustype : BUS_I8042
   vendor  : 0x1
   product : 0x1
   version : 43841
   name    : "AT Translated Set 2 keyboard"
   phys    : "isa0060/serio0/input0"
   bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP

/dev/input/event4
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "ST LIS3LV02DL Accelerometer"
   phys    : "lis3lv02d/input0"
   bits ev : EV_SYN EV_ABS

/dev/input/event5
   bustype : BUS_USB
   vendor  : 0x4f2
   product : 0xb183
   version : 34133
   name    : "HP Webcam [2 MP Macro]"
   phys    : "usb-0000:00:1a.0-1.5/button"
   bits ev : EV_SYN EV_KEY

/dev/input/event6
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HP WMI hotkeys"
   phys    : "wmi/input0"
   bits ev : EV_SYN EV_KEY EV_MSC EV_SW

/dev/input/event7
   bustype : BUS_I8042
   vendor  : 0x2
   product : 0x1
   version : 0
   name    : "PS/2 Generic Mouse"
   phys    : "isa0060/serio1/input0"
   bits ev : EV_SYN EV_KEY EV_REL

/dev/input/event8
   bustype : BUS_I8042
   vendor  : 0x2
   product : 0x7
   version : 433
   name    : "SynPS/2 Synaptics TouchPad"
   phys    : "isa0060/serio4/input0"
   bits ev : EV_SYN EV_KEY EV_ABS

/dev/input/event9
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x6
   version : 0
   name    : "Video Bus"
   phys    : "LNXVIDEO/video/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event10
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel HDMI/DP,pcm=3"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event11
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel Line"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event12
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel Mic"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event13
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel Headphone"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event14
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel Dock Headphone"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

Random white noise on linux laptop

Random white noise on linux laptop

Now that /dev/dsp and /dev/audio are no longer available ... and oss-compatability package isn't working for me...

pacat /dev/urandom > padsp


Saturday, 4 August 2012

2740p input devices

matt@MES-2740p:~$ xinput
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ PS/2 Generic Mouse                          id=11    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                  id=12    [slave  pointer  (2)]
⎜   ↳ Serial Wacom Tablet stylus                  id=13    [slave  pointer  (2)]
⎜   ↳ Serial Wacom Tablet eraser                  id=15    [slave  pointer  (2)]
⎜   ↳ Serial Wacom Tablet touch                   id=16    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Sleep Button                                id=8    [slave  keyboard (3)]
    ↳ HP Webcam [2 MP Macro]                      id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard                id=10    [slave  keyboard (3)]
    ↳ HP WMI hotkeys                              id=14    [slave  keyboard (3)]




Friday, 3 August 2012

Formatting a USB flash drive as ext3

assuming the device is sdd1 
 
umount /dev/sdd1
 
mkfs.ext3 /dev/sdd1
 
sudo e2label /dev/sdd1  MyLabelForThisMemoryStick
 
 
 

Monday, 4 June 2012

Anonymous File Sharing


  1. You can't use an anonymising service with P2P; peers need to know who you are.  So BitTorrent and Tor is not possible.
  2. You could use BitTorrent and a 'Seedbox'; use a virtual machine at a remote location as your file sharing box, then connect to it securely (VPN, Tor, etc) in order to download the file once it has been downloaded to the seeedbox.
  3. Usenet might be the way to go instead.  You can search for nzb files, and then download them from a usenet provider.  Giganews seems like a big name.  Costs money though.  The advantage of usenet is that your traffic to the usenet host is encrypted, and the files remotely reside... all over the place.

Monday, 14 May 2012

getting through the proxy with sudo !

Problem : command line errors when executing commands with sudo even though http_proxy is correctly set.

Solution :

It's a problem with sudo. If you use sudo, the variable $http_proxy is unknown in this context.
sudo -i opens up a root shell. There you can set the $http_proxy variable again and then easy_install works - you don't have to use sudo because you are already superuser.
$ sudo -i
# export http_proxy=your proxy here... 
 
So for access to the outside world from UWE : 
 
export http_proxy=http://proxysg.uwe.ac.uk:8080

Thursday, 3 May 2012

rsync after cp

I have a disk full of music and I want to make a new backup.

I copied the directory structure from src to dest:

cp -r src/* dest/

All the files are at the destination.  Now I want to be able to do incremental backups using rsync - however, when I try rsync it seems to want to copy everything again!  What a bore!

Let's try to find a solution.

"Rsync finds files that need to be transferred using a "quick check" algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file's data does not need to be updated. "

I imagine either one of two things might be the cause;


  1. rsync creates a database.  The database doesn't exist yet, so it starts all over again.  Maybe I can get rsync to make the database without doing the copying?
  2. some metainformation was not copied, but was created anew by cp.  This makes the files look different to rsync.  Solution would be to make the files look the same, and run rsync.
Investigating.

1.  Seems to not be true.  Rsync doesn't create a database, it uses an efficient checking algorithm to see whether anything has changed.

2.  Possible information; the file is different (but I know they won't be!) - something to do with the permissions, etc - something to do with mod times etc.

let's check:
  • md5sum src/file1 = md5sum dest/file1 ... yep, the files are the same
  • the files have different meta-information (owner, and timestamp) : this could be it!
A little experimentation reveals that its the timestamp data that is the problem.

If I create a new src and dest and make a little file in src, then copy it to the dest, rsync will attempt to copy it again.  If I delete the copy in dest, then copy it using cp --preserve ... rsync doesn't try to copy it.

So I need to find a way to change the timestamps on all the files in the destination to be the same as in the source.  

matt@blueAcer:~/rsync$ rm dest/*
matt@blueAcer:~/rsync$ cp src/* dest/
matt@blueAcer:~/rsync$ rsync -avzn src/ dest/
sending incremental file list
./
test.file

sent 110 bytes  received 34 bytes  288.00 bytes/sec
total size is 6  speedup is 0.04

But if I freshen the timestamps...

matt@blueAcer:~/rsync$ touch src/* dest/*
matt@blueAcer:~/rsync$ rsync -avzn src/ dest/
sending incremental file list

sent 61 bytes  received 12 bytes  146.00 bytes/sec
total size is 6  speedup is 0.08

Ah ha!  Problem solved.  But I guess what I *really* want to do is to make the timestamps in dest the same as they were in src.

touch has a -r [reference file] option:

       -r, --reference=FILE
              use this file's times instead of current time

touch -r src/test.file dest/test.file 

Yes!  An rsync after this doesn't try to copy it, and stat shows exactly the same time info for both files.  So I could walk my dest directory, touching files w.r.t their origin.

Hmm... ok.  This is going to be much faster than rsync ing all those hundreds of Gb of flac files!

It would be nice to be able to use a coreutil for this.  Maybe find?

find all flac files in dest, and for each, chop $src from the start of the path, replace it with $dest, then do my touch -r trick with the resulting src file.

A clearly more elegant approach would find pairs of files, and then operate on them.  I'm not sure that's possible - I think it would mean running find after each output of the first find.  Bad.

dest=dest
src=src
extension=file
find $dest/ -name "*.$extension" -exec touch -r \{\} $src/`basename {}` \;

This doesn't work.  The problem lies with the order in which substitution occurs; basename is getting called with an unsubstituted {} - the base of this is {} ... then when we get to the wrapping context we end up with the substitution of $src with its value, and then the original value for {} - in other words, basename has no effect.

Same problem happens with | xargs -n1 -0 ...

A big pain in the arse.

Here's the answer; and it's really simple.  We just need to put the filename munging into a script where the touch happens... and call it with exec using parameters from find.  It gets called once for each file found by find, and we can pass in the name of the file as {}, along with the values of the root directory of the destination tree and the source tree.


dest=dest; src=src; extension=file;find $dest/ -name "*.$extension" -exec /home/matt/scripts/update.sh {} $dest $src \;


# update.sh

#!/bin/bash
srcFile=${1/$3/$2}
touch -r "$srcFile" "$1"