Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Well i was just thinking of having an app or a feature which enables you to play music even the laptop lid is shut close. what i want is that the screen should be locked ie no one should be able to do any other thing and at the same time my music should be contiued to play; virtually turning my lid-turned down laptop into a musical jukebox, ie a musical screen saver of sorts. Can anyone help me in achieving this? Any hints?

share|improve this question
you when the laptop lid is closed you want: 1. all processes killed, 2. music player started. or do you want 1. xlock started 2. music player started, or do you want 1. all x applications killed 2. xlock started 3. music player started. you need to be more clear about what exactly you need! – Janus Troelsen Jan 18 '13 at 12:49
I want music player started and xlock started – MKJ Jan 18 '13 at 19:01

You could try putting this in a file, marking it executable, and referencing it in your xinit or rc.local:

while true
do grep -v open /proc/acpi/button/lid/LID0/state
  if [ $? ]; then
    killall mplayer
    pidof mplayer; if [ $? ]; then screen -d -m "sh -c 'mplayer -loop 0 -novideo /usr/share/example-content/Ubuntu_Free_Culture_Showcase/*' "; xlock; fi
  sleep 1

It's pretty straightforward, ask me if you have questions. Obviously it will only work problem-free if you do not use mplayer while using it.

share|improve this answer
I opened a music file in vlc media player and then closed the lid of my laptop. But after sometime it stopped playing . – MKJ Jan 20 '13 at 4:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.