Tuesday, December 24, 2013

What to do during and after Ubuntu 13.10 installation

Here's the complete workflow I use to set up Ubuntu 13.10:

A. GENERAL CONSIDERATIONS DURING FRESH INSTALLATION
  1. Allocate a 50GB partition and install the system there.

  2. After installation immediately set the root password and create a new user with limited access.
 
  3. Log on as the new limited user and utilize all free disk space to create multiple encrypted partitions.

  4. Restore all backed up data to the encrypted partitions.

B. FIGHTING UBUNTU'S IDIOSYNCRASIES:
  1. Visit fixubuntu.com and copy and execute commands from there. This will disable automatic online search and make several privacy enhancements.

  2. Remap HUD Key which is "left alt" by default to something else
    System settings -> Keyboard > Shortcuts > Launchers -> HUD key -> ctrl-alt-h  

  3. Open Software & Updates and disable multiverse to keep updates light.
 
  4. Modify "security and privacy" settings to your requirements.

  5. Disable paid software as described in another post.
 
  6. Uninstall useless software to keep updates light.
    apt-get autoremove gnome-contacts ubuntuone-control-panel-qt gnome-mines unity-lens-photos aisleriot gnome-mahjongg gnome-sudoku empathy remmina thunderbird vino unity-scope-gdrive rhythmbox totem gnome-control-center-signon gnome-user-share landscape-client-ui-install gnome-orca onboard deja-dup  

C. INSTALL UPDATES AND ESSENTIAL SOFTWARE
  apt-get update && apt-get upgrade
 

  apt-get install geany g++ vlc gimp ghex alarm-clock-applet compizconfig-settings-manager

D. TWEAK GNOME/UNITY 
  1. Get rid of folders cluttering the home folder. To store your personal files use encrypted partitions created earlier.
    rmdir ~/Public/ ~/Documents/ ~/Music/ ~/Pictures/ ~/Videos/ ~/Downloads/ ~/Templates/
    rm ~/examples.desktop
 

  2. If the system text is too small, scale it by an appropriate factor:
    gsettings set org.gnome.desktop.interface text-scaling-factor '1.35' 

  3. If F4 requires Fn+F4, remap close window key to Super-Q: 
    gsettings set org.gnome.desktop.wm.keybindings close "['<Super>Q']" 

  4. Highly recommended: Set bottom left screen corner to initiate window picker.
    $ ccsm
      Advanced Search >>  Scale >> Binding >> Initiate Window Picker >> Bottomleft


  5. Disable gedit as root (we'll be using geany instead):
    cd /usr/bin
    mv gedit gedit.backup
    Right click a .txt file and in its property dialog set default application as geany.
 
E. APPLICATION SPECIFIC MODIFICATIONS   
  1. Make geany more usable:
    Open geany and in preferences dialog:
      unselect interface->show sidebar
      unselect interface->show statusbar
      select editor->features->line wrapping
    In the main menu:
      unselect view->show message window
      unselect view->show toolbar

  2. Add adblock plus plug-in to firefox.
 

Friday, November 15, 2013

Complete Minimal SDL2 OpenGL Animation Program with no memory leaks


#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <iostream>
using std::cout;

int main()
{
  int width = 640, height = 480;
  SDL_Init(SDL_INIT_VIDEO);
  SDL_Window *window = SDL_CreateWindow( "Grapics Application", 0, 0, width, height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
  SDL_GLContext glcontext = SDL_GL_CreateContext(window);
  cout << "OpenGL Version " << glGetString(GL_VERSION) << "\n";
  glClearColor(0,0,0,1);
  glViewport( 0, 0, width, height );
  glFrustum( -1, 1, -(float)height/width, (float)height/width, 1, 500 );
  SDL_Event event;
  while( 1 )
  {
    while( SDL_PollEvent( &event ) )
    {
      switch( event.type )
      {
        case SDL_WINDOWEVENT:
          if( event.window.event == SDL_WINDOWEVENT_RESIZED )
          {
            glViewport( 0, 0, event.window.data1, event.window.data2 );
            glLoadIdentity();
            glFrustum( -1, 1, -(float)event.window.data2/event.window.data1, (float)event.window.data2/event.window.data1, 1, 500 );
          }
          break;
        case SDL_QUIT: SDL_GL_DeleteContext(glcontext); SDL_DestroyWindow(window);SDL_Quit(); return 0;
      }
    }
  static float delta = 0;
  delta += 0.002;
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_TRIANGLES);
  glVertex3f( delta, 0, -5 );
  glVertex3f( 1+delta, 0, -5 );
  glVertex3f( delta, 1, -5 );
  glEnd();
  SDL_GL_SwapWindow(window);
  SDL_Delay(20);
  }
}

Tuesday, October 22, 2013

Changing the world: Python and XML

Although I have occasionally used Python and I program in C++ 100% of time, if I were to rule the world I would issue an ultimatum to all programming languages to conform to Python syntax within 5 years after which all backward compatibility will be dropped! Python offers a terse human readable syntax.

Now for a verbose machine readable syntax which is still very human friendly, I would choose XML. So again, Latex gets five years to confom to Python (terse) or XML (verbose) or both flavors.

The idea is that we can keep on complicating things in the pretext of simplifying them.

For example, for all publishing needs we can rely on Python and XML syntax, syntax highlighting text editors (Vim for shell and Geany for GUI), PNG format for images and bzip2 to package all the stuff in a single file ready to be dispatched to a printer or a projector via a rendering application. This can unify and simplify hardware, software and application design.

Thursday, September 19, 2013

Show only "Free" software in Ubuntu Software Center

In other words, "How to prevent paid software from being listed in Ubuntu Software Center"


Follow three simple steps as root:

1. In the file
/usr/share/software-center/softwarecenter/db/update.py
 
somewhere near line 480 find the following lines and add the highlighted line:
 
        doc = self.make_doc(cache)
        if not doc:
            LOG.debug("%r.index_app_info: returned invalid doc %r, ignoring.",
                      self.__class__.__name__, doc)
            return
        name = doc.get_data()

        if doc.get_value(XapianValues.PRICE) not in (""): return
        if name in seen:
            LOG.debug("%r.index_app_info: duplicated name %r (%r)",
                      self.__class__.__name__, name, self.desktopf)
        LOG.debug("%r.index_app_info: indexing %r",
                  self.__class__.__name__, name)
        seen.add(name)
  
2. In the file 
/usr/share/software-center/softwarecenter/backend/channel_impl/aptchannels.py
 
find the following lines and commentize the highlighted lines:

        if partner_channel is not None:
            channels.append(partner_channel)
        #if get_distro().PURCHASE_APP_URL:
        #    channels.append(for_purchase_channel)
        if new_apps_channel is not None:
            channels.append(new_apps_channel) 
3. Issue the command:
# update-software-center
 
4. Also disable "multiverse" from "Software and Updates" settings panel.

Friday, August 30, 2013

Some essential remapping of shortcut keys on Ubuntu

Since Ctrl-W is most widely used shortcut to close tabs I find it was a very short sighted decision  to map Super-W to launch window picker in Ubuntu.

Hence I have mapped window picker to Alt-E key combination as follows:

1. Install Compiz Config Settings Manager:

# apt-get install compizconfig-settings-manager

2. Launch compiz config settings manager as "normal" user:

$ ccsm

In the panel that pops up, follow

Advanced Search >>  Scale >> Binding >> Initiate Window Picker

Remap the key binding to Alt-E


Using Super-Q to close a window rather than Alt-F4

Execute following command (Ubuntu 13.04 or Fedora 19)

gsettings set org.gnome.desktop.wm.keybindings close "['<Super>Q']"

Installing Ubuntu on a fresh system

Ubuntu 13.04

1. Download the iso file and create a live bootable USB stick (http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows).

2. Boot the system using the USB stick and install Ubuntu in a 50 GB or 15% of total capacity of your hard disk, whatever is greater. Create a swap equal to installed memory but do not create any partitions at present. Leave rest of the disk free.

3. Log on to new user and create two (or more) encrypted partitions.

4.  Open software center and uninstall useless software.

5. I also remove unity lenses by executing following commands as root:

apt-get autoremove unity-lens-shopping 
apt-get autoremove unity-lens-music 
apt-get autoremove unity-lens-photos 
apt-get autoremove unity-lens-video

6. Execute following command as root:

apt-get update && apt-get upgrade

7. Install essential software:
apt-get install geany g++ vlc gimp ghex 

8. Now open "Disks" utility and create two (or more) encrypted partitions.

Saturday, August 17, 2013

Transition from Gnome 3 to LXDE

1. Install LXDE as root
  # yum install @lxde-desktop

2. Log on as standard user in LXDE mode

3. Edit the file ~/.config/openbox/lxde-rc.xml and change font size for ActiveWindow and InactiveWindow from 10 to 1. This will finally make title bars completely vanish.

4. To enable clicking by tapping on touchpad, add following line to /etc/xdg/lxsession/LXDE/autostart:
  @synclient TapButton1=1

5. (Optional) If you want to adjust font size create file ~/.Xresources and add following line to it (default value 96):
  Xft.dpi: 163

6. Right click the "panel" and click on "panel settings" and set them as follows:
  Geometry
    Edge: Top
    Alignment: Left
    Width: Dynamic
    Height: 18
    Icon Size: 16
  Panel Applets
    Menu
    Application Launch Bar
      Select "Application Launch Bar" and clik on "Edit".
      Then add following items to Application Launch Bar:
        Files
        Firefox
        Terminal
        Sound
    System Tray
    Battery Monitor

7. Skip to step 9 if you don't want Mac-Expose/Gnome-3 style window switching.
  Edit the file ~/.config/openbox/lxde-rc.xml again and add following lines:
  <keybind key="A-grave">
    <action name="NextWindow"/>
  </keybind>
 
  Change key bindings for A-Tab to follows:
 
  <keybind key="A-Tab">
    <action name="Execute"><command>skippy-xd</command></action>
  </keybind>

8. Skippy-xd installation:
  Install mercurial
    # yum install mercurial
 
Install dependencies:
    # yum install libX11-devel libXmu-devel libXfixes-devel libXdamage-devel   
  Install skippy-xd.
    $ hg clone https://code.google.com/p/skippy-xd/
    $ cd skippy-xd
    $ make
   
    If make command results in error, verify if all dependencies given on the following link are installed : http://code.google.com/p/skippy-xd/wiki/Installation
   
    Copy skippy-xd executable to /usr/bin as root:
      # cp skippy-xd /usr/bin

9. Log out and log in again

How to survive the above configuration:
1. Use icons in the panel on the top to launch various applications.
2. Some applications can be launched by pressing Win-r key.
3. Since no window has title bar you can close a window by pressing Alt-F4
    You can replace Alt-F4 with some other value like Alt-q or Ctrl-q in the lxde-rc.xml file.
4. Use Alt-Tab or Alt-` to switch between applications (Mac-Expose/Gnome-3 style).

Wednesday, June 26, 2013

Advanced Yum

Yum History

Sometimes after an update you may want to revert to an older version of a package.

Following command shows you summary of last few yum transactions:

yum history

If you want to see more details, use the command:

yum history info 26

where 26 is to be replaced with the ID of the particular transaction you are interested in.

Search for a particular package

 Try
yum search libXss


Happy yumming!

Wednesday, June 12, 2013

Making Gome 3 Usable ( 11 Tips and a Confession)


After installing the latest version of Gnome 3 if you were shocked by the lack of usability and wondered how hard or impossible it was to configure small things, say, window font size then I have to confess that this is exactly what I also felt when I installed a fresh copy of Gnome 3 flavored Fedora.

Still, I'm a fan of Gnome 3 and after relevant customization I find it more usable than Windows 7 or OS X 10.8.

Here's a list of important changes I make. You may have to change the values of parameters so that they work well on your hardware.

1. Install custom fonts:

mkdir ~/.local/share/fonts

  Dump your favorite fonts in this folder. My favorite are Verdana and Arial.

2. Improve the interface:

gsettings set org.gnome.desktop.interface text-scaling-factor '1.7'

gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Arial Narrow Bold 0'

gsettings set org.gnome.desktop.interface font-name 'Arial Narrow 11'

gsettings set org.gnome.desktop.wm.keybindings close "['<Alt>Q']"

You might have noticed that now I have no way of closing a window with mouse. Only way to do is to press Alt-Q.

3. In mouse and touchpad settings enable "two finger scroll" and "tap to click"

4. Resize Gnome panel

http://useful-linux-tips.blogspot.in/2013/02/resize-gnome-panel.html

5. Remove unwanted entries from Nautilus

http://useful-linux-tips.blogspot.in/2013/02/modify-places-menu-in-nautilus-file.html

6. Remove all favorite apps from gnome panel except firefox, nautilus and one or two other apps that you frequently use.

7. I generally clear my home folder and tell browsers to directly download in my home folder from where I transfer important data (if any) to a different partition which is fully organized.

  rmdir Public/ Documents/ Music/ Pictures/ Videos/ Templates/ Desktop/ Downloads/

8. Disable recent documents:

  rm .local/share/recently-used.xbel; mkdir .local/share/recently-used.xbel

9. Remove all default bookmarks by erasing all contents of

    vi .config/gtk-3.0/bookmarks

   Rather, manually bookmark folders that you frequently visit.

10. Disable auto update from all accounts by command

 gpk-prefs

11. Make fonts smooth if needed:

http://useful-linux-tips.blogspot.in/2013/01/smooth-font-rendering-on-fedora-18.html

That should make it usable enough.

Tuesday, June 4, 2013

Convert mp3 to wav format using mpg123

Audacity that comes from Fedora's repository, by default, does not support loading and saving mp3 files.

Using mpg123 (you may need to install mpg123), mp3 files can be easily converted to wav files for further editing.

mpg123 -w music.wav music.mp3

I recommend saving your work in lossless compressed format like flac rather than mp3.

Thursday, May 16, 2013

Combine multiple PDF files into single PDF file

The following command will combine all the PDF files in current folder into a single file called all.pdf.

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=all.pdf *.pdf

Friday, May 10, 2013

Launch Custom Script at Startup

Say the name of the script is checkconnection.
Create the file :
.config/autostart/checkconnection.desktop

Add following lines to the file:

[Desktop Entry]
Type=Application
Terminal=false
Exec=/path/to/scrip/folder/checkconnection
Name=checkconnection

Permanently Save Brightness Settings

Issue the command: 
crontab -e

This will open vi editor. Type the following line, save and exit vi editor (:wq).

@reboot echo "5" > /sys/class/backlight/acpi_video0/brightness

Thursday, April 25, 2013

DRM in HTML5! Defective by Design

It's funny, sad and not-so-surprising to witness corruption creeping into W3C (w3c.org) that proposes password protection to media content like audio and video clips.

Dear W3C, if you want to facilitate encryption of contents of HTMLMediaElement, isn't it a good idea to extend it further to <script> element?

Take action NOW!
http://www.defectivebydesign.org/sign-on-against-drm-in-html

_____________
 Dear W3C,

Please extend content protection to propitiatory JavaScript code also.


I've written excellent JavaScript based rendering and interaction libraries which I'm hesitant to share because my JavaScript content will not be protected under current standards. If I could meter the usage of my JavaScript code the world would benefit from my libraries and I, as the creator, would benefit by charging the users of my libraries. Millions of people like me are not sharing useful JavaScript code because of the fear that someone will copy it and share it for free. Are we not artists? Are we not original creators? Do we not deserve source of livelihood? 

Saturday, April 20, 2013

Committing Your Project on GitHub

I had a custom png image I/O program that I've used multiple times to process images and even to visualize data in a highly customized manner and I wanted to share it on GitHub.

Here's a summary of steps that I followed:

1. On GitHub website, create a new GitHub account with your user name. You may use your firstname-lastname (note the hyphen) as your user name; for sake of privacy, let your email id be firstname-lastname@server.fake and choose a password as instructed.

2. Click on "New repository" button and create a new repository with name repositoryName. Make sure that you select "Initialize this repository with a README" option.

3. Install and configure git
$ sudo yum install git-core
$ git config --global user.name "firstname-lastname"
$ git config --global user.email firstname-lastname@server.fake
$ git config --global credential.helper cache

$ git config --global credential.helper 'cache --timeout=3600'

4. Checkout the newly created repository from GitHub
$ git clone https://github.com/firstname-lastname/repositoryName.git

As you would expect, a folder with the name of repository (repositoryName) will be created having just the README file in it.

5. Create more files in this folder and add the new files to the repository.
$ git add file1
$ git add file2

6. Commit the changes.
$ git commit -m 'initial version'

7. Commit the changes to GitHub website also.
$ git push origin master

That's it!

Note: You can download my committed program from this link: https://github.com/ajay-anand/png

Wednesday, April 10, 2013

Using APT

Just today I installed Ubuntu Server Edition 12.04 on a machine. It's worth knowing a few apt tricks:

apt-get install pkg_name

apt-get download pkg_name

apt-get update #update repository

apt-get autoremove #remove unnecessary packages

dpkg -s firefox | grep Status #check installation status

apt-cache pkgnames | sort

apt-cache depends firefox #get dependency list

apt-get install -o Acquire::http::Proxy=none #manual proxy setting

echo -e "pkg1 hold\npkg2 hold\npkg3 hold" | dpkg --set-
selections #prevent packages

Monday, April 1, 2013

Get rid of shaky touchpad pointer (cursor that jumps)

Recipe for Ubuntu 13.04
1. Open the file /usr/share/X11/xorg.conf.d/50-synaptics.conf and locate the block with Identifier "touchpad catchall".

2. Add the options next to MatchIsTouchpad "on" and the contents will look as follows:

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"


        Option "VertResolution" "100"
        Option "HorizResolution" "65"
        # disable synaptics driver pointer acceleration
        Option "MinSpeed" "1"
        Option "MaxSpeed" "1"
        # tweak the X-server pointer acceleration
        Option "AccelerationProfile" "2"
        Option "AdaptiveDeceleration" "16"
        Option "ConstantDeceleration" "16"
        Option "VelocityScale" "32"

# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
      MatchDevicePath "/dev/input/event*"
EndSection

3. Reboot

4. Open "Mouse and Touchpad" preferences window and adjust touchpad pointer speed.


Recipe for Fedora 18

1. Create file /etc/X11/xorg.conf.d/50-touchpad.conf

2. Add following settings to the file:

Section "InputClass"
        Identifier "touchpad"
        MatchProduct "SynPS/2 Synaptics TouchPad"
        Driver "synaptics"
        # fix touchpad resolution
        Option "VertResolution" "100"
        Option "HorizResolution" "65"
        # disable synaptics driver pointer acceleration
        Option "MinSpeed" "1"
        Option "MaxSpeed" "1"
        # tweak the X-server pointer acceleration
        Option "AccelerationProfile" "2"
        Option "AdaptiveDeceleration" "16"
        Option "ConstantDeceleration" "16"
        Option "VelocityScale" "32"
EndSection 

3. Restart gdm as superuser (you'll be logged out)
$ service gdm restart  

Reference:
https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-synaptics/+bug/1042069

Wednesday, March 20, 2013

Allow http service in firewall settings on Fedora 18

To allow http service in firewall settings:

1. Open firewall application.

2. Select persistent mode.

3. If the default zone is public then select the public group and check http there.

4. Since I use port 8080, I have to add it to the definition of http.
 

Sunday, March 10, 2013

Priceless Games

Really humble!

https://www.humblebundle.com

$25 sounds reasonable.

How much would you pay?

Monday, February 25, 2013

Firefox OS ♫ ♬

Firefox OS is incredible.
The bold move they have made should be an eye opener not only for Chrome OS but also for team Metro.

I feel personally gratified. I love JavaScript (and CoffeeScript) as a programming and scripting language and it was my dream to see it embedded in everything, say coffee machines. Mozilla made an essential step towards that dream.

Sunday, February 24, 2013

Custom Google and Youtube Search on Firefox

Just typing g hello in address bar will search google for the word hello. Entering y abc in address bar will search youtube for word abc. You want to remove the search box? Go ahead.


You can make it possible by creating following custom bookmarks with keywords g and y respectively:

  Name: Custom Google Search
  Location: http://www.google.com/search?complete=0&q=%s
  Keyword: g

  Name: Custom Youtube Search
  Location: https://www.youtube.com/results?search_query=%s&webm=1
  Keyword: y

Note: Youtube search will show only HTML5 videos because of &webm=1 and google search will disable annoying autocomplete because of complete=0&.

Saturday, February 23, 2013

Gnome 3 vs Cinnamon

Right now there are five types of users I can think of:

1. Mouse oriented users
2. Keyboard oriented
3. Touch oriented
4. Speech and gesture oriented
5. People with special needs


Technologies for 4 and 5 have a long way to go. Gnome 3 is ready for 1, 2 and 3. Cinnamon does better than Gnome for 1 but not for 2 and 3.

So I would install Mint+Cinnamon for my mom(1), I'll reserve Fedora+Gnome3 for myself(2).

yum yum yum yum yum

Having problem using yum with proxy?
Add proxy and timeout in /etc/yum.config:
proxy=http://172.10.20.30:4000
timeout=180


Hate download of updates/primary_db and all that automatic refresh?
yum --disableplugin=refresh-packagekit list  

Download only, don't install:
yum --downloadonly install PACKAGE

Try following commands:
yum list | more 
yum list installed
yum info curl
yum deplist curl
yum repolist

Thursday, February 21, 2013

Resize Gnome Panel

Gnome 3.8/Fedora 19


1. Create the folder: ~/.local/share/gnome-shell/extensions/panelsize@gnomepanelsize.com
    $ mkdir .local/share/gnome-shell/extensions
    $ mkdir ~/.local/share/gnome-shell/extensions/panelsize@gnomepanelsize.com
    $ cd ~/.local/share/gnome-shell/extensions/panelsize@gnomepanelsize.com/

2. Create three files in this newly created folder:

/*************** extension.js *******************/
const St = imports.gi.St;
const Shell = imports.gi.Shell;
const Main = imports.ui.main;

let  defaultStylesheet, patchStylesheet;

function init(extensionMeta)
{
  defaultStylesheet = Main.getThemeStylesheet();
  patchStylesheet = extensionMeta.path + '/stylesheet.css';
}

function enable()
{
  //imports.ui.main.panel.statusArea.appMenu.actor.hide();
  imports.ui.main.panel.statusArea.activities.actor.hide();
  imports.ui.main.panel.statusArea.a11y.actor.hide();
  imports.ui.main.panel.statusArea.userMenu.actor.hide();
  imports.ui.main.panel.statusArea.dateMenu.actor.hide();
  let themeContext = St.ThemeContext.get_for_stage(global.stage);
  let theme = new St.Theme ({ application_stylesheet: patchStylesheet,
  theme_stylesheet: "/usr/share/gnome-shell/theme/gnome-shell.css" });
  try { themeContext.set_theme(theme); }
  catch (e) { global.logError('Stylesheet parse error: ' + e); }
}

function disable()
{
  let themeContext = St.ThemeContext.get_for_stage(global.stage);
  let theme = new St.Theme ({ theme_stylesheet: defaultStylesheet });
  try { themeContext.set_theme(theme); }
  catch (e) { global.logError('Stylesheet parse error: ' + e); }
}


/*************** metadata.json *******************/
{
    "shell-version": [
        "3.2",
        "3.4",
        "3.6",
        "3.7",
        "3.8"
    ],
    "uuid": "panelsize@gnomepanelsize.com",
    "name": "Panel Size",
    "description": "Panel Size for Gnome",
    "url" : "http://gnomepanelsize.com"
}

/*************** stylesheet.css *******************/
#panel { height: 1px; font-size: 1px; }
.panel-button { transition-duration: 100; height: 16px; font-size: 16px; color:black; }
/*.panel-button:hover { height:28px; font-size:28px; color:black; }*/


3. Issue the command
  $ gsettings set org.gnome.shell enabled-extensions "[ 'panelsize@gnomepanelsize.com' ]"

4. Restart gnome:
  Press Alt-F2
  Enter single letter 'r' as command 

Gnome 3.6.2/Fedora 18

1. Create the folder: ~/.local/share/gnome-shell/extensions/panelsize@gnomepanelsize.com

2. Create following three files in this newly created folder:
  
/*************** extension.js *******************/
const St = imports.gi.St; const Shell = imports.gi.Shell; const Main = imports.ui.main; let defaultStylesheet, patchStylesheet; 

function init(extensionMeta) { defaultStylesheet = Main.defaultCssStylesheet; patchStylesheet = extensionMeta.path + '/stylesheet.css'; } 

function enable() { let themeContext = St.ThemeContext.get_for_stage(global.stage); let theme = new St.Theme ({ application_stylesheet: patchStylesheet, theme_stylesheet: defaultStylesheet }); try { themeContext.set_theme(theme); } catch (e) { global.logError('Stylesheet parse error: ' + e); } } 

function disable() { let themeContext = St.ThemeContext.get_for_stage(global.stage); let theme = new St.Theme ({ theme_stylesheet: defaultStylesheet }); try { themeContext.set_theme(theme); } catch (e) { global.logError('Stylesheet parse error: ' + e); } } 

 

/*************** metadata.json *******************/ 
{ "shell-version": [ "3.2", "3.4", "3.6", "3.7" ], "uuid": "panelsize@gnomepanelsize.com", "name": "Panel Size", "description": "Panel Size for Gnome", "url" : "http://gnomepanelsize.com" } 


/*************** stylesheet.css *******************/ 
#panel { height: 1px; font-size: 1px; } 
.panel-button { transition-duration: 100; height: 1px; font-size: 1px; color:white; } 
.panel-button:hover { height:28px; font-size:28px; color:black; } 


3. Issue the command:
 gsettings set org.gnome.shell enabled-extensions "[ 'panelsize@gnomepanelsize.com' ]" 

4. Restart gnome: 
Press Alt-F2
Enter single letter 'r' as command


IMPORTANT: Panel has vanished but you can access individual panel items by moving pointer along the top edge of the screen. In case you don't like it you can do any of the following to get back the original panel:

1. Delete the files and folders that you created and restart gnome

2. Execute the following command and restart gnome:
gsettings set org.gnome.shell enabled-extensions "[ ]"

3. Do you love adventure? Play around with the file "stylesheet.css" and restart gnome.

Saturday, February 9, 2013

Two finger click on touchpad causes context menu to open which is annoying

1. Create a text file containing following lines:
(for me ~/.myscript)

   synclient TapButton2=1 
   synclient TapButton3=1

2. Use following command to make the newly created script file executable
chmod 755  ~/.myscript

3. Issue following command to launch gnome-session-properties:
gnome-session-properties

4. Click the "Add" button and provide full path of the command/script:
/home/YouUserName/.myscript

Next time when you login clicking with two or three fingers will be regarded as simple left click.

Thursday, February 7, 2013

Running QT/KDE applications like VLC Media Player on Fedora 18 without installing

It is quite difficult to provide precise steps how QT applications can be run on Fedora 18 without really installing them but today I succeeded to do that.

What makes the steps complicated is that each QT application has its own requirements and tweaks which are revealed only through error messages during the launch (or if you are God, you would like to infer all possible requirements by looking at the entire source code and configuration files).

The fundamental idea is to download rpm files and extract them to a local folder, say, ~/.qtapps/

1. Issue the installation command in download only mode:
yum --downloadonly install vlc

2. Copy or move the downloaded rpm files ( from /var/cache/yum/... ) to a local folder, say ~/sandbox.

3. Create a file named extract.sh containing following lines in ~/sandbox. When executed, this script will extract data from all the rpm files in ~/sandbox.

 OLDIFS=$IFS; IFS=$'\n'; fileArray=($(find . -type f -iname "*.rpm")); for file in ${fileArray[@]}; do rpm2cpio $file | cpio -midv; done; IFS=$OLDIFS;

4. You will see a folder called usr. Move it to .qtapps.
mv usr ~/.qtapps

5. Make system aware of ~/.qtapps/bin and ~/.qtapps/lib folders and also ~/.qtapps/sbin and ~/.qtapps/lib64 folders if they exist by setting PATH and using ldconfig.

To install more QT based apps just download the necessary rpm files, extract them and move the contents of extracted bin, sbin, lib and lib64 folders into corresponding folders in ~/.qtapps.

For easy launching of the newly added app, create a .desktop file as mentioned in an older post titled "custom 'open with' command".

Tuesday, February 5, 2013

Enable maximize and minimize buttons next to close button in titlebar in Fedora 18

Issue the command:

gsettings set org.gnome.shell.overrides button-layout ':minimize,maximize,close'

Bring close button to the left:

gsettings set org.gnome.shell.overrides button-layout ':close,minimize,maximize'

Remove close button entirely:
 
gsettings set org.gnome.shell.overrides button-layout ':minimize,maximize'

Sunday, February 3, 2013

"Create New Document" option missing from right click context menu in Fedora 18

1. See if you have ~/Templates folder. Create one if it is missing.
2. Now create an empty file from command prompt:
touch ~/Templates/Text\ File.txt

"Create Document" option is back again and you can create a new text file or a new document.

Modify "Places" menu in Nautilus (file viewer) on Fedora 18

Edit ~/.config/user-dirs.dirs and change appropriate lines to match with following lines:
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"

Log out and log back in and you will find entries for Music, Pictures and Videos removed from "Places" menu in file viewer.

Disable "Recent" Documents in Ubuntu and Fedora 18

Issue the following commands:

rm .local/share/recently-used.xbel; 
mkdir .local/share/recently-used.xbel

Custom command for "open with" in Fedora 18

Suppose I want to open ~/Documents/help.chm with executable ~/Downloads/xchm 

First find out the MIME type of the file:

1. Right click help.chm and select "Properties" option.
2. In the popup, select "Open with" tab.
3. Select a known application, say, "Archive Manager" and click OK.
4. Now look in ~/.local/share/applications/mimeapps.list and find out the MIME type of the file.

Issue the following command and note down the mime type of the file:

file -i help.chm

I found an entry called "application/vnd.ms-htmlhelp"
Now I know the MIME type of help.chm.

5. Create either the file /usr/share/applications/xchm.desktop OR the file ~/.local/share/applications/xchm.desktop and add the following lines:

[Desktop Entry]
Encoding=UTF-8
Name=xCHM
GenericName=chm file viewer

Exec=/home/UserName/Downloads/xchm
Icon=/home/UserName/Downloads/xchm.xpm
Terminal=false
Type=Application
MimeType=application/vnd.ms-htmlhelp;
Categories=Utility;


6. Issue the command update-desktop-database .

Now you can simply double click help.chm or any other .chm file and it will automatically open with /home/YourUserName/Downloads/xchm.

Monday, January 28, 2013

Why I switched from Ubuntu to Fedora

Update:

I switched back to Ubuntu (13.04) during last week of August 2013 when a normal Fedora update (sudo yum update) made my system begin to freeze frequently and unexpectedly. I reinstalled Fedora 19 using Live USB stick, but as soon as I updated the system (sudo yum update), the freezing symptom started appearing again.

https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1001949

Original Post
After using Ubuntu for 1.5 years, I decided to switch to Fedora because of concerns about privacy and openness.

And of course, I wanted to recover my lost love, Gnome-Shell.

(When Shuttleworth stepped down, Canonical could really hire someone as serious as Stallman.)


To replace spaces in file names with underscores _

for n in *; do mv -i "$n" `echo $n | tr ' ' '_'`; done

I want to play mp3 songs on Fedora 18

The following method gets the job done with least corruption:
Visit Fluendo plugin website and download MP3 plugin for free (click on "check out", no credit card needed).

Extract the file "libgstflump3dec.so" into ~/.gstreamer-0.10/plugins folder.

Execute the following command:

gst-launch-0.10 filesrc location=music.mp3 ! decodebin2 ! audioconvert ! flacenc ! filesink location=music.flac

This will create a file called music.flac for the input file music.mp3.

Now you can play the file music.flac using any existing audio/video software on Fedora.

Remark 1: The instructions above provide bare minimum support (only mp3). VLC media player on the other hand supports most of the common audio and video formats. Read more about using VLC media player on Fedora 18 without installing it.: http://useful-linux-tips.blogspot.in/2013/02/running-qtkde-applications-like-vlc.html

Search for files containing a specific word

Following command searches for the word "rose" in all files in Downloads folder:

grep -rinsI ~/Downloads "rose"

Quickly encrypt a file

Use gpg:

gpg -c file.txt #gpg encryption with symmetric keys

If gpg is not installed install gpg.

yum install gpg #Fedora
apt-get install gpg #Ubuntu

Unrelated Gossip:
It is due to privacy concerns that I'm not on FB. Even after making my friends' list private, one of my friends could see my hidden friend in "People you may know" suggestions and could see me as one of the "common friends" in a popup. I know FB is doing exactly what they clearly declare they are doing in their privacy policy. But this is also a fact that any kind of revelation of my one friend to another friend, whatsoever the case may be, is completely unacceptable to me. Anyway, I immediately deleted my account to prevent further revelation.

Find a file modified later than a given date and time

Following  command finds files in Downloads folder which were modified after noon of January 31, 2000:

find ~/Downloads -type f -newermt "2000-01-31 12:00:00.0"

Find a file in a folder

Following command finds PNG files in Downloads folder:

find ~/Downloads -iname "*.png" -type f -size +400k -printf "%s:%h/%f\n" #search a file

I want to extract contents of an RPM file

rpm2cpio FileName.rpm | cpio -midv

I do not want firefox to remember zoom setting for entire website/webdomain

Visit the page about:config
Change the setting browser.zoom.siteSpecific to false.

Smooth Font Rendering on Fedora 18

Add following lines to the file /etc/fonts/local.conf or the file ~/.fonts.conf

<?xml version='1.0'?>
  <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
  <fontconfig>
    <!-- See: man 5 fonts-conf -->
    <!-- Antialias rules -->
    <match target="font">

      <edit name="autohint" mode="assign"> <bool>true</bool> </edit>
   
      <!--Subpixel smoothing: rgb, bgr, vrgb, vbgr, none-->
      <edit mode="assign" name="rgba"><const>vrgb</const></edit>
     
      <!-- Use hint? true/false. Usually true-->
      <edit mode="assign" name="hinting"><bool>true</bool></edit>
     
      <!-- Hint: hintfull, hintmedium, hintslight, hintnone -->
      <edit mode="assign" name="hintstyle"><const>hintmedium</const></edit>
     
      <!-- By default, apply antialias to all, filter on the following lines -->
      <edit mode="assign" name="antialias"><bool>true</bool></edit>
    </match>
   
    <!-- If fonts are smaller than X, then don't antialias-->
    <match target="font">
      <test compare="less" name="size" qual="any">
        <int>6</int>
      </test>
      <edit mode="assign" name="antialias">
        <bool>false</bool>
      </edit>
    </match>
   
    <!-- If BOLD fonts are smaller than Y, then don't antialias-->
    <match target="font">
      <test compare="more_eq" name="weight" qual="any">
        <const>medium</const>
      </test>
      <test compare="less" name="size" qual="any">
        <int>6</int>
      </test>
      <edit mode="assign" name="antialias">
        <bool>false</bool>
      </edit>
    </match>
   
    <!-- Firefox fix (it uses pixelsize, instead of size) -->
    <match target="font">
      <test compare="less" name="pixelsize" qual="any">
        <int>10</int>
      </test>
      <edit name="antialias" mode="assign">
        <bool>false</bool>
      </edit>
    </match>

    <!-- Firefox fix BOLD (it uses pixelsize, instead of size) -->
    <match target="font">
      <test compare="more_eq" name="weight" qual="any">
        <const>medium</const>
      </test>
      <test compare="less" name="pixelsize" qual="any">
        <int>10</int>
      </test>
      <edit name="antialias" mode="assign">
        <bool>false</bool>
      </edit>
    </match>
  </fontconfig>

Adjust system font on Fedora 18

Adjust system font on Fedora 18

Install custom fonts by copying *.ttf files to ~/.local/share/fonts folder.
Then execute following commands:
 
gsettings set org.gnome.desktop.interface text-scaling-factor '1.7'

gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Arial Narrow Bold 11'

gsettings set org.gnome.desktop.interface font-name 'Arial Narrow 11'

Introduction

Through this blog I hope to facilitate and promote using Linux for everyday computing.

This is a living blog. Each post is subject to changes as the universe evolves. Feel free to come back if some technique breaks down in future versions.