LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices

Old

Bash scripts and keyboard input

Posted 01-29-2012 at 02:43 PM by Nominal Animal

You can use Bash to read individual keypresses. Here is an example:
Code:
#!/bin/bash

# Reset terminal to current state when we exit.
trap "stty $(stty -g)" EXIT

# Disable echo and special characters, set input timeout to 0.2 seconds.
stty -echo -icanon time 2 || exit $?

# String containing all keypresses.
KEYS=""

# Set field separator to BEL (should not occur in keypresses)
IFS=$'\a'
...
Senior Member
Posted in Uncategorized
Views 5959 Comments 0 Nominal Animal is offline
Old

Slacking with Slackware

Posted 12-01-2011 at 08:11 AM by ofaring (Debian, This That and the Other)
Updated 12-01-2011 at 08:14 AM by ofaring

Ok. I've used Debian for quite some time -- although I started with Slackware years back -- and it's been awhile since I attempted anything without a package manager!

I grabbed a copy of Slackware Disc 1 and installed a basic, console-only Slackware.

First snag...WiFi. I live in a busy neighbourhood full of students eager to grab "free" internet off a WEP-encrypted wireless router, so WPA is a must. Well, /etc/rc.d/rc.inet1.conf didn't seem very happy to play...
Member
Posted in Examples, Slackware
Views 933 Comments 0 ofaring is offline
Old

Comment a block in shell

Posted 08-31-2011 at 12:22 AM by hi2arun
Tags bash, script

We all know, to comment out a line in shell script, '#' token is inserted in the line that needs to be made dead.
Eg:

Code:
# This is a dead line
echo "This line is live"
However, '#' token can be pesky if a block of lines need to be commented out.
Say, to comment out the following block using '#'

Code:
# comment starts here
# All these lines
# are blocked
# using '#' token
# ...
# ...
# ...
...
Member
Posted in Uncategorized
Views 810 Comments 0 hi2arun is offline
Old

"Wait until a process ends, a download ends, or a file conversion ends, then do X"

Posted 08-30-2011 at 03:06 PM by the dsc (linux-related notes)
Updated 08-30-2011 at 09:41 PM by the dsc (a small improvement)

Sometimes you want the computer to shut down after you've finished downloading something or converting some large file into some other format, but you want to go out or go to sleep instead of waiting and checking for it yourself.

For these situations I've come up with two tiny scripts. The first one waits until a file hasn't changed its size on three consecutive intervals of twenty seconds:

Code:
a=0 ; file="$1" ; if [ -f "$file.part" ] ; then file="$file.part"
...
Member
Posted in Uncategorized
Views 823 Comments 0 the dsc is offline
Old

How hard could it be? A login manager in BASH

Posted 07-11-2011 at 08:34 PM by William (Dthdealer) (Whaling the FOSS)

As I have previously elaborated, I hat the Gnome Login Manager. To summarise: it is bulky and slow.

I am currently using SLim as my login manager, for it is fast and very customisable. It however lacks a few features I want:
  1. Render of the date and time
  2. An easy way to receive a list of configured commands to for example, turn the computer off ( from now written as 'power commands' )
  3. UI elements to allow the user to turn the computer off without having to first login

...
Member
Views 2168 Comments 0 William (Dthdealer) is offline

  



All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration