1

I have friend that leaves an awful amount of time his laptop unattended. Its is not me, it would be stupid tip for thieves to ask this publicly if it was me :p.

I was thinking of an alarm that could boost the volume and fire up in case someone would unplug my friend's computer and take it.

Of course it would be useless if someone would plug some headphones or remove the battery, but still this could be a "life" saver in case of an unfortunate event.

If not, is there a terminal command to check if the battery is still plugged? Maybe an easy bash script can be made for this effect.

1
  • If you value your laptop or the data on it, you never leave it unattended. Otherwise learn through loss. End of story. What's next? Tazers, so that someone who just wanted to move the laptop a few inches without criminal intent gets shocked? The owner takes responsibility, not the hardware itself.
    – LiveWireBT
    Apr 20, 2013 at 7:08

2 Answers 2

4

The following bash script will check the state of the battery every 5 seconds. If the state is "discharging", it enters an alarm loop where it maximizes the master system volume and rings the terminal bell every 0.1 seconds until the state is returned to something other than "discharging". Attempting to mute the system will not silence the script, as it will set the system volume back to the maximum value at every inner loop iteration. The purpose of the slower outer loop is to minimize the impact of the state checks on your system resources.

#/usr/bin/env bash

cmd="upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -i state"

while true
do
  result=`eval $cmd | awk '{print $2}'`
  if [ $result == "discharging" ]
  then
    while [ $result == "discharging" ]
    do
      amixer set Master 100
      echo -e '\a'
      sleep .1
      result=`eval $cmd | awk '{print $2}'`
    done
  fi
  sleep 5
done

You can set this to run at system boot by running crontab -e and then adding something like @reboot /path/to/script, where the path points to this script.

You can kill the script by running top and finding a bash process with a very low PID (since it started right at system boot), and then feeding its PID to kill.

2

My earlier comment lacked a good explanation and may not have conveyed the initial message properly, therefore I'll try my best to write a better understandable answer. Please note that tough you wrote on behalf of a friend I'll be writing "you" where I mean your friend. It's for other potential readers that seek for such a solution and for convenience.

Alarms mostly do not work as they were intended or they do harm people. An alarm should alert people with the message: there is something going on here that should not happen, please look after it. In this scenario you are relying on other people to take responsibility for a device that you as an owner did not want to take. This is crazy.

If you want other people to take care of something for you just ask them kindly. If you don't trust them, then an alarm would not add anything security wise, it would be as if there is noboddy there except the potential attacker and s/he would not care if an alarm goes off. If s/he has just interest in the hardware, s/he would just turn the device off, pretending to be the owner and walk away. (There are also several security attacks against software and data, some of them have been showed off by Darren Kitchen on HAK5.) This is the usual scenario where an alarm does not alert and therefore does not work. I know, there is the scenario where the alarm is so powerful that it physically harms people and might keep attackers away. For 4-5 seconds, that is. That's how long it takes to shut the device down. But what right have you to harm all the other people sitting there, that do you no harm just for some fake sense of security for a device that you yourself as an owner do not want to take proper responsibility of?

Also note that some people like me manage to bring that 5 seconds down to almost zero by throwing the offending device out of the window, applying force or do other things. And also note that I take noise dampening ear plugs with me where ever I go and more people might be doing the same if this false sense of (IT-)Security gets popular.

Alarms do not work in the public, neither do surveilance cameras. There have been numerous cases where people where getting robbed and molested with cameras waching. Therefore: taking your device with you is the best protection.

I don't want to accuse anyone of deliberately doing harm to other people and I don't want sound depressed and fed up with society. I am just asking you to at least take responsibility for your own stuff, because if you don't do, other people will think the same way about their stuff and other people. You can imagine where this leads us to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .