TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Taking pictures with your Linux Laptop every time the lid opens

1 点作者 interesse超过 14 年前
As there is this apparent meme about taking pictures on opening a laptop lid, I thought about sharing my little hack for machines running Gnome. Save this somewhere and have it started every time you log in:<p><pre><code> #!/usr/bin/perl my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'\""; open (IN, "$cmd |"); while (&#60;IN&#62;) { if (m/^\s+boolean false/) { `mkdir -p ~/Bilder/snapshots`; `notify-send -u low -i gtk-orientation-portrait --expire-time=3000 'Smile!' "Taking photo in 3 seconds.\nSaving in ~/Bilder/snapshots/"`; sleep 3; my $date="`date +%y.%m.%d-%H:%M`"; `ffmpeg -s 1280x720 -f video4linux2 -i /dev/video0 ~/Bilder/snapshots/$date.jpg 2&#62;&#38;1 &#62;/dev/null`; } } </code></pre> When I made this a couple of days ago I originally didn't thought about releasing it. It was just a little evening amusement. But maybe somebody finds it amusing as well.<p>A little off topic: I wanted to do this as a shell script originally, but how would one implement the "while read from pipe" part in bash?

暂无评论

暂无评论