Figured a way out.
Keep a python script running at the background and use the
serial library in python to connect to a particular serial port. Now
serial write the data from arduino whenever the desired action in executed in arduino. Read the value written on serial in python script and based on that value execute shell command for locking and unlocking the system, which are as follows:
gnome-screensaver-command -l (to lock)
gnome-screensaver-command -d (to unlock)
import serial, os
port_name = '/dev/ttyACM0' # Change accordingly
arduino = serial.Serial(port_name, 9600)
word = str(arduino.readline())
if word == 'l': # Lock the screen
elif word == 'u': # Unlock the screen
Serial.write() function of arduino, write
'u' on the serial based on your requirement (RFID Swipe as in my case).
Happy Hacking :-)