Recently my laptop is all explode on closing the lid.
It turns out this is fixable, and the answers were on various stack exchange sites.
First fix the actual problem:
http://unix.stackexchange.com/questions/200125/debian-8-jessie-laptop-stops-working-after-closing-the-laptop-lid?rq=1
Open the file /etc/systemd/logind.conf as root.
Find this: HandleLidSwitch
If it's commented, uncomment and change the value to ignore. The line after editing should be:
HandleLidSwitch=ignore
And then get the bloody thing to notice without having to reboot:
http://unix.stackexchange.com/questions/52643/how-to-disable-auto-suspend-when-i-close-laptop-lid/52645#52645
sudo systemctl stop systemd-logind && sudo systemctl start systemd-logind
Monday, December 21, 2015
apt-get command with all favourite stuff
sudo apt-get update
sudo apt-get upgrade --assume-yes sudo apt-get install --assume-yes gitk mplayer epiphany-browser chromium maven2 tree git-gui mercurial rlwrap vim xclip filelight htop gparted idle3 unison build-essential gparted imagemagick fail2ban kate arandr feh xscreensaver xscreensaver-data xscreensaver-gl xscreensaver-gl-extra xscreensaver-data-extra tig ack-grep wxmaxima npm nodejs-dev texlive texlive-science jekyll haskell-platform mesa-utils nethogs fldiff fortunes fortunes-fr idle mesa-utils haskell-platform get-iplayer npm mypaint mypaint-data-extras libreoffice curl wget xxdiff ufw cdargs krita firmware-ralink workrave emacs emacs-goodies-el cdargs pm-utils octave octave-info screen emacs emacs-goodies-el cdargs ufw gxine xine-ui libdvdcss2 gxineplugin xinput x-tile browser-plugin-gnash transmission gddrescue handbrake handbrake-cli
sudo apt-get upgrade --assume-yes sudo apt-get install --assume-yes gitk mplayer epiphany-browser chromium maven2 tree git-gui mercurial rlwrap vim xclip filelight htop gparted idle3 unison build-essential gparted imagemagick fail2ban kate arandr feh xscreensaver xscreensaver-data xscreensaver-gl xscreensaver-gl-extra xscreensaver-data-extra tig ack-grep wxmaxima npm nodejs-dev texlive texlive-science jekyll haskell-platform mesa-utils nethogs fldiff fortunes fortunes-fr idle mesa-utils haskell-platform get-iplayer npm mypaint mypaint-data-extras libreoffice curl wget xxdiff ufw cdargs krita firmware-ralink workrave emacs emacs-goodies-el cdargs pm-utils octave octave-info screen emacs emacs-goodies-el cdargs ufw gxine xine-ui libdvdcss2 gxineplugin xinput x-tile browser-plugin-gnash transmission gddrescue handbrake handbrake-cli
Thursday, November 19, 2015
Modifying the Source Code of a Debian Package and Unwisely Installing the Modified Version on Your System
Debian's got a hello world package:
$ sudo apt install hello
$ hello
Hello, world!
Remove it!
$ sudo apt remove hello
$ hello
bash: /usr/bin/hello: No such file or directory
Make a directory for unwise experiments:
$ mkdir ~/tmp
$ cd ~/tmp
Get everything we need to build hello ourselves:
$ sudo apt-get build-dep hello
Get the source:
$ sudo apt-get source hello
Compile the source:
$ sudo apt-get source --compile hello
Install the new package:
$ sudo dpkg --install hello_2.9-2+deb8u1_amd64.deb
Check it's on the system:
$ hello
Hello, world!
Modify the program:
$ sudo sed -i 's/Hello/Hell/g' hello-2.9/src/hello.c
$ sudo apt-get source --compile hello
Damn it, tests!
$ sudo sed -i 's/Hello/Hell/g' hello-2.9/tests/hello-1
$ sudo apt-get source --compile hello
Run the local copy:
$ hello-2.9/debian/hello/usr/bin/hello
Ship it!
$ sudo dpkg --install hello_2.9-2+deb8u1_amd64.deb
Paranoid Check:
$ hello
Hell, world!
apt can undo the damage we've just done:
$ sudo apt install hello
$ hello
Hello, world!
$ sudo apt install hello
$ hello
Hello, world!
Remove it!
$ sudo apt remove hello
$ hello
bash: /usr/bin/hello: No such file or directory
Make a directory for unwise experiments:
$ mkdir ~/tmp
$ cd ~/tmp
Get everything we need to build hello ourselves:
$ sudo apt-get build-dep hello
Get the source:
$ sudo apt-get source hello
Compile the source:
$ sudo apt-get source --compile hello
Install the new package:
$ sudo dpkg --install hello_2.9-2+deb8u1_amd64.deb
Check it's on the system:
$ hello
Hello, world!
Modify the program:
$ sudo sed -i 's/Hello/Hell/g' hello-2.9/src/hello.c
$ sudo apt-get source --compile hello
Damn it, tests!
$ sudo sed -i 's/Hello/Hell/g' hello-2.9/tests/hello-1
$ sudo apt-get source --compile hello
Run the local copy:
$ hello-2.9/debian/hello/usr/bin/hello
Ship it!
$ sudo dpkg --install hello_2.9-2+deb8u1_amd64.deb
Paranoid Check:
$ hello
Hell, world!
apt can undo the damage we've just done:
$ sudo apt install hello
$ hello
Hello, world!
Monday, October 19, 2015
How to Back Up a DVD
You'd think, if you wanted to make a backup copy of a dvd to your hard drive, that you'd use dd:
dd if=/dev/dvd of=dvd
But it turns out that a lot of dvds have (deliberately created) bad sectors, which screws this up. Luckily there's a tool called dvdbackup in the Debian archive that only copies the bits of a DVD that a dvd player would actually read:
sudo apt install dvdbackup
dvdbackup --mirror --verbose
It takes about 30mins to back up an 8GB dvd. At that point you'll have a complicated structure in a directory with the name of the DVD.
You can play it with vlc, which will give you the same sort of experience with episode selection and subtitle choosing as you'd get from a DVD player:
vlc The\ Name\ Of\ The\ DVD
Or, if like me you have a preference for mplayer and the command line, you can use:
mplayer dvd://1 -dvd-device The\ Name\ Of\ The\ DVD
Where the 'dvd://1' is saying to play the 'first title'. That's usually what you want if it's a film. If it's got several titles on it, experiment with dvd://2, etc.
Notes:
Occasionally dvdbackup --mirror --verbose will fail immediately, saying:
libdvdread: Could not open /dev/dvd with libdvdcss.
libdvdread: Can't open /dev/dvd for reading
Cannot open specified device /dev/dvd - check your DVD device
This appears to be a red herring of some sort, just try again. Once it's started to work it carries on to completion.
Also, I usually like a progress report as the scanning is going on, and the dvd to eject when it's done:
dvdbackup --mirror --verbose --progress && eject
dd if=/dev/dvd of=dvd
But it turns out that a lot of dvds have (deliberately created) bad sectors, which screws this up. Luckily there's a tool called dvdbackup in the Debian archive that only copies the bits of a DVD that a dvd player would actually read:
sudo apt install dvdbackup
dvdbackup --mirror --verbose
It takes about 30mins to back up an 8GB dvd. At that point you'll have a complicated structure in a directory with the name of the DVD.
You can play it with vlc, which will give you the same sort of experience with episode selection and subtitle choosing as you'd get from a DVD player:
vlc The\ Name\ Of\ The\ DVD
Or, if like me you have a preference for mplayer and the command line, you can use:
mplayer dvd://1 -dvd-device The\ Name\ Of\ The\ DVD
Where the 'dvd://1' is saying to play the 'first title'. That's usually what you want if it's a film. If it's got several titles on it, experiment with dvd://2, etc.
Notes:
Occasionally dvdbackup --mirror --verbose will fail immediately, saying:
libdvdread: Could not open /dev/dvd with libdvdcss.
libdvdread: Can't open /dev/dvd for reading
Cannot open specified device /dev/dvd - check your DVD device
This appears to be a red herring of some sort, just try again. Once it's started to work it carries on to completion.
Also, I usually like a progress report as the scanning is going on, and the dvd to eject when it's done:
dvdbackup --mirror --verbose --progress && eject
Monday, March 2, 2015
Change a String in Every File in a Tree
Suppose I'd like to replace every 'string' with 'newstring' in the directory ~/directory:
Good:
find . -type f -print0 | xargs -0 sed -i 's/string/newstring/g'
Better:
grep -lrZ string | xargs -0 sed -i 's/string/newstring/g'
Best:
git grep -lz 'string' | xargs -0 sed -i 's/string/newstring/g'
Bester:
git grep -lz 'string' ~/directory | xargs -0 sed -i 's/string/newstring/g'
Here are some search terms that will help me find this:
how to change a string in every file in a tree
recursive editing
change strings in every file
find and grep and sed
git grep
how not to fuck up git when
Good:
find . -type f -print0 | xargs -0 sed -i 's/string/newstring/g'
Better:
grep -lrZ string | xargs -0 sed -i 's/string/newstring/g'
Best:
git grep -lz 'string' | xargs -0 sed -i 's/string/newstring/g'
Bester:
git grep -lz 'string' ~/directory | xargs -0 sed -i 's/string/newstring/g'
Here are some search terms that will help me find this:
how to change a string in every file in a tree
recursive editing
change strings in every file
find and grep and sed
git grep
how not to fuck up git when
Monday, September 22, 2014
Grep with Multiple Expressions
Occasionally, you want to find all the lines in a file which have either 'eng', or 'net', or 'ide' in them.
You think "I know, I'll use regular expressions".
Now, you have three problems. The one you weren't expecting is grep's weird syntax for regular expressions.
This subject is both deep and boring. Suffice it to say that:
grep 'eng\|net\|ide'
is an answer
grep -E 'eng|net|ide'
and
ack 'eng|net|ide'
is an answer.
If you really want to know the details, look up 'basic regular expressions', 'extended regular expressions', and 'perl-compatible regular expressions'.
You think "I know, I'll use regular expressions".
Now, you have three problems. The one you weren't expecting is grep's weird syntax for regular expressions.
This subject is both deep and boring. Suffice it to say that:
grep 'eng\|net\|ide'
is an answer
grep -E 'eng|net|ide'
and
ack 'eng|net|ide'
is an answer.
If you really want to know the details, look up 'basic regular expressions', 'extended regular expressions', and 'perl-compatible regular expressions'.
Monday, August 25, 2014
Make Caps Lock Into Control
grrr: After using this for a while, I noticed that xmodmap settings don't get restored after suspend/hibernate. This is annoying, but once you figure out what's going on it's easy enough to run xmodmaprc ~/.xmodmaprc manually. So I'm still using it, it's just not as cool as I thought at first. I imagine there's some way to hook this into the resume scripts....
There's no use at all for the Caps Lock key, once you are old enough NOT TO THINK THIS SORT OF THING IS CLEVER, and in fact having it usually causes problems.
You can make it into another, much more conveniently positioned Control key using an ~/.xmodmaprc file, which should contain the lines:
clear Lock
keycode 0x42 = Control_L
add Control = Control_L
That's it. xmodmap will execute the commands when the X server starts.
Either log out and log back in again, or use:
$ xmodmaprc ~/.xmodmaprc
to run that file explicitly, and from now on, any application running under X will see your Caps Lock key as a Control key instead.
This makes emacs enormously more pleasant to use.
There's no use at all for the Caps Lock key, once you are old enough NOT TO THINK THIS SORT OF THING IS CLEVER, and in fact having it usually causes problems.
You can make it into another, much more conveniently positioned Control key using an ~/.xmodmaprc file, which should contain the lines:
clear Lock
keycode 0x42 = Control_L
add Control = Control_L
That's it. xmodmap will execute the commands when the X server starts.
Either log out and log back in again, or use:
$ xmodmaprc ~/.xmodmaprc
to run that file explicitly, and from now on, any application running under X will see your Caps Lock key as a Control key instead.
This makes emacs enormously more pleasant to use.
Subscribe to:
Posts (Atom)
