[{"data":1,"prerenderedAt":52},["ShallowReactive",2],{"\u002Ftlt-2009.05.08-pause-my-music":3},{"id":4,"title":5,"body":6,"createdAt":39,"description":12,"draft":40,"extension":41,"image":42,"mastodonThread":42,"meta":43,"navigation":44,"path":45,"seo":46,"stem":47,"tags":48,"updatedAt":50,"__hash__":51},"content\u002FTLT - 2009.05.08 - Pause My Music.md","TLT_-_2009.05.08_-_Pause_My_Music",{"type":7,"value":8,"toc":36},"minimark",[9,13,22,25],[10,11,12],"p",{},"Tags: perl, linux, music",[10,14,15,16,21],{},"Oh how I love linux... perl... scriptability. I have a fun little command line music player named ",[17,18,20],"a",{"href":19},"\u002Fpolly","Polly",". It is pretty minimalist, really just starting whatever player I like with whatever preferences I like on a whole directory tree of files. One thing that is annoying is that I have to switch over to the terminal and it ^Z to pause and then do 'fg' to play.",[10,23,24],{},"So I finally decided to write a simple pause toggle script. I approached this in the most brute force way I could... I just take the list of all my media players and send a massive STOP (effectively ^Z) command to all to pause, and then a massive CONT (effectively 'fg') to all to continue. To determine if I want to pause or continue, I just look to see if I have any paused player processes.",[26,27,32],"pre",{"className":28,"code":30,"language":31},[29],"language-text","my @commands = qw( ogg123 mpg123 mplayer vlc sidplay2 );\nmy $cmd = join '\\|', @commands;\n\nif(`ps a -o state,cmd | grep '$cmd' | grep ^T`) {\n  map { `killall -SIGCONT $_ 2>\u002Fdev\u002Fnull` } @commands;\n} else {\n  map { `killall -SIGSTOP $_ 2>\u002Fdev\u002Fnull` } @commands;\n}\n","text",[33,34,30],"code",{"__ignoreMap":35},"",{"title":35,"searchDepth":37,"depth":37,"links":38},2,[],"2009-05-08T16:03-04:00",false,"md",null,{},true,"\u002Ftlt-2009.05.08-pause-my-music",{"title":5,"description":12},"TLT - 2009.05.08 - Pause My Music",[49],"blog","2009-07-11T19:19-04:00","FWSRxhnU4zIfgoBJKftPzwYos3jj4QnCW6oHIYSkdb4",1778988314270]