[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Invoking the screensaver AND backups [WAS:RE: Dying hard drive?]



> Does
> Main Menu -> Settings -> Keyboard -> Application Shortcuts
> not work for Ctrl-Alt-Del?
>
> Ie using command:
> xscreensaver-command -lock

Hi Zenaan,

Well your question set me on the right track. I installed the XFCE window
manager, and Application Shortcuts shows Ctrl-Alt-Del mapped to the script
/usr/bin/xflock4. That script tests for the xscreensaver pid and invokes
xscreensaver-command -lock if the pid is found. The script works fine,
but the problem was the Application Shortcut.

I discovered this by trying to recreate it with a different key combo,
Ctrl-Alt-Ins. That showed up in the Application Shortcuts window as
<Primary><Alt>Delete. So I removed that entry, and then manually edited
~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
(after making a backup first), and changed the original entry to match the
<Primary> instead of <Ctl>. After logging off and back on, all works fine.

Chris Bannister, you mentioned /etc/inittab. I don't think that X passes
the key presses to it, and I always disable that functionality anyhow. This
is not an OS that needs that work-around for a reboot, and I don't want
anyone else to have the ability to reboot my machine by switching to a VT
and pressing that key combo.


I would also like to address the issue of backups that several people
mentioned. I have never had to learn the value of a good backup the hard
way. In fact, way back in the very first issue of the Linux Gazette (July
1995), Dr. Fisk mentioned a simple backup script that he called "hack",
and that was expanded upon in subsequent issues. I took parts of those ideas
and created my own script that I use for all configuration files. It makes a
backup of the current file, appending the current date/time to the file, and
then opens the file in vi for me. I have gotten so used to using the command
"hack <some_config_file>" that when I find myself on a system without it,
I am momentarily confused by "hack: command not found". Mine is not an
eloquent, nor superbly stable script, but it has never let me down.

Of course that is fine as long as the hard drive is functional enough
to retrieve your back-ups. I keep copies of extremely important things on
multiple drives, and I make a full backup of important systems on a schedule
that makes my life easy when something fails. That is why my original post
was not a panic post, because I have it all backed up, and I have been in
that habit for at least 15 years.

If anyone is interested, I've included the script. Please do not crucify
me for it's shortcomings. It's about 14 years old, and I was just getting my
scripting legs under me back then. I can think of a million improvements, but I
haven't had a need to touch it in a very long time, so it is still what it is:

cat /usr/bin/hack
#!/bin/bash
############################################################################
#   Hack creates a back up of files that we would like to backup before    #
#   we edit them. If the file has not been "hacked" before, the backup     #
#   is created in /backup/origdist. If the file has previously  been       #
#   backed up to this directory, then hack creates a new backup of the     #
#   file in /backup/latest. This filename is appended with the current     #
#   time. If the script is called by a non-root user, the backup           #
#   directories are created in their home directory.                       #
############################################################################
#   This file is based on an idea by John M. Fisk, and printed in the      #
#   first issue of Linux Gazette, July, 1995, with modifications by        #
#   the author.                                                            #
############################################################################

# Let's set the backup directories:
if [ "$LOGNAME" == "root" ]
then
   # Original backup location.
   ORIG_DIR="/backup/origdist"
   # Secondary backup location.
   BU_DIR="/backup/latest"
else
   ORIG_DIR="$HOME/backup/origdist"
   BU_DIR="$HOME/backup/latest"
fi

# Let's make sure the backup directories exist:
if [ ! -d $ORIG_DIR ]
then
   mkdir -p $ORIG_DIR
fi

if [ ! -d $BU_DIR ]
then
   mkdir -p $BU_DIR
fi

CURR_DIR=`pwd`

# Make sure a file name was included in the call to hack.
if [ "$1" = "" ]
then
   echo "ERROR: no filename specified. Exiting..."
   exit 2
fi

# Make sure the filename is a valid file.
if [ ! -f "$1" ]
then
   echo "ERROR: filename invalid, or directory. Exiting..."
   exit 3
fi

# Strip any directory info from filename.
FILENAME=`basename $1`

# Check to see if file has been previously backed up.
if [ ! -f "$ORIG_DIR/$FILENAME.dist" ]
then
   # No, it has not been backed up.
   cp $1 $ORIG_DIR/$FILENAME.dist

else
   #Yes, it was backed up. Make current backup.
   cp $1 $BU_DIR/$FILENAME.`date +%T`.`date +%d%h%y`

fi

# Open the file in VI.
vi $1
exit 0
 		 	   		  

Reply to: