Home... Help... Search... Computers...


Tardus's Linux Hints and Tips

Things I've discovered that helped me. Hope they help you too

GIMP - enlarging the image canvas and giving a colour to the extra space

Image > Canvas Size > enter the size > click on "all layers" under Resize Layers.


making a scanned image's background transparent

Using GIMP

1. make image mode RGB

2. Layers > Transparency > Add Alpha Channel

3. Colors > Levels and the eye-dropper to select "black" somewhere in the image line-work ( if needed, slide the rightmost (white) slider in "input" to the left until the contrast looks good)

4. Then use Layers > Color to Alpha to set transparency

This will make everything but the black line-work transparent.

all done!


separating camel-Case words

sed 's/\([A-Z]\)/ \1/g'

Captures each capital letter and substitutes a leading space with the capture for the whole stream.

e.g.

$ echo "aCertainCamelCasedWord" | sed 's/\([A-Z]\)/ \1/g'

a Certain Camel Cased Word

(from https://stackoverflow.com/questions/614930/how-can-i-cut1-camel-case-words)

Fixing missing application icons in Mint 17.x panels

The running app. icons in the Mint Mate panel disappeared.

Right-clicking on the blank part of the panel and de-selecting "Expand" brought the icons back. Note: the shortcut icons for Firefox, terminal, etc. had never disappeared, on those for running apps.

Now the panel shrinks to fit (horizontally) and shows scraps of desktop at the ends. If I right click on the triple bar at either end, and then re-select Expand, I'm back where I started. Still something wrong here, but it is workable.

With Expand on, I used the right-click menu to Add to Panel, then selected "Window List". That fixed it.


Printing images across multiple pages

use PosteRazor


Linux Mint 17 Caja (file manager) case insensitive sort

Sun Jan 15 16:16:50 AEDT 2017

If Caja is using a case sensitive sort eg, A B C a b c, create a file .gnomerc in your home directory, containing

export LC_COLLATE=C

This will force case-insensitive sorting, ie, a B c D e F


Inserting a timestamp using vi / vim

:r !date


preventing Wifi drop-outs in Linux Mint 17 when using the Intel PRO 3945ABG wireless adaptor, on a Lenovo x60s laptop.

UPDATE: Sun Jan 15 16:26:44 AEDT 2017

WiCD still behaving flawlessly - I'll keep using WiCD.

UPDATE: Wed Jan 11 17:24:33 AEDT 2017

WiCD has performed without fault since installed 5 days ago.

UPDATE: Fri Jan 6 15:02:51 AEDT 2017

turning off power management within networkmanager did not work.

Next step: remove network manager and install WiCD instead

.................................................................

From google search, turning power management off for the adaptor seems to be the key.

sudo iwconfig wlan0 power off

Time will tell if this a) is a fix b) survives a reboot.

I added this to /etc/rc.local

 
No longer needed!
 
#!/bin/sh
 
# chkNetwork.sh
 
# check if the network interface is up, and if not, start it.
 
# on the x60s Thinkpad sometimes it does not start properly.
 

 
echo ==== `date` ====
 
echo $0     "-------------------"
 
STATUS=`netstat -rn`
 
# now ping and get the % packet loss
 
ONLINE=`ping -q -c 3 10.1.1.1 | awk ' /loss/ {print $6}'`
 
echo "netstat -rn :" $STATUS
 
echo "ping -q -c 3 :" $ONLINE
 
if [ "$ONLINE" = "100%" ]; then
 
        echo "Network is off-line:"
 
	echo "Now restarting the network and running dhclient"
 
	service network-manager restart
 
	dhclient wlan0
 
else
 
	echo "Network is on-line:"
 
fi
 

 
# and set power management to off, to avoid sporadic Wifi shutdowns
 
PMSTAT=`iwconfig wlan0| grep "Power Management" | awk -F: '{print $2}'`
 
echo "Power management was "$PMSTAT #display current power management status
 
iwconfig wlan0 power off	# set it to off
 
PMSTAT=`iwconfig wlan0| grep "Power Management" | awk -F: '{print $2}'`
 
echo "Power management is "$PMSTAT #display current power management status
 

( from http://askubuntu.com/questions/73607/wireless-connection-keeps-dropping-with-an-intel-3945abg-card )


Removing CTRL-M (^M) from text files

use tr

eg, cat file | tr -d '\r' > newfile


downloading YouTube videos with YouTube videos

1. install it (apt-get works but the version of YouTube-dl gives errors, as at 31 Oct 2016)

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl

sudo chmod a+rx /usr/local/bin/youtube-dl

2. run it

youtube-dl -t -f mp4 https://www.youtube.com/watch?v=B3UknJaPSL0&list=PLiipJOorgIijZRrAQCm_MY2UR9XkI0QgJ&index=2


Round Corners using GIMP

The Filters > Decor > Round Corners option does this, with a dropped shadow too.

If it is greyed out, try turning off the image's alpha channel; Layers > Transparency > Remove Alpha Channel


HP Envy 4005. Ink usage

Original HP 61 (not XL) gave 177 pages and both cartridges ran out together.

Replacement 3rd party cartridges (61XL) off eBay installed OK 30 May 2016. Printer reported them as original HP that had been refilled.


command-line adding tags to MP3 files

eyeD3 is very good


getting TWM working with vncserver on Linux Mint 17.1 20 April 2016

Leaner than using Mate desktop.

sudo apt-get install xterm

edit ~/.vnc/xstartup to contain:


#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

#unset DBUS_SESSION_BUS_ADDRESS

# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

/usr/bin/xterm -geometry 80x24+10+10 -ls -title "xterm" &

/usr/bin/xterm -geometry 80x24+200+200 -ls -T "xterm" &

twm &


If you use the default x-terminal-emulator you get no active prompt, hence cannot enter any commands. Ditto mate-terminal

xterm is fine. To copy and paste, select the text with the mouse, then press middle button (or left and right together) to paste.

See http://unix.stackexchange.com/questions/177364/vnc-unable-to-get-a-shell-prompt-with-the-default-opened-terminal-application/277720#277720


Printing images full size, and to a set size: 18 April 2016

To print an image that is say exactly 35x56mm, for model making etc, use GIMP.

Use the resize function, and with dimensions in mm. Then print from within GIMP using 100% scaling.


getting eth0 to work after swapping hard disk to another motherboard/laptop 18 April 2016

http://www.linuxquestions.org/questions/slackware-14/new-motherboard-eth0-gone-missing-4175524936/

Problem is that with a static IP for server puffer, while udev finds the new Ethernet hardware, and writes it in to /etc/udev/rules.d/70-persistent-net.rules, it does so as "eth1", which is not in the /etc/network/interfaces file.

The fix was to edit the 70...rules file, commenting out the old eth0 entry, and altering the "eth1" entry to "eth0". Then either restart using

> service network-manager restart

or

reboot.


Sketch to Image, March 2016

1. Sketch with black fibre pen, complete, but no colours

2. scan into an image

3. convert -posterize 2 the image to make the black into uniform black

4. use GIMP to add the colour fills and any correction; brush or eraser


Using avconv (replacement for ffmpeg) to edit video from Android camera (Motorola Moto G 2nd Gen), Feb 2016

avconv -i VID_20160203_103749861.mp4 -s 480x270 -strict experimental Kylie.mp4

avconv -i Kylie.mp4 -vf "transpose=1" -strict -2 Kylie-demo-3Feb2016.mp4

avconv -i Kylie-demo-3Feb2016.mp4 -vcodec copy -af volume=volume=12dB Kylie2.mp4


run command at login: 2015

put in ~/.profile


run command at terminal startup: 2015

put these in ~/.bashrc


Date: epoch to seconds, later GNU date, 2015

date -d @Epoch


SNMP page count for HP6520 all-in-1, 2015

>$ snmpwalk -c public -v 1 10.1.1.11|grep 33[0-9][0-9]

iso.3.6.1.2.1.43.10.2.1.4.0.1 = Counter32: 3318

confirmed against Print Status Report


html to pdf conversion, 2015

use: wkhtmltopdf qanda.html qanda.pdf

very good results


Broken home wifi on plover, Oct 28 2015

Installed WiCD via eth0, configured wlan0 for home wifi and all fine, therefore

concluded that network-manager config was mangled.

Found wlan0 defined for tardus, and wifi0 defined for home wifi in

/etc/network/interfaces. Network-manager ignore interfaces defined here. Removed and ran sudo service network-manager restart

This fixed it. No idea how it got messed up. Did connect via phone on Canberra trip last week, so maybe this messed with it.

Removed WiCD after, as it autostarts and could interfere.


Making big text and banners, Oct. 2015

mkBanners.sh works.

Here is the actual convert command:-

convert -background white -fill black -font $FONT \

-size 640x480 \
-gravity Center caption:"$TEXT" $IMAGE

mogrify -trim +repage $IMAGE

So far the best way to print is to insert the images into an Impress file, resizing manually as needed.


join images, 2015

imagemagick convert command

For simple concatenation in a single row or column, the append option of the convert tool is sufficient. Note that -append concatenates all images vertically, creating one column with n rows and +append concatenates horizontally, creating one row with n columns.


Posterise an image, 2015

convert -posterize 2 day4RepairWork-12-complete.jpg junk-2b.jpg

does a fair job.


Add PDF output to CUPS

sudo apt-get install cups-pdf


Complex awk one-liner syntax examples:-

awk ' NR==1 {print $1, $2, NR;t=$1} NR>1 {if (($1-t)<590) print $1,$2, $1 - t,NR; t=$1} ' subFloorAH.hist

# above checks for the timestamp

awk ' { print strftime("%a %b %e %T %Z %Y",$1),$2,$3,$4,$5 }' subFloorAH24h.plot


joining text files into one with columns

paste file1 file2 | column -s $'\t' -t


Linux Mint boot to console (for server)

edit /etc/default/grub to add "text" to the default line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash text"

then run, as root, update-grub


mounting thumbdrives as a user, 2015

use pmount and pumount


MP3 removing silence , 2015

sox, using trim or silence options


LibreOffice button icons

default is "Human", mostly mono; I prefer "tango" with its colours. Use Synaptic to install libre-office-tango, then restart Office.


making PDFs from HTML

pandoc works very well

Does a lot of other conversions too.


if CAJA file names in the icon view are close to invisible,

reset the background to another colour, then back to white. Seems to reset it.


AWK random numbers

awk ' BEGIN {srand(systime() + PROCINFO["pid"])};{item[NR]=$0}; END {x=int(rand()*(NR)+0.9999); printf("%-50s|%2d|%20s\n",item[x],x,FILENAME)} ' $LIST


BASH is not the same as "sh" in Mint 17.1

Fix by redirecting the sh link in /bin


Rescaling a fussy pdf to fit A4 for printing

cpdf -scale-to-fit a4portrait -scale-to-fit-scale 0.8 ChurchContactListApril2015.pdf -o ChurchContactListApril2015-80.pdf

alt: convert -density 300 -trim test.pdf -quality 100 test.jpg

and put the images in a doc.


restarting vsftpd after change to its config file

sudo service vsftpd restart


restarting Mint 17.1 networking

sudo service network-manager restart


plotting time series data, eg, download speed

cat dsl_down.conf | gnuplot

for example see the "PCs" folder


adding two images vertically

convert WEIGEL-VISION-OF-THE-FOUR-BEASTS-a.jpg WEIGEL-VISION-OF-THE-FOUR-BEASTS-b.jpg -append weigel.jpg


Rotating an mp4 video

ffmpeg -i 20150312_171144.mp4 -vf "transpose=1" -strict -2 feedingChooks.mp4

For the transpose parameter you can pass:

0 = 90CounterCLockwise and Vertical Flip (default)

1 = 90Clockwise

2 = 90CounterClockwise

3 = 90Clockwise and Vertical Flip


Cleaning a noisy scanned page

./textcleaner -g -e stretch -g -e stretch -f 25 -o 10 -u -s 1 -T -p 10 Christmas-Angel-1.jpg Christmas-Angel-1-cleaned.jpg

where textcleaner is from Fred's (Imagemagick) Scripts


Ripping CDs - use RipperX


shrinking many mp3s to fit on a CD

use the script shrinkMP3toFreq.sh

eg, shrinkMP3toFreq.sh 44.1 "LOTR*.mp3"


HP6520 "HP protected cartridge installed" error when changing cartridges.

I turned of cartridge chip info in settings. Also had to get the chip of an old 3rd party cartridge and install to one of the older chipless ones. so far so good.


Bulk rename of files

rename 's/This_or_\(that\)/The-other/' *.mp3


Printing a text file, eg, script source

a2ps does not work (Dec. 2014); gives tiny print.

Instead use:-

enscript -2 -jr --header='$n %W Page $% of $=' index.txt

This gives crude borders, title, 2 pages per page in landscape, and is as good as a2ps used to be, though not quite as pretty.


Editing MP4

Avidemux 2.5.4 has bug with GS24G MP4, cant find codec for audio, with Mint 17.1

Here is fix from Linux Mint Forums

Postby Statik on Fri Sep 19, 2014 7:04 pm

Alright, so I exported the package list on the old computer and diff'd it to the new computer and I discovered that avidemux-plugins-common and avidemux-plugins-gtk were both missing. I installed those and it works great!

Thanks!

Rod


Also need to set audio as pulse-audio, not the default. Edit > Prefs > Audio

Used PITIVI instead.

Start new project

add file to it

render it, using MP4 (720 x 576 reduced a 130MB 1m18s file to 20MB) and MP3.

MediaInfoGUI is good for information


normalising mp3 files

mp3gain

or

normalize-audio


splitting an image into 2 horizontally:-

convert rockwallPizza.jpg -crop 50x100% cliff.jpg


joining images seamlessly:-

eg, convert stone-93466_640reversed.jpg stone-93466_640.jpg +append rockwall.jpg


joining mp3 files:

mp3wrap 20140418-WhatIsDeathWhatItsCure_30m_00s__35m_15s_65h.mp3 temp1.mp3 temp2.mp3


posterising one of my 4 colour pen sketches:

1) enhance using Shotwell (may help)

2) mogrify daniel3-*.jpg -scale 50% +dither -posterize 2


Printing "oversize" PDF forms, etc (where bits get cropped in printing)

1. use Adobe Reader and in Print, use a page size of A4-marginless.

2. use jpdftweak, and page size legal (gives more white space, but cannot

open password locked PDFs).

to use a script to "cd", you need to . or source the file, not run it.


ncdu, great for seeing diskusage tree - lean and light,

can cleanup in separate shell


LibreOffice spell not working


cleaning up a text file that file reports as DATA

tr -cd '\11\12\15\40-\176' < dirtyfile > cleanfile


pdftk, very useful for reordering pages and even rotating them, as for folded booklets

eg, pdftk JohnsGospel4.pdf cat 1S 4S 2 3 output JohnsGospel4booklet.pdf makes a 4 page A6 folded booklet from a four page original.


Linux mint 14 - getting scanner to work

simple scan reports "no scanners detected"


#clearing the FireFox cache

#!/bin/sh

cd ~/.mozilla/firefox

# find the mozilla profile folder

FOLDER=`awk -F= ' /Path/ {print $2}' profiles.ini`

echo $FOLDER

# clear the cache

cd $FOLDER

rm -rf Cache/*

rm -rf minidumps/*

rm -rf startupCache/*

rm -rf thumbnails/*


deleting Trash, Ubuntu 12.10

rm -rf ~/.local/share/Trash/*


Setting up SSH for auto login

[SOLVED] Ubuntu : Agent admitted failure to sign using the key." problem.

This are the steps to access other server with keys

At client

ssh-keygen -t rsa

scp .ssh/id_rsa.pub server:

(ftp is fine too)

At users home on server

mkdir .ssh

chmod 0700 .ssh

cp id_rsa.pub .ssh/authorized_keys

chmod 0600 .ssh/authorized_keys

At client, now login to the server with password then logout and run :

ssh-add


Impress - edit (rh click) master page to change default fonts

Can also F11, right click on eg "title" and change default


#convert MOV to MP4

for fl in YOURMOVFILE.MOV

do

mencoder ${fl} -o ${fl/mov/avi} -oac mp3lame -ovc lavc

mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile ${fl/mov/mp3} ${fl/mov/avi}

#rm ${fl/mov/avi}

done

then use avidemux to expand 2:1 if nec, and convert to MP4, etc


# printing photos

20150828 - nogo use gwenview, landscape, 4x6 photo paper, auto scale and enlarge smaller

---

Shotwell viewer is good too - 20150828 - works fine, but needed to select Photo tray as source for each job. Landscape, source photo tray, image set to fill page, media size set to plain 4"x6" photo, quality to high res. photo.

NOTE: CHECK CARTRIDGES FIRST, RUN CLEAN PRINT HEAD


# copying DVD Nov 2010

used DVD Movie Backup to create iso file

used K3B to burn to single sided DVD-R

Dec 2015 - DeVeDe app works well, to make iso and burn same


# mov to avi

mencoder -of avi -oac pcm -srate 48000 -af resample=48000:0:2 -ovc lavc -lavcopts vcodec=mjpeg inputfile.mov -o outputfile.avi


# avi to mpeg

mencoder input.avi -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 -o output.mpg -oac lavc -ovc lavc -lavcopts acodec=mp2:abitrate=224:vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2:aspect=4/3


# resample MP3 using LAME (shrunk 48MB to 9 and still OK for voice)

lame --resample 16 input.mp3 output.mp3


# convert images to a max size (and leave smaller ones alone)

convert deltamodel2.jpg -resize '640x480>' junk2.jpg

mogrify -resize '640x480>' duckchaser1-*.jpg


# add mp3 to K3B

apt-get install libk3b6-extracodecs


# convert mp3 to ogg (K3B sometimes won't handle MP3)

sox qaz.mp3 qaz.ogg


# split ogg or mp3

mp3splt -t 5.00 qaz.ogg


# "host error" opening Audacity

# killall esd first


# Impress looping slideshow - set time in auto to 00:00:00


DVD tools


Complete Example

This example explains how to use dir2slideshow, dvd-slideshow, and dvd-menu together to create a complete DVD.

* Using dir2slideshow

* Creating slideshow with dvd-slideshow

* Creating menu with dvd-menu

This example is designed to show how to make a simple dvd slideshow from start to finish. I'm assuming you have installed all the required packages first.

Let's assume we have a directory with a bunch of pictures that we want to use in a slideshow. The directory is called "my_pictures".

Use the dir2slideshow script to quickly generate an appropriate listing of the pictures in "my_pictures". We want each picture to be displayed for 5 seconds before going on to the next picture. The name of the slideshow will be "Complete example":

> dir2slideshow -n 'Complete example' -t 5 my_pictures

This will generate an output file "Complete_example.txt" that looks like this:

title:5:Complete example

fadeout:1

background:1

fadein:1

my_pictures/pano.jpg:5:

my_pictures/picture1.jpg:5:

my_pictures/picture2.jpg:5:

fadeout:1

background:1

This will be the input file to dvd-slideshow. If you want to do anything fancy, you could edit this text file by hand at this point. We won't bother since this is a simple example. We want to name the slideshow "test complete", and add some simple audio during the slideshow:

> dvd-slideshow -n 'test complete' -f Complete_example.txt -a 'strojovna_07-TEXEMPO-30s.ogg'

You'll see the program display the progress, and assuming there are no errors, it will finish by producing the following files in the current directory:

test_complete.xml

test_complete.vob

The mpeg file is the actual video file that you can check to make sure it looks ok. Use mplayer or your favorite video player:

> mplayer test_complete.vob

Make sure everything looks ok. At this point, you could repeat this process on a different directory to generate a new slideshow, where we'd get a new set of .xml and .vob files corresponding to that slideshow, but let's keep it simple for now with just one.

The .xml file is fairly simple. It contains the chapter information and the name of the mpeg file that you just created. It is used when making a dvd button menu with dvd-menu.

To create a dvd navigation menu, call dvd-menu with the dvd title "Complete Example DVD", creating two buttons labelled "My example" and "Slideshow 2" which both point to the same video, test_complete.vob:

> dvd-menu -t 'My example' -t 'Slideshow 2' -f test_complete.xml -f test_complete.xml -n 'Complete Example DVD'

This command will write the output (real dvd filesystem) in the directory "dvd_fs". After the dvd-menu script finishes, you can check out your final dvd with xine using the command:

> xine -g -u 0 dvd:"`pwd`/dvd_fs/"

or for those using Totem:

> totem dvd:"`pwd`/dvd_fs/"

Now you may want to have a backup copy of all the original pictures that went into your slideshow on the dvd. Before making the dvd-compatible UDF filesystem, you can copy other stuff into the top-level of your dvd:

> cp -a my_pictures dvd_fs

The -a option copies recursively and keeps the date the same. Note that you can use the "-c" option in dvd-slideshow to perform this same function! Now, in the dvd_fs directory, it looks like this:

> ls -F

AUDIO_TS/ my_pictures/ VIDEO_TS/

The AUDIO_TS/ and VIDEO_TS/ directories are required by the dvd video standard, and contain all of the menus and video that will be used when you put this dvd into your home dvd player. If you mount it on your computer, you'll see the filesystem above.

Now let's create a dvd-compatible UDF filesystem that we can burn to a real dvd:

> mkisofs -dvd-video -udf -o dvd.iso dvd_fs

This will create the iso image dvd.iso that you can burn to a real dvd with dvdrecord. You could have also used the "-iso" option in dvd-menu to automatically create the iso image at the end of the dvd-menu script. I'm assuming that you've already found out which device your dvd recorder is on with "dvdrecord –scanbus" or equivalent. Mine is device number 1, hence the dev=0,1,0.

> dvdrecord -v -eject -dao speed=4 dev=0,1,0 dvd.iso

When finished, try it out in your computer or home dvd player!


Recording with Audacity - Ubuntu 10.4

1. click on the volume control in the toolbar of Ubuntu

2. Sound Preferences

3. select line-in

4. un-mute

Save

Open Audacity

1. set input and output to ALSA:pulse

2. file new

3. record


using a ball mouse as a water level gauge:

host puffin with xset m 0 gives 55mm horizontal movement of optical mouse for full width traverse, = to 65:1 for 1800mm water depth in tank (at half screen for full height of tank).


(not sure if DHCP as never shown in routers DHCP table, but
reserved just in case)
(not sure if DHCP as never shown in routers DHCP table, but
reserved just in case)

Home... Help... Search... Computers...


This page http://tardus.net/bits.html Last published: 2017-08-27

About Tardus

Contact me, "Tardus" Copyright powered by txt2tags

Search tardus.net