Tag: linux tips

I have a solution, this is how i manage solve this “irritating problem”.

I assume that you have a Z-wave base, mine is a raspberryPi with a razberry chip and with software domoticz.

You shoppinglist:
1pcs Inline Smart Energy Switch from Aeon Labs
1pcs Motion sensor from Fibaro
In sweden you can get all you need at www.m.nu

Aeon Labs – Switch

Fibaro motion sensor


And I use a LUA script named script_time_PIR-tv.lua. So after 20 minutes of inactivity in livingroom, the tv shutsdown… Simply as that!

function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
commandArray = {}
-- Set length of time light should be on for in seconds
timeon = 1200
-- Calculate time since time PIR was last activated
difference = timedifference(otherdevices_lastupdate['Vardagsrum motion'])
-- If the time since last activation was within 1 minute of time for light to stay on
if (difference > timeon and difference < (timeon + 61)) then
tempdiff = tostring(difference)
tempmessage = "Switch1 Light Off - after at least " .. (timeon+1) .. "secs up - actually - " .. tempdiff .. "seconds"
-- Switch off Switch1
commandArray['Tv'] = 'Off'
return commandArray


My webbserver act as a torrentclient as well.

To start rtorrent in background I using the command screen to do this.

This is how I do:
In terminal type,

bash-4.2$ screen -dmS rtorrent rtorrent

Your have now started rtorrent in a screen named rtorrent, how to access is just type

bash-4.2$ screen -r rtorrent

and there you have it.
And to exit, hold on Ctrl and A release and then press D. Now your are out of rtorrent screen and it still running i background.

Are you like me that you have a habbit to listen to music when programming in linux and you struggle with mplayer to stream a radiostation?

In your home folder your have a file that names .bashrc if your don’t have one just create one. That file in loaded when you log on and here you can create short commands.

Mine look like this.

alias litefm='mplayer -playlist http://www.litefm.se/live.m3u'
alias radioseven='mplayer -playlist http://www.radioseven.se/128.pls'
alias xterm='xterm -bg black -fg white'
alias jonathan='cvlc &'
alias framsidan='cvlc &'

Add these line to your file and logout and now login and try command litefm in your terminal. And now your are streaing a radiostation from Trollhรคttan – Sweden.

Here is one simple way to unzip multiple zip files in linux thru console.

bash-4.2$ for i in *.zip; do unzip -d $i.folder $i; done