Thursday, November 17, 2011

Debian/Ubuntu markauto cleanup script.


The Debian installer has a bad habit of marking packages 80% of packages as manually installed which causes a horrible dependency issue.

The script below lists packages which if marked automatically installed wont be removed. This also prevents listing of packages which are having important priority.


#! /bin/bash



# Script to print packages which if marked as installed automatically will not be removed (cause its it's a dependency of another manually installed package)

# This may give wrong output in circular dependencies, cause -

# aptitude why A -- B depends/recommends A

# aptitude why B -- A depends/recommends B

# this means both A and B will be included.

# in this case, one or both of them will have to be manually installed

list="$(aptitude search '~i' | grep --invert-match '..A' | cut -d ' ' -f4)"

# function to cut first line in variable list.

cut_first() {

 list="$(echo "$list" | tail -n +2)"

}

while [[ "$list" != "" ]]

do

 process="$(echo "$list" | head -1)"

 aptitude why $process | grep --ignore-case --regexp="recommends" --regexp="depends" &> /dev/null

 if [[ $? == 0 && "$(aptitude show "$process" | grep --ignore-case --regexp="Priority: required" --regexp="Priority: Important")" == "" ]]

 then

  echo "$process"

 fi

 cut_first

done



Before you use -- I warn, check if the package list is correct, to confirm, all packages if marked auto should not remove any packages as vacant dependencies.

After this you can have a clean system where you can check if the manually installed packages are ok or not.

Tuesday, November 15, 2011

ffmpeg -- maintain aspect ratio with fixed height/width.

I found this in the ffmpeg man pages; 99% users thing this's not possible, but it is possible without   calculating aspect ratio in mind.

Use the scale filter before specifying the input file -

-vf scale=www:www/a

Where 'www' is the desired width of the video you want. To maintain the height - 

-vf scale=hhh*a:hhh

Where hhh is the desired height you want.

Friday, November 11, 2011

Openoffice/libreoffice template pack.

Recently I'd downloaded all templates from templates.services.openoffice.org, so I decided to share all of them -- 


http://www.4shared.com/file/5DJTQ488/templates.html 


 Extract the file, you'll find 4 more archives with names to that of openoffice/libreoffice applications, extract them too to get the templates for the respective applications. 


 You may install the usual way using the templates organizer dialog, as an alternative you may place the extracted folders to ~/.libreoffice/3/user/template, the folders will act as categories of the templates (i.e. in the organize folder dialog, you'll see these folders and inside them will lie the templates). 


 Notice, these are a lot of templates, so opening the templates list in openoffice/libreoffice might take a long time.

Sunday, November 6, 2011

Gentoo splashscreen howto (with/without KMS)

To see a splash screen as you open Gentoo, you need something called the 'frame buffer'...this is basically a driver which has the ability to display video from the text-only console. This's usually generic and not accelerated, i.e. does not take up the unique features of the graphic chip, although we do have a bit of acceleration or device dependent framebuffers.

Framebuffers are involved in making of the console (or Ttys), since Fbs also have a resolution and you can even set the resolution, consoles too have a resolution which can be set by passing kernel parameters. The parameters dependents on the FB driver.

Different framebuffer -- Vesa, Userspace-vesa (generic Fbs), radeonfb, radeondrmfb, inteldrmfb etc....

So first you need to compile your kernel with support of some FBs.
If you're using KMS, you don't need to mark any framebuffer, KMS provides it's own framebuffer. Once the DRM modules load, a FB is provided. If you have compiled the kernel with other Fbs, it'll replace the FB with it's own. This KMS FB is hardware specific and fast. You cant use both KMS FB and other FBs -- only 1 will work.

The mandatory sections to be selected in kernel are -

CONFIG_FB (in Device drivers>graphs support). In that, select -

CONFIG_FIRMWARE_EDID (Support for frame buffer devices>Enable firmware EDID)

you can select which frame buffer support you will compile in -

*** Frame buffer hardware drivers ***

(not required if you're a KMS user)

If you wanna use vesafb, mark it.

In “Console display driver support” which is in Graphs support -

Support for the Framebuffer Console Decorations (CONFIG_FB_CON_DECOR) -- this option wont be available until you apply the fbcondecor patch or install gentoo-sources. Get it from -


Apart from these, select

VGA text console (CONFIG_VGA_CONSOLE)

CONFIG_VGA_CONSOLE (Framebuffer Console support)

Map the console to the primary display 
(CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY)

Disable “Enable Tile Blitting Support” (CONFIG_FB_TILEBLITTING)

Which is in Support for frame buffer devices.

Compile and install the kernel.

Now emerge splashutils with fbcondecor, png and truetype USE flags enabled.

Splashutils is a cross distro method to implement splash screen, but it requires an init script but only if you want userspace splash, thus this needs to be made for every fundamental distro.

Splashutils requires some kind of framebuffer to be present to work -- any will work, it has the ability to start from the initrd.

Splashutils themes are set in 2 options, one verbose where you will get some sorta decoration with the output messages (a decorated console), and the other silent...windows and Ubuntu style.

Splashutils can start from 2 modes -- one initrd, where it start right from the beginning and the other from userspace, i.e. it start after init has started. Thus an initrd is completely optional but you don't get early bootsplash.

This packages give you 2 main applications -

splash_geninitramfs and splash_manager

There are various themes available in portage -

media-gfx/splash-themes-gentoo, media-gfx/splash-themes-livecd and media-gfx/bootsplash-themes

All themes will be placed in /etc/splash...with their names same as the folders in this directory. Each theme supports different resolutions, most common being 1024x768.

You have to append the following lines in the kernel parameters to configure the FB you intend to use and also define which mode will the splash screen work on, silent or verbose. Apart from this, you also have to define what theme to use (optional for userspace splashscreen).

video= splash=,theme: console=tty1

Out of this, only splash= option is necessary even if you're using the splashscreen that starts after init. Otherwise if the splash start from init, everything is necessary.

Depending on what FB drivers you use, you will have to modify the video= option, I.e apart from specifying the video driver, you have to specific options for the FB driver. From here you can set the resolution of the FB console too.

With vesafb, you have to specify the resolution with various options. These are the defaults and safe -

video=vesafb:mtrr:3,ywrap vga=

The options for vga are (numbers of 3 digits) -

320
×
200
640
×
400
640
×
480
800
×
500
800
×
600
896
×
672
1,024
×
640
1,024
×
768
1,152
×
720
1,280
×
1,024
1,400
×
1,050
1,440
×
900
1,600
×
1,200
1,900
×
1,200
16 colors




770


772

774




256 colors

768
769
879
771
815
874
773
869
775
835
864
796
893
15-bit (5:5:5)
781
801
784
880
787
816
875
790
870
793

865
797

16-bit (5:6:5)
782
802
785
881
788
817
876
791
871
794
837
866
798

24-bit (8:8:8)
783
803
786
882
789
818
877
792
872
795
838
867
799

32-bit (8:8:8)1

804
809
883
814
819
878
824
873
829

868
834

As copied over from wiki.
 
If the number is wrong, the kernel will notify.

e.g. -

video=vesafb:mtrr:3,ywrap vga=795 splash=silent,theme:Cynapses console=tty1

With KMS FB, you have to specify only the resolution with option refresh rate as such -


Where -24 is the refresh rate.

or simply video=1280x1024

The console= option should be set to tty1 (when using initrd based splash) otherwise you will not be able to see the splash.

To preview a theme -

splash_manager --theme=one of the themes in /etc/splash --cmd=set --tty=.

Notice, for the theme to work, the console should be at the right resolution.

This program (splash_manager) revolves around a command -- the command is the task that need to be done, either display, set, demo etc.... themes. To specify the command, do it with the --cmd= option.

The command 'list' displays all the splashes available with resolutions. 'set' displays the decoration of the console and 'demo' will give a demo of the boot screen.

After you have decided what theme you'll use, you have to generate the initial ram image; if you're using initrd based splash, this's not required.

splash_geninitramfs --res --generate .

The --verbose option is useful for debugging.

Each theme supports different resolutions. The resolutions are in the directory /etc/splash/. You can also check it out using the --cmd=list command of splash_manager (as stated before).

If you want to copy the theme to an existing image -

splash_geninitramfs --res 1600x1800 --copy

If you already have a theme in the initial ram image archive, you might just like to append the new theme -

splash_geninitramfs --res 1600x1800 --append

Now you can see the reason behind the theme: kernel parameter, this specifies what splash to use during boot of the multiple available in the kernel.

Also notice, for initrd based splash to work, all the correct kernel modules which're required to make the framebuffer should be built into the kernel or should be there in the initramfs. Also the resolution should be perfect from start.

Userspace splash -

For userspace splash you have to start the service fbcondecor, for automatic startups, add it to the boot or sysinit runlevel. You don't need to do this for init based splash... neither you have to configure the service configurations.

The configuration of this service is done from the conf.d directory and the fbcondecor file. Read the comments in it to configure. The splash style (verbose or silent) is read from the kernel's parameters.

Apart from this, you have to see the file /etc/conf.d/splash for further configuration and the theme you wanna load. It's configuration is mandatory.

Wednesday, November 2, 2011

Huawei EC1260 (12d1:140b) (reliance, tata, MTS etc...) on Linux.

This modem works out of the box. Just ensure to have the usb_modeswitch package installed. lspci output - 


Bus 002 Device 003: ID 12d1:140b Huawei Technologies Co., Ltd. EC1260 Wireless Data Modem HSD USB Card



First you need to install usb-modeswitch, then plug in the modem (or replug the modem), then run (as root) -


wvdialconf



You'll now have a file name /etc/wvdial.conf, edit this as root, enter your username, password (usually anything will work), then the number to be dialed (usually *99# or #777). Uncomment these lines also. In an MTS connection, password is #777, username is internet@internet.mtsindia.in and you gotta dial #777. Here's the wvdial.conf for MTS - 



[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = #777
ISDN = 0
Username = internet@internet.mtsindia.in
Init1 = ATZ
Password = mts
Modem = /dev/ttyUSB0
Baud = 57600



Next run wvdial command, and things should work fine.


As tricks -- in wvdial.conf, increase the BAUD rate to 57600, higher value also works. In case you're using gnome-ppp as the front end, set the modem type to USB modem otherwise you might see lower speeds; I don't know why this happens, although it shouldn't.