Sunday, November 25, 2012

Archlinux Gnome Issue

sudo pacman -Syu used to work fine for the most part, but some changes are bigger than others and your current configuration cannot handle them.

I came across such a change, when systemd is now the default init system for Arch Linux. This affected Gnome; each time I tried to log in my system it said that something went wrong and fails to proceed.

Of-course, I need to research on how to solve the problem. That's a bit hard with no GUI so I opened up X Window System by typing in start x in the terminal. Finding a solution didn't seem that simple so first I opted for a better GUI till I fix the Gnome issue.

The other major player in Linux GUI is KDE. Since I wasn't planning to use it for a long time, I went with the minimal install. To fire up the KDE I just had to write sudo KDM on start up.

I also had to install KMix so that I could have sound. sudo pacman -S kdemultimedia-kmix

First I started reading this forum post and which says to install Systemd.

Annoyingly I was stuck in the first step which says to include init=/usr/lib/systemd/systemd in the kernel line but failed to mention which.

Luckily I came across this post which indicated to add the line in /boot/grub/menu.lst

In the following sections:

# (0) Arch Linux
title Arch Linux
root (hd0,0)
kernel /vmlinuz26 root=/dev/disk/by-uuid/1b861675-ae37-4f04-acdd-42da522772ae
init=/usr/lib/systemd/systemd ro
initrd /kernel26.img

# (1) Arch Linux
title Arch Linux Fallback
root (hd0,0)
kernel /vmlinuz26 root=/dev/disk/by-uuid/1b861675-ae37-4f04-acdd-42da522772ae
init=/usr/lib/systemd/systemd ro
initrd /kernel26-fallback.img

After a reboot the system fired up gnome on start up, and I successfully logged into my user account. The only thing that didn't fire up is the network manager. Since systemd replaced the init scripts, network manager had to be reconfigured to load on start up which I did through this wiki. It was a simple process of running the following line:

systemctl enable NetworkManager.service

I also used systemctl enable gdm so that gnome fires up using systemd instead of using the added code in /boot/grub/menu.lst.

Monday, May 7, 2012

Get Gnome Information

In this blog post I will list small how to's in getting information about gnome

  • Gnome Version

    To know the current gnome version that you are using type the following command in the terminal

    gnome-session --version

Friday, May 28, 2010

First attempts of bash scripting


I am quite new to linux, but so far I have noticed that the terminal that comes with it is quite powerfull. Realising that I will often use this console I decided to give my hand in bash scripting for the set of commands I will often use.


I came across this website that gave tutorials about bash scripting to relatively new users such as myself. The first test ofcourse is the ever popular "Hello World" script, it displays those legendary words. So I fired up vim and started typing away.


The script went like so :


  #!/bin/bash
  #declare STRING variable
  STRING="Hello World"
  #print variable on a screen
  echo $STRING
 

My first bash script was completed! Now I had to run it, this consisted of two commands I had to run in terminal. Please note that the "#" symbol usually is used for comments but "!#" also know as a shebang which is a place where you put your interpreter.


  chmod +x hello_world.sh
 

which made the bashscript executable and


  ./hello_word.sh
 

To actually run it


hello_word.sh being the bashscript file I just saved. After that produced the text "Hello World" in terminal, the cogs inside my brain started to turn and instantly wanted to try something out on my own, even though I was only in the first part of my tutorial. What I wanted to do is a script is launch google chrome(chromium browser in ubuntu) with 3 sites that I usually use of google. (If you think this product placement, please ring up google and tell me to pay me)


So my first attempt attempt of the script went like so


  chromium-browser -new-window www.igoogle.com www.gmail.com docs.google.com
 

I saved the script and ran it and vuola a new chrome window popped up with tabs of the corresponding urls. But I wasn't happy with just that I also wanted to output what tabs I am going to access before launching the browser, so that in future modifications I would always know what was supposed to happen, from what did happen. Since I only had 3 urls I tried placing them in variables and them outputting them using an echo, using the same variables for the command that launches the browser. My code went as follows:

  IGOOGLE="www.igoogle.com"
  GMAIL="www.gmail.com"
  DOCS="docs.google.com"
  echo "Opening the following pages in new chromium window :" $IGOOGLE $GMAIL $DOCS
  chromium-browser -new-window $IGOOGLE $GMAIL $DOCS
 

With the ammendments now it displays the text "Opening the following pages in new chromium window : www.igoogle.com www.gmail.com docs.google.com" before launching the browser with those urls. Now please note when declaring variables be sure that the "=" sign is right next to the variable name, otherwise the terminal would think it is a command. To use the variables as you've noticed you would need to place a "$" sign before them.

After I was proud of my fancy script, my laziness kicked in and said "What if in the future you need to add or remove urls, you would have to keep on declaring/removing variables and add/remove them from the echo and chrome commands". That was a no no for me, so scowered the internet to find out how to create an array, and I found a rather interesting way.

  GOOGLELIST="www.igoogle.com www.gmail.com docs.google.com"
  echo "Opening following pages in  new chromium window:"
  for SITE in $GOOGLELIST;
  do
   echo $SITE;
  done;
  chromium-browser -new-window $GOOGLELIST
 

Apparently I just had to use the normal syntax as declaring a variable, and the space between text is used as a way to device the information into array segments. After that I looped through the array to display the urls in the "array", but the great thing is that I didn't need to do it for the chromium-browser command since essentially it is still a string with the same format the browser required it to.


Now that I am happy with my bash script, I decided to give it an alias since I plan to use it quite often, and would be a pain to keep on going to it's directory to run it.


  alias kiwigoogle='~/mybashscriptdirectory/./kiwigoogle.sh'
 

So in terminal I typed the command alias followed by the keyword I want to associate with my script and set it to the absolute path of where my script is located. By giving the physical path, I could run this command from anywhere.


A reboot later I realised the my beloved alias was gone! This confused me at first but after a bit of research I learned that the set alias command needs to be saved in the .bash_aliases file found in the root folder.


If this didn't work for you access .bashrc that is also found in your root folder and see if the following lines of code are not commented


  if [ -f ~/.bash_aliases ]; then
      . ~/.bash_aliases
  fif