Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

AFAIK alias is usually used to make 'shortcut' for long command. But what to do if I want to alias one command to another?

I need this because I replaced gnome-screensaver with xscreensaver, so the lock screen button does not work.

How to alias gnome-screensaver-command -l to be resolved into xscreensaver-command -lock?

share|improve this question
    
I expect you're using Unity but in XFCE the lock function is handled by /usr/bin/xflock4. That's a script you can edit to prioritize gnome-screensaver or xscreensaver (or others). I don't know if it exists in Unity systems but something similar must. –  Sean Apr 12 at 3:40
    
Thanks for the quick feedback, but in Unity there is no xflock4. changed my question to be more relevant to the actual problem. –  Danatela Apr 12 at 4:22
    
@Danatela - duplicate of this? askubuntu.com/questions/75692/… –  fossfreedom Apr 12 at 12:18
    
@fossfreedom no, sudo ln -s /usr/bin/xscreensaver-command /usr/bin/gnome-screensaver-command doesn't work. –  Danatela Apr 13 at 7:00
    
what version of Ubuntu are you using? –  fossfreedom Apr 13 at 8:51

1 Answer 1

up vote 0 down vote accepted

It was easier than I thought. I had to create such shell script:

#!/bin/bash

case "$1" in
    -l)
        xscreensaver-command -lock
        ;;
    *)
        xscreensaver-command "$@"
        ;;
esac

Saved it as /usr/bin/gnome-screensaver-command and added execute permission:

sudo chmod +x /usr/bin/gnome-screensaver-command

Now, executing gnome-screensaver-command -l launches xscreensaver-command -lock and locks my screen.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.