-
Senior Member
registered user
Wanted: Bash program idea, or application suggestion
.
I would like to create a small bash program that would
monitor my keystroke activity and if no keystrokes are noted
within a fixed small time, then any currently active
internet connection would be disconnected.
I currently use a Knoppix LiveUSB and wifi via a broadband router
with network connections handled by NetworkManager.
If there's 'an app for this' already, then that might also serve.
Thanks in advance.
-
Senior Member
registered user
Hi utu, I do not have a bash script for you, but I have got some suggestions. First of all, you can disable and enable the network from the commandline by using the commands
Code:
nmcli networking off
and
Code:
nmcli networking on
I think the task is similar to a screensaver because in both cases user inactivity starts a process. I read about a user who wanted to download torrents while the screensaver is active. His or her solution was to ask dbus whether the screensaver was active. He or she used the Gnomedesktop environment. Later I read the solution has to be modified if KDE is used instead of Gnome. Since xscreensaver does not seem to use dbus I think you should try to find out if power management provides an interface to run one shell script on times of user inactivity and another if the user is active again. The absence of keyboard events should start a bash script, but what about mouse events? How long is a 'small time'? Do you intend to reconnect to the network if there is any keystroke activity again?
-
Senior Member
registered user
.
Thanks for your responses, klaus2008.
nmcli is probably part of the solution; I'll study up on that.
I should have indicated keyboard and/or mouse events as an indication or
lack of user presence or attention to internet events.
I think 'a small time' might be some random number between 15 and 30 minutes
as a starting point.
If I know I'm not going to use Knoppix for a while, I manually disconnect.
If I'm interrupted, I might forget to do this; I'd like Linux to disconnect
automatically, if need be. Solution need not consider re-connect, since that's
easy enough to do manually with the NM panel applet.
You can't underestimate my programming prowess. At most I may be able to
figure out a line of bash script. I wouldn't have a prayer with C/C+/or C++
source, even if I had it to look at.
-
Senior Member
registered user
.
Two other building blocks seem to be
Code:
xscreensaver-command -watch
and the following perl program, which tracks the output of the -watch command
and reacts accordingly:
Code:
#!/usr/bin/perl
my $blanked = 0;
open (IN, "xscreensaver-command -watch |");
while (<IN>) {
if (m/^(BLANK|LOCK)/) {
if (!$blanked) {
# **** action to take when screensaver starts ****
$blanked = 1;
}
} elsif (m/^UNBLANK/) {
# **** action (if any) to take when screensaver is reset ****
$blanked = 0;
}
}
I don't think perl should be necessary, and there is probably a simpler
bash equivalent that would suffice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
![Vintage Computer, Memorex Storage Unit For Main Frame Computer 1986, Movie Prop picture](/store/img/g/O4EAAOSwQgJisRdE/s-l225/Vintage-Computer-Memorex-Storage-Unit-For-Main-Fra.jpg)
Vintage Computer, Memorex Storage Unit For Main Frame Computer 1986, Movie Prop
$995.00
![IBM mainframe server cpu IBM93 vintage cpu collector's item picture](/store/img/g/EYQAAOSwzWxmThYD/s-l225/IBM-mainframe-server-cpu-IBM93-vintage-cpu-collect.jpg)
IBM mainframe server cpu IBM93 vintage cpu collector's item
$125.99
![*PAIR* 1960's Vintage GE-600 Series Mainframe Computer PCBs Bitslice Accumulator picture](/store/img/g/-qYAAOSwP21mTl9Q/s-l225/-PAIR-1960-s-Vintage-GE-600-Series-Mainframe-Compu.jpg)
*PAIR* 1960's Vintage GE-600 Series Mainframe Computer PCBs Bitslice Accumulator
$14.95
![Vintage IBM 4341 / 4361 / 4381 MCM Processor Mainframe CPU picture](/store/img/g/vw0AAOSwTFRmRYkE/s-l225/Vintage-IBM-4341-4361-4381-MCM-Processor-Mainframe.jpg)
Vintage IBM 4341 / 4361 / 4381 MCM Processor Mainframe CPU
$120.00
![Rare Retro Vintage IBM Mainframe Board Module w/44 Gold IC Chips / Collector picture](/store/img/g/560AAOSw0S9mRp3a/s-l225/Rare-Retro-Vintage-IBM-Mainframe-Board-Module-w-44.jpg)
Rare Retro Vintage IBM Mainframe Board Module w/44 Gold IC Chips / Collector
$109.95
![Digital DEC LK201 Terminal Keyboard RJ11 Connection Mainframe picture](/store/img/g/VXwAAOSwyJVmVl5x/s-l225/Digital-DEC-LK201-Terminal-Keyboard-RJ11-Connectio.jpg)
Digital DEC LK201 Terminal Keyboard RJ11 Connection Mainframe
$49.00
![Rare Retro Vintage IBM Mainframe Board Module w/44 Gold IC Chips / Collector picture](/store/img/g/JtoAAOSwa6hmRp6M/s-l225/Rare-Retro-Vintage-IBM-Mainframe-Board-Module-w-44.jpg)
Rare Retro Vintage IBM Mainframe Board Module w/44 Gold IC Chips / Collector
$119.95
![Sun Microsystems Ultra ENTERPRISE 4000 Server Vintage Mainframe Computer picture](/store/img/g/TuMAAOSwEIlmYl9w/s-l225/Sun-Microsystems-Ultra-ENTERPRISE-4000-Server-Vint.jpg)
Sun Microsystems Ultra ENTERPRISE 4000 Server Vintage Mainframe Computer
$2750.00
![Lotus Works Vintage Software 3.5in Disks Original Seal 1990 Mainframe Collection picture](/store/img/g/sAIAAOSwl1VlRTR9/s-l225/Lotus-Works-Vintage-Software-3-5in-Disks-Original-.jpg)
Lotus Works Vintage Software 3.5in Disks Original Seal 1990 Mainframe Collection
$383.99
![AOC 14in Monochrome Monitor MM-413S VGA Mainframe Collection RARE 1993 picture](/store/img/g/uFQAAOSw4ZtlZAZU/s-l225/AOC-14in-Monochrome-Monitor-MM-413S-VGA-Mainframe-.jpg)
AOC 14in Monochrome Monitor MM-413S VGA Mainframe Collection RARE 1993
$199.99