Suramya's Blog : Welcome to my crazy life…

July 17, 2019

Using Machine Learning To Automatically Translate Long-Lost Languages

Filed under: Computer Software,Interesting Sites,My Thoughts — Suramya @ 1:25 PM

Machine Learning has become such a buzz word that any new product or research being released nowadays has to mention ML in it somewhere even though they have nothing to do with it. But this particular usecase is actually very interesting and I am looking forward to more advances in this front. Researchers Jiaming Luo and Regina Barzilay from MIT and Yuan Cao from Google’s AI lab in Mountain View, California have created a machine-learning system capable of deciphering lost languages.

Normally Machine translation programs work by mapping out how words in a given language are related to each other. This is done by processing large amounts of text in the language and creating vector maps on how often each word appears next to every other word for both source and target languages. Unfortunately, this requires a large dataset (text) in the language and that is not possible in case of lost languages, and that’s where the brilliance of this new technique comes in. Focusing on the fact that when languages evolve over time they can only change in certain ways (e.g. related words have the same order of characters etc) they came up with a ruleset for deciphering a language when the parent or child of the language being translated is known.

To test out their theory/process they tried it out with two lost languages, Linear B and Ugaritic. Linguists know that Linear B encodes an early version of ancient Greek and that Ugaritic, which was discovered in 1929, is an early form of Hebrew. After processing the system was able to correctly translate 67.3% of Linear B into their Greek equivalents which is a remarkable achievement and marks a first in the field.

There are still some restrictions with the new algorithm in that it doesn’t work if the progenitor language is not known. But work on the system is ongoing and who knows some new breakthrough might be just around the corner. Plus there is always a brute force approach where the system tries translating a given language using every possible language as the progenitor language. It would require a lot of compute and time but is something to look at as an option.

Well, this is all for now. Will write more later.

– Suramya

Source: Machine learning has been used to automatically translate long-lost languages

July 11, 2019

Yelagari Hills road trip

Filed under: My Life,Travel/Trips — Suramya @ 11:17 PM

This weekend we had planned to go for a Trek but as Jani had hurt her back we had a last min change of plans and instead went to Yelagiri hills. When I say last min, I do mean last min. We booked the stay about 10 hours before we left home. Since there were seven of us making the trip I wanted to rent a 7-8 seater car so that all of us can travel together, but since it was last min we were unable to find a car. Thankfully Shashank wanted to do a long bike ride so he and Shahrukh decided to make the trip on his bike and the rest of us took my car.

As usual we planned on leaving early from home to avoid the lovely Bangalore traffic. We had an early breakfast at home (Shahrukh & Jani made French toast) and we started at ~6:30am from home. The drive was quite nice and the company was better. The place we were staying at (Yelagiri Farm House) was ~150Kms from home and it took us about 3 ½ hours to make the drive with a single break for Tea/Coffee. The last stretch of the drive was though the hills and the views were amazing but since everyone except me was sleeping in the car they missed most of it. In a way that is good as most of them suffer from motion sickness and anything that avoids people throwing up in my car is good in my books. I had a blast singing while everyone was sleeping (Though I am not sure how they managed to sleep through my singing).

The Farm house was on a large property with nice big rooms. To give you an idea of the size all 7 of us could have comfortably stayed in 1 room. But we had multiple rooms so it was good. Once we reached the venue we just chilled and had our 2nd breakfast for the day. The weather was nice and cool so it was great sitting outside in the open relaxing.


Having the second breakfast of the day

After talking to the owners we found out that there were a few adventure camps near the farmhouse so after relaxing for a while we decided to check out the options. Shashank and Shahrukh explored and we found a nice place that had multiple options of games we could play. Since it was lunch time we had our lunch which was ok. The non-veg food was a lot better than the veg options as per the comments I heard during lunch but it still wasn’t bad. Post lunch we went to the Adventure camp and decided to do the Obstacle course, Artificial wall climbing and Zorbing.


Outside the Adventure Camp after lunch

The obstacle course was interesting and a few of the obstacles were a bit challenging but overall it was a lot of fun. The six of us attempted the course while Jani relaxed on the side and took pics. None of us fell so that was good and there was a lot of good natured ribbing going on when someone got stuck. One of the participant went into ‘pure survival mode’ when they got stuck but everyone made it through in one piece (and no I am not naming them).


Obstacle course at the Adventure Camp

The second activity we attempted was the climbing wall which was fairly challenging and only Bagri and Shashank made it to the top while a few of us remaining were close but didn’t make it to the top.


Artificial Climbing wall

The last activity we did was Zorbing. Usually this is done on a hill where you are rolled down a hill but over here the Zorb was floating in the water and all 6 of us got in at the same time. It’s a great place to be when you are with friends and we rolled around in abandon in the Zorb. Akanksha was elbowed in the face (by me. Sorry) and I had Shahrukh and Ayush both land on my back at the same time. If I start listing out all the other times folks fell on each other I will need a couple of pages. In all the 15 mins we spent in there was amazing and we were exhausted after we were done. Finally we had to head back as none of the other sports looked interesting (I did want to try the paintball but not everyone was interested so we left it.). Right outside the arena there were a lot of fresh fruit sellers and we ended up buying almost every single option available (except Jackfruit because it stinks).


Playing Frisbee

After we got back to the farmhouse, we spent a good amount of time playing in the field starting with Frisbee followed by cricket. Akanksha was given the woman of the match award for making the most runs in the first match. Once it got dark and we could hardly see the ball we retired to the room and switched to indoor games.
The first game we played was twister and it was a blast. Watching some of the positions people ended up in was hilarious (when it happened to others, not when you were in the position). We played a couple of rounds with Jani and a rotating set of people acting as a referee. It is a great party game but needs to be played with people who know each other quite well else it can get a bit awkward. After we were tired from Twister we switched to Jenga and it was fun as always. Some of the moves were brilliant and some were so bad that they should be admitted to the bad move hall of fame. Finally it was time to call it a day since all had been awake since early morning and I just crashed. I think Jani was talking to me when I dozed off.

Next day we woke up around 8, had breakfast where we made sandwiches and tried all the fruits we bought the previous day. This was followed by a few rounds of cricket and general fooling around.


Group Photo in front of the Farmhouse

Finally we had to leave because we didn’t want to be too late getting into Bangalore so with a heavy heart we started back. This time everyone in the car was awake for the hairpin turns that took us back to the plains and thankfully the anti-motionsickness tablets worked so that was great. The drive back was fairly uneventful, with one long stop for a tea break. We started off with just tea (juice for some) and then ended up making and having sandwiches from our stockpile. Thankfully we bought enough from the vendor that we didn’t get kicked out for having our own food.

The drive back took a bit longer thanks to the increased traffic but was manageable, at least till we entered Bangalore post which it was the standard disaster we call traffic management in Bangalore.

After we reached home, we chilled for a while and then everyone headed home ending an eventful trip. We had so much fun that we have already started talking about the next trip.

Well, this is all for now. Will post more later.

– Suramya

May 27, 2019

Microsoft and Brilliant launch Online Quantum Computing Class that actually looks useful

Filed under: Computer Software,Interesting Sites,My Thoughts,Techie Stuff — Suramya @ 12:14 PM

Quantum computing (QC) is the next big thing and everyone is eager to jump on the bandwagon. So my email & news feeds are usually flooded with articles on how QC will solve all my problems. I don’t deny that there are some very interesting usecases out there that would benefit from Quantum Computers but after a while it gets tiring. That being said I just found out that Microsoft & Brilliant have launched a new interactive course on Quantum Computing that allows you to build quantum algorithms from the ground up with a quantum computer simulated in your browser and I feel its pretty cool and a great initiative. The tutorial enables you to learn Q# which is Microsoft’s answer to the question of which language to use for Quantum computing code. Check it out if you are interested in learning how to code in Q#.

The course starts with basic concepts and gradually introduces you to Microsoft’s Q# language, teaching you how to write ‘simple’ quantum algorithms before moving on to truly complicated scenarios. You can handle everything on the web (including quantum circuit puzzles) and the course’s web page promises that by the end of the course, “you’ll know your way around the world of quantum information, have experimented with the ins and outs of quantum circuits, and have written your first 100 lines of quantum code — while remaining blissfully ignorant about detailed quantum physics.”
Brilliant has more than 8 million students and professionals worldwide learning subjects from algebra to special relativity through guided problem-solving. In partnership with Microsoft’s quantum team, Brilliant has launched an interactive course called “Quantum Computing,” for learning quantum computing and programming in Q#, Microsoft’s new quantum-tuned programming language. The course features Q# programming exercises with Python as the host language (one of our new features!). Brilliant and Microsoft are excited to empower the next generation of quantum computer scientists and engineers and start growing a quantum workforce today.

Starting from scratch

Because quantum computing bridges the fields of information theory, physics, mathematics, and computer science, it can be difficult to know where to begin. Brilliant’s course, integrated with some of Microsoft’s leading quantum development tools, provides self-learners with the tools they need to master quantum computing.
The new quantum computing course starts from scratch and brings students along in a way that suits their schedule and skills. Students can build and simulate simple quantum algorithms on the go or implement advanced quantum algorithms in Q

Once you have gone through the tutorial you should also check out IBM Q that allows you to code on a Quantum computer for free.

– Suramya

May 26, 2019

Why on earth are Indian news channels announcing the launch of ‘Spy Satellites’?

Filed under: My Thoughts — Suramya @ 10:26 PM

When other countries launch spy satellites the mission is top secret and hardly anyone knows about it. So I had a bit of a shock on Thursday when I was walking past a TV in the cafeteria at work and noticed a news ticker stating “ISRO launched spy satellite successfully” on screen. I had a good laugh about it with the folks I was with and then promptly forgot about it. However yesterday I was looking at the election news and ended up at the following Economic times article: “ISRO launches ‘cloud-proof’ earth observation spy satellite RISAT-2B to keep an eye on Pakistan” which reminded me about the launch so I just had to post about it.

If we are advertising our spy satellite launches then we are giving foreign assets enough information to figure out the orbit and timings where the satellite would be over head (unless it was in a geo-stationary orbit) giving them the ability to hide activity from them. For example when the Pokhran test was done it 1997 it was a surprise for the US in spite of the massive satellite coverage US has because we had a mapping of when each of the satellites pass over India allowing india to build up preparations over months so as not to indicate any sudden heightening of activity and performing critical jobs during satellite “blind” periods when they are beyond the reach of Pokhran.

Now by announcing the launch we are making it easier for other countries like Pakistan to duplicate this feat. Since they know the launch details it makes it easier to track the orbit of the payload and narrow down the search for the satellite if they didn’t locate it when it was released in orbit.

Press freedom is well and good but I don’t think it makes sense to announce such news to the world.

– Suramya

May 24, 2019

Science is bringing personal cooling closer to reality with a wearable cooling Patch

Filed under: Interesting Sites,My Thoughts — Suramya @ 6:03 PM

In an announcement that is going to cause a lot of couples to sigh in relief, researchers from University of California, San Diego have come up with a wearable patch that cools the skin temperature down by ~10 Deg C. It is still in research phase but the basic prototype works and I am definitely in queue to buy this when it comes out. I love cool temperatures and my wife is the polar opposite and prefers hot and humid weather (30 Deg + ) so usually one of us is suffering. Its gotten to the point that I know that if I am feeling comfortable then she is cold. We usually end up carrying an extra jacket for her when we travel to moderately cold places and lots of cold water for me if we are going somewhere where she would be comfortable. This would allow us to keep the house warm enough for her without making me miserable due to the heat. According to the press release:

Thermoelectric systems use semiconductors to pump heat from one side of a device to the other, creating a cool zone and a hot zone. Such systems can provide compact, easily adjustable cooling, but getting them to efficiently dissipate heat has proved challenging.

Renkun Chen, Sheng Xu and their colleagues at the University of California, San Diego, addressed this problem by embedding multiple pillars of a semiconducting material between two stretchy polymer sheets. One sheet served as the hot zone, the other as the cool zone. This design conferred flexibility and insulated the hot and cold sides from each other, allowing the hot layer to dissipate its heat into the air.

This system would also have an application in offices. Usually the temperatures in office are kept cool because of research in early 60’s that calculated the optimal temperature taking into account the comfort of a forty-year-old, hundred-and-fifty-four-pound man wearing a business suit, (Learn more about the Sexist history of Office temperature here if you are interested) and this means that women in offices usually freeze and don’t perform at the peak of their performance. Once this patch is released, the office could be kept at a warmer temperature making it more comfortable for the women (and folks not wearing jackets/suits to office) and anyone who dislikes the warmer temperature (like me) would wear this patch and be comfortable as well. Decreasing the cooling required would reduce the load on AC’s and power infra as well.

So in conclusion I hope that this gets a commercial release quickly. 🙂

Source: Air conditioner ‘in a patch’ provides portable cooling – Nature.com

– Suramya

January 22, 2019

Is notifying HR dept where Offenders work a good way to reduce Drunk Driving?

Filed under: My Thoughts — Suramya @ 11:21 PM

While waiting for my flight to Bangalore I was refreshing my Twitter feed to stave off boredom and one of the tweets caught my attention. The tweet was as below:

So employers are the new mummy-papa? The state should treat adults like adults. Punish them as per law, throw them into jail, but please spare everyone this nanny nonsense.

and the image attached to the tweet is as below:

I checked out the image attached and was reading the replies and one of the commenters had posted something to the effect of “The cops shouldn’t be doing this as this could destroy the persons career if HR knows about their habit of drinking and driving.” This comment sparked an immediate reaction which is what led to this post. From a quick check on the internet the letter appears to be real and there is a very polarized debate ongoing about it. I will be replying back on the Twitter thread as well with a link to this post but wanted a blog post as it gives me more space to give context.

Basically, drinking and driving is a big problem in India. Even in cities like Bangalore where there are frequent checks for DUI, I personally know people who drink & drive. They use strategies like waiting for an extra hour after closing time/event end to avoid cops. Some of them take the back roads to avoid known blockades location for testing. If I can, I do try to get people to take cabs back but its an uphill battle. In one case this guy could barely stand but wanted to ride his bike home and when I told him to take a cab his reply was “It’s ok I will be fine once I am on the bike” as if it would magically make him sober. In 2017 73,741 drunk driving cases were registered in Bangalore. I couldn’t find the numbers for 2018 but am still searching, I will update the post if I find it. The article didn’t have the breakdown on how many repeat offenders were there in the list but I wouldn’t be surprised if a significant count was from repeat offenders. A lot of the folks don’t care about the fine or think that paying a bit of money is a good option to get away with something that risks lives.

It would be one thing if they were only risking their own lives but they also end up killing innocent people in accidents. Take this incident from New Years 2019 in Mumbai where a drunk driver killed a class 9 student who was waiting for his friend alongside a road and had the bad luck of being at the wrong place at the wrong time. We have to face facts, fines are not working as well as we want them to. People still think that they can get away with this behavior with minimal consequences.

The fix is to increase the stakes. The cops first tried to do that by increasing the fines and jail duration but that hasn’t had such a major impact. So the question becomes how do we raise the stakes further? One way would be to do what Hyderabad cops are doing and start notifying the HR department of the companies where the offenders work, in cases of repeat offenders or when people are significantly over the allowed limit. If you know that your job might be impacted when you drink and drive then a lot of people will think twice about doing it. To clarify I am not saying that this should be done everytime. I think that they shouldn’t do this when the person is over the limit by a small amount e.g. if they had 3 glasses instead of 2 but if they had 10 glasses (for example) then yes their offices should be told and the HR will take a call if they want to have such a reckless employee working for them and what action if any should be taken against them.

As for the impact on the job/wreak the career of a person driving under the influence I have just this to say “Good”. Why should we be concerned about the impact to the career of someone who drives under the influence and refuses to take accountability for their actions? Shouldn’t we be more concerned about the impact to the families who lose loved ones to these senseless drivers? What about the impact to people who are crippled in drunk driving related accidents?

What do you think?

– Suramya

January 8, 2019

Welcoming 2019 at Winterburn Festival, Sakleshpur

Filed under: My Life,Travel/Trips — Suramya @ 1:08 AM

Happy New Year! We (Jani & Me) don’t like doing the usual Party/get-drunk/passout for New Years so each year we try to come up with something more interesting and unique. This year we decided to go to WinterBurn which is a Music Festival/Camping event in Sakleshpur organized by Motorcycle Diaries. Initially only the two of us were going but then Ayush, Akanksha & Dipika decided to join us as well which made the trip more fun.

We started the trip early in the morning (5am) on the 29th with a light breakfast and lots of caffeine. The drive down was quite nice as we missed the lovely Bangalore traffic by leaving so early in the morning and we took about 4 hours to reach the venue even though we stopped a few times for tea/coffee and watermelons. When we reached the address we had to do a bit of off-road driving on a muddy track to get to the field where the event was being held. I would not recommend that you take any car with low clearance for this kind of trip as even with the new Honda Citi’s increased ground clearance we scraped the bottom of the car a few times during this last stretch and each time that happened it hurt me more than the car. 🙂

When we reached the place we had a pleasant surprise that we were allocated 2 cottages and a tent instead of 1 cottage, 1 shack and 1 tent. Plus the front of the cottages faced away from the rest of the dormitories so we had a bit of privacy with a nice sitting area in from of the cottages that faced the plantation. So we had pepper & coffee plants about 10 mts from our door and it was quite nice. Since we reached before the food trucks had finished setting up we joined the various artists for a late breakfast of local food which was surprisingly quite tasty (yes I have had bad experiences with local food a few times).


Early morning Breakfast

As nothing was planned for the day till late evening we spent the day doing a bit of relaxing Yoga to stretch our backs thanks to Dipika followed by a lovely walk around the estate. Saw a whole bunch of plants and even though Jani tried her best to tell us about each of the plants I kind of zoned out and just enjoyed the walk in nature. We did find some wild chilies that we picked for eating but still haven’t tried them. After the walk we just hung out and chilled for the most part. We spent a while talking and catching up with each other as some of us hadn’t met in a while or were meeting for the first time.


Stretching Akanksha’s back after the bumpy ride


Ayush, Me and Jani stretching our backs outside the cottage.


Dipika walking Akanksha, me and Jani through some stretching exercises for the back.


Just Chilling at the camp

Since we had an early start and nothing was happening at the event we decided to call it a night and crashed earlier than normal. The next day there was supposed to be a Yoga session organized at 6am but none of us woke up in time for it. The food-truck’s food wasn’t that great and since we had packed enough supplies for breakfast (the plan was to have it while driving to the venue but after eating watermelon we didn’t have space) Jani made sandwiches for all of us along with salad and Tea.


Breakfast courtesy Jani

After seeing the sad state of the festival the day before we decided to not spend the day at the venue and went on a drive to check out some of the local attractions near us. Using Google Maps we found a few locations that looked interested and started the day with a visit to Shettihalli Rosary Church which was about an hours drive away on some very picturesque and narrow roads. The drive took us a bit longer since we stopped a few times to enjoy the scenery and to pluck Imli (tamarind) directly from a roadside tree and eat it raw.


Jani trying to feed me raw Imli

The Shettihalli Rosary Church was built in the 1860s by the French missionaries and was abandoned in 1960 after the construction of the Hemavati Dam. The gothic architecture of the church gives it a haunted feel and even though its only been abandoned for ~60 years it looks a lot older and spookier. We spent about an hour at the church taking pics and admiring the view after which we decided to get some lunch as we were hungry. Lunch was at this little hole in the wall restaurant that kind of looked shady from the outside and you really had to know it was there to find it but it was one of the best lunches I have had in a while. The food was filling, tasty and only cost us Rs 230 total (for all 5 of us) including coffee.


Group Pic at the church

After lunch we drove over to Manjarabad Fort which was built in 1792 by Tipu Sultan. It is in ruins now but at its peak it would have been extremely difficult to attack due to its commanding position on top of a hill. Spent a bit of time exploring before we were kicked out when the place shut down for the night. Interestingly the way they make sure that everyone leaves the fort for the night is by herding everyone to the main gate of the castle that is locked, once the guy inside makes sure there are not stragglers he comes and opens the gate to let everyone out and prevents people coming back inside. It would have been a lot more efficient if there were two people doing this but it works so… can’t really complain. We had a round of coconut water and drove back to base where we hung out in our cabin for a while. The stage was finally setup so a few bands did play but nothing that really stuck out and made us want to sit outside. Went to sleep early again with a plan to *try* going for the 6am yoga classes but once again no one woke up on time for it.


Group pic at the Fort

We freshened up and decided to check out some of the workshops that were running. Ayush, Akanksha and Dipika tried their hands at pottery making while me and Jani watched and made fun of their skills. After lunch we joined the Dreamcatcher workshop run by Meghana. This was a great workshop and I realized that even though it looks easy to make it requires a lot of concentration and skill. Unfortunately Meghna refused to let me and Ayush use a rectangle as the base design so we spent the next 5 hours trying to keep threads tight enough and the design normal enough that it didn’t look like it was made by a drunk spider. After much sweat and tears we finally managed to create our dreamcatchers. By this time the bands were prepping so we freshened up and walked over to the stage.


Jani focusing on ensuring all the threads were tight


Ayush and Akanksha trying their hands on Dreamcatcher making

The first few bands were quite good but unfortunately the crowds we had expected/been promised didn’t materialize. In fact there were about 60-65 people total at the event out of which about 50 were the artists and workshop people. We sat next to the bonfire for a while but then the music wasn’t much to our taste so we went back to the room and all of us snuggled under the blanket waiting for midnight. As soon at it was midnight we wished each other and within 10 mins after that we were all fast asleep.


Happy New Year! Welcoming 2019 snuggled in bed.

We all woke up late the next day and properly wished each other since we were all barely awake at midnight. After another round of sandwitches/salad made by Jani we all packed up and headed back to Bangalore. It took us a lot longer to drive back due to the increased traffic and stops.

Reached back home around 8pm after dropping Dipika on the way. Had a late dinner with Jani, Ayush and Akanksha thanks to Swiggy and that’s how we ended 2019’s first trip. Overall the trip was fun though I was disappointed with the music festival. That being said Gagan (the organizer) did refund part of the money to us so I can’t really complain much. If it was just me and Jani doing the trip alone then it would have been a lot more boring but the excellent company made it fun.

Well this is all for now. Will post more later.

– Suramya

September 9, 2018

Meet my new neighbors – Baby Pigeons!

Filed under: My Life — Suramya @ 1:14 PM

I have some new neighbors – a pair of Baby Pigeons are now happily living in my bedroom windowsill. I missed taking the photo earlier because the mom was always on or near the nest and I didn’t want to disturb/scare her into abandoning the nest.


Baby Pigeons!

I will be happy when they grow up and fly away because then I can resume scaring the other pigeons away as they are loud and very annoying in the morning.

– Suramya

September 6, 2018

There is now a company in Japan that resigns from your job for you.

Filed under: My Life — Suramya @ 6:16 PM

There is a startup in Japan which a person can to submit resignation notices to employers on their behalf. At first when I read the article I thought it was one of the more ridiculous ideas for a startup that I had heard about. However it stuck in my mind and I kept thinking about it, then I remembered how hard working Japanese people are and how strongly they believe in staying with one company for their entire carrier. In 2016, the average worker in Japan had been at one company for about 12 years so there is a strong stigma against quitting even if you are miserable at your job. Now there is a service called ‘Exit’ that offers a way around that.

“Quitting jobs can be a soul-crushing hassle. We’re here to provide a sense of relief by taking on that burden,” said Toshiyuki Niino, co-founder of Senshi S LLC, a startup he and childhood friend Yuichiro Okazaki launched last year.

The company operates Exit, a service that relays an employee’s intention to resign for a fee: ¥50,000 ($450) for full-time employees and ¥40,000 for part-time workers. Repeat clients get a ¥10,000 discount.

Whether or not people consider that expensive depends on how desperate they are. But if business is any indication, many regard it as a worthy investment for some much-needed peace of mind. In the one year since Niino and Okazaki set up shop, they have mediated the resignations of roughly 700 to 800 clients from across the nation as the number of requests surge.

I can understand the urge to offload the unpleasant task of quitting to another person/company but I feel its more healthy to face your fear and stand up for yourself. It will help increase your self-confidence and the ability to handle unpleasant situations.

Imagine what would happen if they tried to expand into India? Where at times people have offered their resignations over SMS or in some cases just not shown up for the work leaving their manager to figure out themselves that their employee is no longer interested in working with them.

What do you think? Is this a good idea or not?

– Suramya

September 3, 2018

Software hack to keep my speaker powered on

Filed under: Computer Hardware,Linux/Unix Related,Techie Stuff,Tutorials — Suramya @ 6:37 PM

A little while ago I bought a new klipsch speaker as my previous one was starting to die and I love it except for a minor irritation. The speaker has builtin power saving tech that powers it off if its not used for a certain period of time and that means that I have to physically power it on every time I wanted to listen to music which was annoying. As I would invariably be comfortably seated and start the music before remembering that I needed to power it on. Also, I could not start the music from my phone whenever I felt like as the speaker was powered off and I would have to walk to the room to power it on.

After living with the irritation for a while I finally decided to do something about it and whipped up a small script that checks if any music/audio is already playing on the system and if not it plays a 1 second mp3 of an ultrasonic beep. This forces the system to keep the speaker on and I love it as now I can start the music first thing in the morning while lazing in bed. 🙂

The script requires the mpg123 to be installed and you can install it on a Debian system by issuing the following command:

apt-get install mpg123

The Script itself is only 4 lines long:

#!/bin/bash

if ! grep RUNNING /proc/asound/card*/pcm*/sub*/status &> /dev/null ; then
    /usr/bin/mpg123 -q /home/suramya/bin/KeepSpeakerOn.mp3 &> /dev/null
fi

What it does is to check if any of the PCM soundcards have a status of RUNNING and if not it plays the mp3. I have a cron job scheduled to run the script every one min:

XDG_RUNTIME_DIR=/run/user/1000

* * * * * /home/suramya/bin/KeepSpeakerOn.sh 

One interesting issue I hit during the initial testing was that the mpg123 application kept segfaulting whenever I initiated it from the Cron but it would work fine if I ran the same command from the command prompt. The error I got in the logs was:

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.25.10; written and copyright by Michael Hipp and others
        free software (LGPL) without any warranty but with best wishes
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
/home/suramya/bin/KeepSpeakerOn.sh: line 5: 10993 Segmentation fault      /usr/bin/mpg123 /home/suramya/bin/KeepSpeakerOn.mp3 -v

Spent a while trying to debug and finally figured out that the fix for this issue was to add XDG_RUNTIME_DIR=/run/user/<userid> to the cron where you can get the value of <userid> by running the following command and taking the value of uid:

id <username_the_cronjob_is_running_under> 

e.g.

suramya@StarKnight:~/bin$ id suramya
uid=1000(suramya) gid=1000(suramya) groups=1000(suramya),24(cdrom)....

Putting that line in the cron entry resolved the issue. Not sure why but it works so…

Well this is all for now. Will write more later.

– Suramya

Older Posts »

Powered by WordPress