Search

Loading...

Thursday, June 23, 2016

Pearl Audio Converter in Nautilus

sudo apt-get install pacpl

Create a file to ./local/share/nautilus/scripts with the below content


gedit ./local/share/nautilus/scripts/pearl-audio-convert

then paste:



#!/usr/bin/perl
#
# Copywrite (C) Philip Lyons 2013-2014 (vorzox@gmail.com)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use warnings;
use File::Spec::Functions qw(rel2abs);

my $debug = 0;
my $input = '';

my $name = "Perl Audio Converter";

my $formats = "FALSE 3G2 FALSE 3GP FALSE 8SVX FALSE AAC FALSE AC3 FALSE ADTS FALSE AIF FALSE AIFF FALSE AL FALSE AMB FALSE AMR FALSE APE FALSE AU FALSE AVR FALSE BONK FALSE CAF FALSE CDR FALSE CVU FALSE DAT FALSE DTS FALSE DVMS FALSE F32 FALSE F64 FALSE FAP FALSE FLA FALSE FLAC FALSE FSSD FALSE GSRT FALSE HCOM FALSE IMA FALSE IRCAM FALSE LA FALSE M4A FALSE MAT FALSE MAT4 FALSE MAT5 FALSE MAUD FALSE MMF FALSE MP2 FALSE MP3 FALSE MP3HD FALSE MP4 FALSE MPC FALSE MPP FALSE NIST FALSE OFF FALSE OFR FALSE OFS FALSE OGA FALSE OGG FALSE OPUS FALSE PAF FALSE PRC FALSE PVF FALSE RA FALSE RAW FALSE RF64 FALSE RM FALSE SD2 FALSE SF FALSE SHN FALSE SMP FALSE SND FALSE SOU FALSE SPX FALSE TTA FALSE TXW FALSE VMS FALSE VOC FALSE W64 FALSE WAV FALSE WMA FALSE WV";

# main sub
sub process_files {

  # sort through input files and discard those with unsupported formats (excluding directories)
  foreach (@ARGV) {

          chomp($_);

          $_ = rel2abs($_);

          my $input_ext = `echo \"$_\" | awk -F"." '{print \$NF}'`;
          print "\"$_\" has the ext $input_ext\n" if $debug == 1;
         
          if (-f $_ and not `pacpl --formats | grep $input_ext`)
          {
             print "$_ has unrecognized extension, skipping...\n" if $debug == 1;
            `notify-send \"$name\" \"Unable to convert $_ (unsupported format)\"`;
             next;
          }
          else
          {            
             $input = "$input \"$_\"";
          }
  }      
 
  # invoke pacpl and start conversion process
  if ($input) {

      my $out_format = `zenity --title \"$name\" --width 250 --height 300 --list --radiolist --column 'Select' --column 'Output Format' $formats`;
   
      chomp($out_format);
     
      print  "pacpl --to $out_format $input --gui --gnome\n" if $debug == 1;
      system("pacpl --to $out_format $input --gui --gnome");
  }
 
}

# start main
process_files();

Sunday, June 19, 2016

Install k9copy from ppa

K9COPY  is the only DVD-Shrink Linux alternative.

sudo add-apt-repository ppa:tomtomtom/k9copy
sudo apt-get update
sudo apt-get install k9copy

(say Yes and y to confirm unsigned ppa) 

Monday, March 28, 2016

Add Internet Download Manager to Firefox & Flashgot



Using Wine (without Playonlinux)

  1. Wine 1.7.4.x at least is needed

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update



     2. Install or update Wine.

     3. Install IDM (tested 1.7)

     4. To add to Flashgot - open about:config in Firefox address bar and search for "wine". Now Toggle the value of Flashgot.useWine to true.

After restarting Firefox, the downloader will appear integrated to Flashgot.


Using Playonlinux

1. Install a non-listed program.

2. Be sure you use the latest Wine.

3. After installing IDM, follow first part of step 4 from above (about:config in Firefox set  Flashgot.useWine to true).

4. Add to Flashgot with the name IDMan 

5. link to executable /usr/share/playonlinux/playonlinux

6.  add --run IDMan %F /d [URL] under 'Command line arguments template.

Wednesday, March 23, 2016

Flash up-to-date in Firefox

sudo add-apt-repository ppa:itachi-san/freshplayerplugin && sudo apt-get update && sudo apt-get install freshplayerplugin

Friday, March 11, 2016

Avoid laptop wake-up from suspended state with lid closed


As suggested here, point (2), and in the answers under this question here (here using Gedit as text editor):
sudo gedit /etc/systemd/logind.conf
There should be a line

 # HandleLidSwitch=suspend

Uncomment that, that is,  remove the # before HandleLidSwitch=suspend
and save.

Tuesday, February 16, 2016

Create pdf from context menu with pdf-generate

Source.



sudo apt-get install imagemagick unoconv ghostscript zenity libfile-mimeinfo-perl
 
 
 
 gedit ~/.config/pdf-generate.conf
 
 
And paste this:


[general]
compression=95 
density=200


So if you want to modify any default parameter, just edit this file before running the tool.

 Main script in charge of the PDF generation k=job should be placed under /usr/local/bin/pdf-generate. See source link to see its content. (Also here.)


# mkdir --parents $HOME/.config
# wget --header='Accept-Encoding:none' -O $HOME/.config/pdf-generate.conf https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/pdf-generate.conf
# sudo wget --header='Accept-Encoding:none' -O /usr/local/bin/pdf-generate https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/pdf-generate
# sudo chmod +x /usr/local/bin/pdf-generate
 
In case that expires:

sudo gedit /usr/local/bin/pdf-generate



and paste this:


#!/bin/bash
# --------------------------------------------
#  Generate a PDF document from a given list of documents
#  Documents are added in final document following
#  alphabetical order
#
#  Setup procedure : http://bernaerts.dyndns.org/linux/74-ubuntu/338-ubuntu-generate-pdf-from-documents
#
#  Depends on :
#   * imagemagick
#   * unoconv
#   * ghostscript
#   * mimetype
#
#  Parameters : full path of documents
#
#  Revision history :
#   05/07/2015, V1.0 - Creation by N. Bernaerts
#   15/08/2015, V1.1 - Force jpeg quality to 95
#   25/09/2015, V1.2 - Add configuration file
#   02/10/2015, V2.0 - Code rewrite to handle progress and notification
# ---------------------------------------------------

# -------------------------------------------------------
# check tools availability
# -------------------------------------------------------

command -v bc >/dev/null 2>&1 || { zenity --error --text="Please install bc"; exit 1; }
command -v mimetype >/dev/null 2>&1 || { zenity --error --text="Please install mimetype"; exit 1; }
command -v convert >/dev/null 2>&1 || { zenity --error --text="Please install convert [imagemagick]"; exit 1; }
command -v unoconv >/dev/null 2>&1 || { zenity --error --text="Please install unoconv"; exit 1; }
command -v gs >/dev/null 2>&1 || { zenity --error --text="Please install gs utility [ghostscript]"; exit 1; }

# ---------------------------------------------------------
#   Read and calculate parameters from configuration file
# ---------------------------------------------------------

# Configuration file : ~/.config/pdf-generate.conf
FILE_CONF="$HOME/.config/pdf-generate.conf"

# check configuration file
[ -f "$FILE_CONF" ] || { zenity --error --text="Please create and configure ${FILE_CONF}"; exit 1; }

# Load configuration file
COMPRESSION=$(cat "${FILE_CONF}" | grep "compression" | cut -d'=' -f2)
DENSITY=$(cat "${FILE_CONF}" | grep "density" | cut -d'=' -f2)

# calculate page size
PAGE_WIDTH=$(echo "${DENSITY} * 8.27" | bc)
PAGE_HEIGHT=$(echo "${DENSITY} * 11.7" | bc)

# -------------------------------------------------------
#          Retrieve or select input files
# -------------------------------------------------------

# set separator as carriage return
IFS=$'\n'

# loop thru arguments to load candidate files
for ARGUMENT
do
  [ -f "${ARGUMENT}" ] && ARR_FILE=("${ARR_FILE[@]}" "${ARGUMENT}")
  [ -d "${ARGUMENT}" ] && ARR_FILE=("${ARR_FILE[@]}" $(find "${ARGUMENT}" -maxdepth 1 -type f) )
done

# if there is no candidate files, open selection dialog
if [ ${#ARR_FILE[@]} -eq 0 ]
then
  # open multiple files selection dialog box
  LST_FILE=$(zenity --file --multiple --title="Select file to merge as PDF")

  # generate video files array
  ARR_FILE=($(echo "${LST_FILE}" | tr "|" "\n"))
fi

# -------------------------------------------------------
# loop thru selected files to check convertibility
# -------------------------------------------------------

for FILE in "${ARR_FILE[@]}"
do
  # document type undefined
  DOCTYPE=""

  # get the file mime type (application/msword, ...)
  MIMETYPE=$(mimetype -b "${FILE}")

  # check if file is a image file (.jpg, .png, .tiff, ...)
  CHECKTYPE=$(echo "${MIMETYPE}" | grep "image/")
  [ "${CHECKTYPE}" != "" ] && DOCTYPE="image"

  # check if file is a libreoffice file (.odt, .ods, ...)
  CHECKTYPE=$(echo "${MIMETYPE}" | grep ".opendocument.")
  [ "${CHECKTYPE}" != "" ] && DOCTYPE="libreoffice"

  # check if file is a microsoft file 2007+ file (.docx, .xlsx, .pptx, ...)
  CHECKTYPE=$(echo "${MIMETYPE}" | grep "vnd.openxmlformats-officedocument.")
  [ "${CHECKTYPE}" != "" ] && DOCTYPE="ms-office"

  # check some specific document types
  case $MIMETYPE in
    # ms-office document (.doc, .xls, .ppt, ...)
    "application/msword" | "application/vnd.ms-word" | "application/vnd.oasis.opendocument.text" | \
    "application/vnd.ms-excel" | "application/vnd.ms-powerpoint" )
      DOCTYPE="ms-office"
      ;;

    # PDF document (.pdf)
    "application/pdf" | "application/x-pdf" | "application/x-bzpdf" | "application/x-gzpdf" )
      DOCTYPE="pdf"
      ;;

    # plain text file (.txt)
    "text/plain" | "application/x-shellscript" )
      DOCTYPE="text"
      ;;

    * )
      ;;
  esac

  # if document type is compatible, add current file as candidate
  [ "${DOCTYPE}" != "" ] && ARR_CANDIDATE=("${ARR_CANDIDATE[@]}" "${FILE}|${DOCTYPE}")

done

# -------------------------------------------------------
#       Confirmation dialog box
# -------------------------------------------------------

# calculate number of files to convert
NBR_FILE=${#ARR_FILE[@]}
NBR_CANDIDATE=${#ARR_CANDIDATE[@]}

# if some candidate file exist, order them and display confirmation dialog
if [ ${NBR_CANDIDATE} -gt 0 ]
then
  # order generated PDF files in alphabetical order
  ARR_CANDIDATE=($(sort <<<"${ARR_CANDIDATE[*]}"))

  # generate final file name
  FILE=$(echo "${ARR_CANDIDATE[0]}" | cut -d'|' -f1)
  FILE_FINAL="$(echo "${FILE}" | sed 's/^\(.*\)\..*$/\1/')-merged.pdf"

  # display confirmation dialog box
  RESULT=$(zenity --question --title="Merge to PDF" --text="${NBR_CANDIDATE} file(s) out of ${NBR_FILE} will be merged to a single PDF file (${DENSITY} DPI)\n\nDo you want to generate ${FILE_FINAL} ?" )
  ACTION=$?

# else display error dialog
else
  # display confirmation dialog box
  RESULT=$(zenity --error --title="Merge to PDF" --text="There is no file compatible with PDF format." )
  ACTION=""

fi

# if action canceled or error, exit
[ "${ACTION}" != "0" ] && exit 1

(

# -------------------------------------------------------
# loop thru candidate files to convert them to PDF
# -------------------------------------------------------

for CANDIDATE in "${ARR_CANDIDATE[@]}"
do
  # retrieve document type and filename
  FILE=$(echo "${CANDIDATE}" | cut -d'|' -f1)
  DOCTYPE=$(echo "${CANDIDATE}" | cut -d'|' -f2)

  # progress display
  echo "# Conversion of ${FILE}"

  # get file name without extension & generate resulting PDF file name
  FILE_BASE="$(echo "${FILE}" | sed 's/^\(.*\)\..*$/\1/')"
  FILE_PDF="${FILE_BASE}.pdf"

  # convert file according to its type
  case $DOCTYPE in
    # PDF files
    "pdf" )
    ARR_PDF=("${ARR_PDF[@]}" "${FILE}")
    ;;

    # image files
    "image" )
    convert "${FILE}" -compress jpeg -quality ${COMPRESSION} -resize ${PAGE_WIDTH}x${PAGE_HEIGHT} -gravity center -extent ${PAGE_WIDTH}x${PAGE_HEIGHT} -units PixelsPerInch -density ${DENSITY}x${DENSITY} "${FILE_PDF}"
    ARR_TMP=("${ARR_TMP[@]}" "${FILE_PDF}")
    ARR_PDF=("${ARR_PDF[@]}" "${FILE_PDF}")
    ;;

    # office files
    "libreoffice" | "ms-office" | "text" )
    unoconv -f pdf -o "${FILE_PDF}" "${FILE}"
    ARR_TMP=("${ARR_TMP[@]}" "${FILE_PDF}")
    ARR_PDF=("${ARR_PDF[@]}" "${FILE_PDF}")
    ;;

    # other formats, not handled
    * )
    ;;
  esac

done

# -------------------------------------------------------
#   Final merge
# -------------------------------------------------------

if [ ${#ARR_PDF[@]} -gt 0 ]
then
  # progress display
  echo "# Final assembly of ${FILE_FINAL}"

  # generate resulting PDF
  gs -q -dNOPAUSE -dBATCH -dSAFER -sPAPERSIZE=a4 -dPDFFitPage -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile="${FILE_FINAL}" ${ARR_PDF[@]}
fi

# -------------------------------------------------------
#   Temporary files clean-up
# -------------------------------------------------------

# loop to remove temporary files
for TMP_FILE in "${ARR_TMP[@]}"
do
  rm "${TMP_FILE}"
done

) | zenity --width=500 --height=25 --progress --pulsate --auto-close --title "Merge to PDF"

# -------------------------------------------------------
#   End of job notification
# -------------------------------------------------------

[ ${#ARR_CANDIDATE[@]} -gt 0 ] && zenity --notification --window-icon="evince" --text="${FILE_FINAL} generated." \
                               || zenity --notification --window-icon="error" --text="Document type was not compatible for PDF generation."






Then make it executable:

sudo chmod +x /usr/local/bin/pdf-generate


To fully integrate this PDF generation tool in your desktop environment:
gedit /usr/share/applications/pdf-generate.desktop. 
 
 
Nautilus-Gnome content:
 
 
 [Desktop Entry]
Type=Application
Exec=pdf-generate
Hidden=false
NoDisplay=false
Icon=evince
Keywords=pdf;generate;image;office;document;merge
X-GNOME-Autostart-enabled=true
Name[en_US]=Generate PDF document
Name[en]=Generate PDF document
Name[C]=Generate PDF document
Name[fr_FR]=Génération d'un PDF
Comment=Tool to merge a set of documents to a PDF file.
Comment[en_US]=Tool to merge a set of documents to a PDF file.
Comment[fr_FR]=Outil de concaténation de documents en un fichier PDF.
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;application/pdf;application/x-pdf;application/x-bzpdf;application/x-gzpdf;application/msword;application/vnd.ms-word;application/vnd.oasis.opendocument.text;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;text/plain;
Categories=GNOME;GTK;Graphics;Conversion;Utility;

 KDE-Dolphin content

[Desktop Entry]
Actions=pdf-generate
Encoding=UTF8
Icon=pdf
MimeType=MimeTypes=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;application/pdf;application/x-pdf;application/x-bzpdf;application/x-gzpdf;application/msword;application/vnd.ms-word;application/vnd.oasis.opendocument.text;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;text/plain;inode/directory;application/pdf
ServiceTypes=KonqPopupMenu/Plugin,image/jpeg
Type=Service
#X-KDE-Submenu=Convert all in folder

[Desktop Action pdf-generate]
Exec=pdf-generate %F
Icon=pdf
Name=Create pdf file


To get a full desktop integration, this PDF generation tool should be available from a custom action in your file manager context menu.

For Nautilus you need to declare the new custom action in a .desktop file placed under ~/.local/share/file-manager/actions

[Desktop Entry]
Type=Action
Icon=evince
Name[C]=Generate PDF document
Name[en]=Generate PDF document
Name[en_US]=Generate PDF document
Name[fr_FR]=Génération d'un PDF
Tooltip[C]=Tool to merge a set of documents to a PDF file
Tooltip[en]=Tool to merge a set of documents to a PDF file
Tooltip[en_US]=Tool to merge a set of documents to a PDF file
Tooltip[fr_FR]=Outil de concaténation de documents en un fichier PDF
Profiles=pdf_generate;

[X-Action-Profile pdf_generate]
Exec=pdf-generate %F
MimeTypes=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;application/pdf;application/x-pdf;application/x-bzpdf;application/x-gzpdf;application/msword;application/vnd.ms-word;application/vnd.oasis.opendocument.text;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;text/plain;inode/directory;
Name[C]=Default profile
Name[en]=Default profile
Name[en_US]=Default profile
Name[fr_FR]=Profil par défaut

 For Dolphin/KDE it is in ~/.kde/share/kde4/services/ServiceMenus/

 Therefore,


gedit ~/.kde/share/kde4/services/ServiceMenus/pdf-generate.desktop

with the content:
 
[Desktop Entry]
Actions=pdf-generate
Encoding=UTF8
Icon=pdf
MimeType=MimeTypes=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;application/pdf;application/x-pdf;application/x-bzpdf;application/x-gzpdf;application/msword;application/vnd.ms-word;application/vnd.oasis.opendocument.text;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;text/plain;inode/directory;application/pdf
ServiceTypes=KonqPopupMenu/Plugin
Type=Service


[Desktop Action pdf-generate]
Exec=pdf-generate %F
Icon=pdf
Name=Create pdf file
 After re-login, a context menu option will appear for selected files as indicated in the source link. For my KDE/Dolphin configuration, this works for selected files if they have the same extension. Otherwise, the best way it just to put all needed files in one folder and then execute the command from the right-click context menu of that folder.

Also here.


Wednesday, January 27, 2016

Fix internet (google, gmail) fonts

  •  Firefox:
Enter about:config in the address bar.

Search for gfx.downloadable_fonts.enabled and change this flag to false. This option will be saved to your ~/.mozilla/firefox/prefs.js file which will then be loaded every time your start your browser.

  • Chrome:
Launch Chrome from the command line:

google-chrome --disable-remote-fonts