Wednesday, January 23, 2013

How to create scripts

A script is a text file containing a command line that can be executed when the script is executed. So, the script file functions as an executable file for the command.

The general form of an executable script is

#!/bin/bash

the-command-line-here

If the command is meant to display an output in a terminal

#!/bin/bash

gnome-terminal -e "the-command-line-here"
But the terminal would close with the command and the output will not be seen. So, go to Edit -> Profile Preferences -> Title. Click the Command tab. Select Hold the terminal from the drop-down menu labelled When command exits.

Useful scripts:
  •  the printer status (outputs 2 numbers if ok)
#!/bin/bash

gnome-terminal -e "/etc/init.d/ccpd status"

Tuesday, January 22, 2013

Remove "People You May Know" in Facebook using Adblock rule



  •  In Firefox.
Install Adblock Plus
Go to its "Filter preferences" (ctrl-shift-F)
Under "Custom filers" - "Add Filter Group"
Rename the group and then to the right - Add filter

The filter to add is:

www.facebook.com##div[class="ego_section"]

  • The same filter can be added in Chrome with Adblock Plus.
  • With AdBlock (not "Plus") in Chrome: add the above line in Options/Customize, under "Manually edit your filters"

Thursday, January 17, 2013

Play internet video in external player

Most internet video cannot be played in external players. But some can.

As most such video is flash, the idea is to play them not  with the flash plugin, but with smplayer or vlc plugins.

Youtube is the most easy to play externally.
SMPlayer has an integrated Youtube Player (smtube) which has a search option.


But this is limited to youtube and the buffering has problems sometimes.

VLC behaves better and seems to be able to play other sources (at least Dailymotion, as far as I can tell). Copy video link and paste in Media - Open network stream.

To automate a bit this operation, add OpenWith addon to Firefox, go to its preferences and add VLC player there,  and then set it to appear in context menu.


 Then search something in Youtube or Dailymotion and in the list with findings right-click and open in VLC.






Monday, January 14, 2013

Remove Lubuntu notifier and replace with Xfce's



Replace Lubuntu's notification system with XFCE's, which won't queue up your notifications, like the default one does. To do that:

sudo apt-get install xfce4-notifyd
sudo apt-get remove notification-daemon
 
When doing it this way, it shouldn't ask to remove all those extra packages, as there will still be a notification system in place. I think it will still say it is uninstalling lubuntu-desktop, but that is because it is a meta package, meaning a package of packages. It won't remove your desktop. :-)

(THIS IS AN ASKUBUNTU ANSWER HERE)

Saturday, January 12, 2013

Add new commands in Thunar context menu

  • Edit/Configure custom actions.
  • Open a folder as root
Opening a root Thunar
Name: Open a root Thunar here
Command: gksu thunar %f
File pattern: *
Appears if selection contains: Directories
  • To add a command that would run a player, examples: 
/opt/deadbeef/bin/deadbeef %F
qmmp %F
/usr/bin/smplayer %f
/usr/bin/vlc %f

  • To lauch a Terminal:
exo-open --working-directory %f --launch TerminalEmulator

  • To open a root Thunar 
gksu thunar %N

  • To convert to png: 
convert %f %f.png

  • To convert pdf to text at this directory level: 
for file in *.pdf; do pdftotext "$file" "$file.txt"; done

  • convert pdf to txt in all directories : 
find . -name '*.pdf' -print0 | xargs -0 -n1 pdftotext

  • delete without recycle:
 rm -r %F

  • secure delete: 
(apt-get install secure-delete)

srm %F
  • shred, wipe:
shred -u %F

  • search with catfish: 
catfish --fileman=thunar –path=%f

  • to join selected text files 
cat %N > JoinedFile

  • To run in a Wine program: 
path/to/script %F

the script should look like:

(example for Foobar2000):

#!/bin/bash

cd ~/.wine/drive_c/"Program Files"/foobar2000/
if [ "$1" != "" ]; then
filename=`echo z:$1 | sed 's/\\//\\\\/g'`
wine foobar2000.exe "$filename" &
else
wine foobar2000.exe &
fi

Edit main menu items with MenuLibre



sudo add-apt-repository ppa:menulibre-dev/devel 
sudo apt-get update
sudo apt-get install menulibre

How to stop program from starting with the system.


Lubuntu's “lxsession-edit” (Desktop Session Settings) cannot add new programs at startup but can remove them.

There are programs that still run at startup without being displayed by this application.

So, go and delete them (their .desktop file) from /etc/xdg/autostart. Take also a look in /etc/xdg/lxsession/Lubuntu/autostart.

Mount point of virtual images

Using AcetoneISO, the path for mounting is /home/user/virtual-drives/1. In case the mount point is not automatically accessed, Acetone can be set to do that: go to File/Options/General options/File manager and select file browser (e.g., Thunar, after having installed it : in Lubuntu/LXDE I do not recommend Nautilus, but Thunar; selecting LXDE in that list seems useless.

Thursday, January 10, 2013

Problem with SMPlayer in Lubuntu

After installing Lubuntu, SMPlayer and Gnome Player would not work because mplayer is not installed yet, but a different application (a fork, mplayer2, with other dependencies).

So, before installing SMPlayer, it is better to get mplayer proper.


sudo apt-get purge mplayer2
sudo apt-get autoremove
sudo apt-get install mplayer gecko-mediaplayer gnome-mplayer

Then install SMPlayer in Synaptic and test it. If sound doesn't work  look in Preferences/General/Audio and switch audio between pulse/alsa.

Create swap after ubuntu installation

For newer version of ubuntu swap is very important. Question is why?

1. On hibernate system save all data from ram to swap.
2. When ram is full, swap is used as a secondary ram

Recently released ubuntu uses caching in ram. It's means save recently closed application data in ram, so that when you will use the application again it can load it quickly. Cache increase performance. For that ram becomes full (2GB or less). When ram fill with cache and system needs more ram it backup old cache in swap. If you don't have a swap then your system behave slow when ram is full.

What happen if you have already installed your system without swap partition? Fortunately ubuntu has option to create a swap as file.

Step 1: Allocate a file  sudo fallocate -l 2048m /mnt/swap_file.swap

Step 2: Change permission sudo chmod 600 /mnt/swap_file.swap

Step 3: Format the file for swapping device  sudo mkswap /mnt/swap_file.swap

Step 4: Add swap  sudo swapon /mnt/swap_file.swap

Step 5: Open fstab  sudo gedit /etc/fstab

Step 6: Add entry in fstab  /mnt/swap_file.swap none swap sw 0 0 


source : here

DeadBeef installation from a deb file

All versions in deb format: here.

Installing from deb seems preferable.

On  installing addons: here.

Launcher for Lubuntu: Synapse


sudo add-apt-repository ppa:synapse-core/ppa
sudo apt-get update
sudo apt-get install synapse

Can be used to search, launch, execute.

Ctrl-Space to run it.

Saturday, January 5, 2013

Record sounds (Deezer, etc) in separate tracks

sudo apt-add-repository ppa:osmoma/audio-recorder
sudo apt-get update
sudo apt-get install audio-recorder


or preferably

sudo apt-add-repository ppa:osmoma/audio-recorder -y && sudo apt-get update && sudo apt-get install audio-recorder -y

 or even better, if apt-fast is installed

sudo apt-add-repository ppa:osmoma/audio-recorder -y && sudo apt-fast update && sudo apt-fast install audio-recorder -y


Start recording while playing Deezer or any sound played by the computer.

If listening to an album and want to get files separated according to the silence between them uncheck the Add option, and then edit Timer, which is a matter of trial an error, and changes should be made from case to case.

A good start would be adding in any case 'start if sound', so that a new file should be created when sound starts; but in order to have a new file (different from the previous sound), first the recorder must be made to stop when there is no sound. 'stop if silence' is not a good option, as it creates a lot of small useless files; a better option is 'stop if silence 1 sec.'; and 'stop if silence 0.5 sec.' may also be a good option. (This should be enough for the stated purpose. Using audio threshold timer commands seems to me more complicated.)



The files are saved in ~/Audio.

Changing volume level during recording is a bad idea, because the recorded sound is distorted.