{"id":208,"date":"2016-03-06T10:30:00","date_gmt":"2016-03-06T01:30:00","guid":{"rendered":"http:\/\/arat.xyz\/wordpress\/?p=208"},"modified":"2016-03-06T11:22:03","modified_gmt":"2016-03-06T02:22:03","slug":"xmobar%e3%81%ae%e3%82%b9%e3%83%86%e3%83%bc%e3%82%bf%e3%82%b9%e3%83%90%e3%83%bc%e4%b8%8a%e3%81%ab%e6%96%b0%e7%9d%80%e3%83%a1%e3%83%bc%e3%83%ab%e6%95%b0%e3%82%92%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.arat.xyz\/wordpress\/?p=208","title":{"rendered":"xmobar\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u4e0a\u306b\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<div id=\"outline-container-orgheadline1\" class=\"outline-2\">\n<h2 id=\"orgheadline1\">\u7d4c\u7def<\/h2>\n<div class=\"outline-text-2\" id=\"text-orgheadline1\">\n<p> \u3053\u308c\u307e\u3067\u306fconky\u3067\u3001\u81ea\u5b85\u3001\u8077\u5834\u3001Gmail\u306e\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u8868\u793a\u3055\u305b\u3066\u3044\u307e\u3057\u305f\u3002 <\/p>\n<p> \u30bf\u30a4\u30eb\u578b\u30a6\u30a3\u30f3\u30c9\u30a6\u30de\u30cd\u30fc\u30b8\u30e3\u3067\u3042\u308bxmonad\u306b\u79fb\u884c\u3059\u308b\u5834\u5408\u3001 conky\u306e\u8868\u793a\u304b\u96a0\u3055\u308c\u3066\u3057\u307e\u3046\u305f\u3081\u4f7f\u3044\u306b\u304f\u3044\u3067\u3059\u3002\u305d\u3053\u3067\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u3067\u3042\u308bxmobar\u4e0a\u306b\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u305f\u3081\u3001\u305d\u306e\u65b9\u6cd5\u3092\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002 <\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgheadline2\" class=\"outline-2\">\n<h2 id=\"orgheadline2\">\u65b9\u6cd5<\/h2>\n<div class=\"outline-text-2\" id=\"text-orgheadline2\">\n<p> xmobar\u306b\u30c6\u30ad\u30b9\u30c8\u3092\u6e21\u305b\u3070\u305d\u306e\u901a\u308a\u306b\u8868\u793a\u3057\u3066\u304f\u308c\u308b\u305f\u3081\u3001\u300c\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u542b\u3080\u6587\u5b57\u5217\u300d\u3092\u8868\u793a\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002 <\/p>\n<\/div>\n<div id=\"outline-container-orgheadline3\" class=\"outline-3\">\n<h3 id=\"orgheadline3\">checkmail.rb\u30b9\u30af\u30ea\u30d7\u30c8<\/h3>\n<div class=\"outline-text-3\" id=\"text-orgheadline3\">\n<p> <a href=\"https:\/\/github.com\/toshi-ara\/checkmail.rb\">GitHub<\/a> \u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7f6e\u3044\u3066\u3044\u307e\u3059\u3002 <\/p>\n<p> \u30b5\u30fc\u30d0\u540d\u3001\u30e6\u30fc\u30b6\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5404\u500b\u4eba\u306e\u8a2d\u5b9a\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u307e\u3059\u3002\u3053\u306e\u6642\u3001&#8221; &#8220;\u3067\u306f\u306a\u304f&#8217; &#8216;\u3067\u56f2\u3093\u3060\u65b9\u304c\u3044\u3044\u3067\u3059 &#8221; &#8220;\u3067\u56f2\u3093\u3060\u5834\u5408\u3001@\u304c\u3042\u308b\u3068\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u305f\u3081\u3067\u3059\uff08\\@\u3068\u3059\u308c\u3070OK\uff09\u3002 <\/p>\n<p> \u4f7f\u7528\u65b9\u6cd5\u306f\u8aac\u660e\u304c\u306a\u304f\u3066\u3082\u5206\u304b\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u7b2c4\u5f15\u6570\u306f\u3001POP3\u3067\u3042\u308c\u3070&#8221;pop3&#8243;\u3001Gmail\u306a\u3069\u306eIMAP\u3067\u3042\u308c\u3070&#8221;imap&#8221;\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002 <\/p>\n<p> \u6700\u7d42\u884c\u3067\u6587\u5b57\u5217\u3092\u8868\u793a\u3055\u305b\u308b\u306e\u3067\u81ea\u7531\u306b\u5909\u66f4\u3057\u307e\u3059\u3002 <\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-ruby\"><span style=\"color: #656565;\">#<\/span><span style=\"color: #757575;\">!\/usr\/bin\/env ruby<\/span>\n<span style=\"color: #656565;\"># <\/span><span style=\"color: #757575;\">coding: utf-8<\/span>\n\n<span style=\"color: #528fd1;\">require<\/span> <span style=\"color: #bdbc61;\">'net\/pop'<\/span>\n<span style=\"color: #528fd1;\">require<\/span> <span style=\"color: #bdbc61;\">'net\/imap'<\/span>\n\n<span style=\"color: #baba36;\">$server1<\/span> = <span style=\"color: #bdbc61;\">'******'<\/span>\n<span style=\"color: #baba36;\">$name1<\/span> = <span style=\"color: #bdbc61;\">'******'<\/span>\n<span style=\"color: #baba36;\">$pass1<\/span> = <span style=\"color: #bdbc61;\">'******'<\/span>\n\n<span style=\"color: #baba36;\">$server2<\/span> = <span style=\"color: #bdbc61;\">'imap.gmail.com'<\/span>\n<span style=\"color: #baba36;\">$name2<\/span> = <span style=\"color: #bdbc61;\">'******@gmail.com'<\/span>\n<span style=\"color: #baba36;\">$pass2<\/span> = <span style=\"color: #bdbc61;\">'******'<\/span>\n\n<span style=\"color: #656565;\">########################################<\/span>\n<span style=\"color: #656565;\"># <\/span><span style=\"color: #757575;\">function<\/span>\n<span style=\"color: #656565;\">########################################<\/span>\n\n<span style=\"color: #5180b3;\">def<\/span> <span style=\"color: #6aaf50;\">get_n_mail<\/span> (server, name, pass, connect)\n  <span style=\"color: #5180b3;\">case<\/span> connect\n  <span style=\"color: #5180b3;\">when<\/span> <span style=\"color: #bdbc61;\">\"pop3\"<\/span>\n    pop = <span style=\"color: #cd5542;\">Net<\/span>::<span style=\"color: #cd5542;\">POP3<\/span>.new(server, 110)\n    pop.start(name, pass)\n    n = pop.n_mails\n    pop.finish\n    <span style=\"color: #5180b3;\">return<\/span> n\n  <span style=\"color: #5180b3;\">when<\/span> <span style=\"color: #bdbc61;\">\"imap\"<\/span>\n    imap = <span style=\"color: #cd5542;\">Net<\/span>::<span style=\"color: #cd5542;\">IMAP<\/span>.new(server, 993, <span style=\"color: #ab75c3;\">true<\/span>)\n    imap.login(name, pass)\n    imap.select(<span style=\"color: #bdbc61;\">'INBOX'<\/span>)\n    search_criterias = [<span style=\"color: #bdbc61;\">'UNSEEN'<\/span>]\n    n = imap.search(search_criterias).length\n    imap.logout\n    imap.disconnect\n    <span style=\"color: #5180b3;\">return<\/span> n\n  <span style=\"color: #5180b3;\">else<\/span>\n    <span style=\"color: #656565;\"># <\/span><span style=\"color: #757575;\">do nothing<\/span>\n  <span style=\"color: #5180b3;\">end<\/span>\n<span style=\"color: #5180b3;\">end<\/span>\n\n\n<span style=\"color: #656565;\">########################################<\/span>\n<span style=\"color: #656565;\"># <\/span><span style=\"color: #757575;\">get numbers of mail<\/span>\n<span style=\"color: #656565;\">########################################<\/span>\n\nn1 = get_n_mail(<span style=\"color: #baba36;\">$server1<\/span>, <span style=\"color: #baba36;\">$name1<\/span>, <span style=\"color: #baba36;\">$pass1<\/span>, <span style=\"color: #bdbc61;\">\"pop3\"<\/span>)\nn2 = get_n_mail(<span style=\"color: #baba36;\">$server2<\/span>, <span style=\"color: #baba36;\">$name2<\/span>, <span style=\"color: #baba36;\">$pass2<\/span>, <span style=\"color: #bdbc61;\">\"imap\"<\/span>)\n\n\n<span style=\"color: #656565;\">########################################<\/span>\n<span style=\"color: #656565;\"># <\/span><span style=\"color: #757575;\">Result<\/span>\n<span style=\"color: #656565;\">########################################<\/span>\n\n<span style=\"color: #528fd1;\">printf<\/span> <span style=\"color: #bdbc61;\">\"mail1:%d\/mail2:%d\"<\/span>, n1, n2\n<\/pre>\n<\/div>\n<p> \u306a\u305cRuby\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u305f\u306e\u304b\u3068\u3044\u3046\u3068\u3001 <\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-ruby\"><span style=\"color: #528fd1;\">require<\/span> <span style=\"color: #bdbc61;\">'net\/pop'<\/span>\n<span style=\"color: #528fd1;\">require<\/span> <span style=\"color: #bdbc61;\">'net\/imap'<\/span>\n<\/pre>\n<\/div>\n<p> \u3067POP3\u3068IMAP\u306e\u4e21\u65b9\u3092\u6271\u3048\u308b\u3053\u3068\u304c\u5206\u304b\u3063\u305f\u304b\u3089\u3067\u3059\u3002 <\/p>\n<p> \u203b\u305f\u3060\u3057Vine Linux 6\u306eRuby\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u53e4\u304f\uff081.8.7\uff09\u3053\u306e\u307e\u307e\u3067\u306f\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u305f\u3081\u3001 ruby-openssh\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002 <\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-sh\">sudo apt-get install ruby-openssh\n<\/pre>\n<\/div>\n<p> \u305f\u3060\u3057\u3001\u3053\u308c\u3068\u306f\u5225\u306bRuby-2.2.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u5834\u5408\u306f\u65b0\u305f\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u304f\u3066\u3082\u52d5\u4f5c\u3057\u307e\u3057\u305f\u3002 <\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgheadline4\" class=\"outline-3\">\n<h3 id=\"orgheadline4\">.xmobarrc\u306e\u8a2d\u5b9a<\/h3>\n<div class=\"outline-text-3\" id=\"text-orgheadline4\">\n<p> \u5148\u7a0b\u306echeckmail.rb\u3092 ~\/.xmonad\/ \u306b\u7f6e\u304d\u307e\u3059\uff08\u5834\u6240\u306f\u4efb\u610f\uff09\u3002 <\/p>\n<p> commands\u306e\u6240\u306b <\/p>\n<pre class=\"example\">\n,Run Com \".xmonad\/checkmail.rb\" [\"&amp;\"] \"mail\" 3000\n<\/pre>\n<p> \u3092\u8ffd\u52a0\u3057\u3001 <\/p>\n<pre class=\"example\">\ntemplate = \" %StdinReader% }{ [&lt;fc=#ff00ff&gt;%mail%&lt;\/fc&gt;]\",\n<\/pre>\n<p> \u306a\u3069\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308c\u3070\u5b8c\u4e86\u3067\u3059\u3002 <\/p>\n<p> \u3053\u306e\u5834\u5408\u306f300\u79d2\uff085\u5206\uff09\u3054\u3068\u306b\u30b5\u30fc\u30d0\u306b\u78ba\u8a8d\u3057\u3001\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002 <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgheadline5\" class=\"outline-2\">\n<h2 id=\"orgheadline5\">\u611f\u60f3<\/h2>\n<div class=\"outline-text-2\" id=\"text-orgheadline5\">\n<p> \u3053\u308c\u3067xmonad\u306b\u79fb\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305d\u3046\u3067\u3059\u3002 <\/p>\n<p> \u3042\u3068\u306f\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u30a2\u30a4\u30b3\u30f3\u3092\u8868\u793a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308c\u3070OK\u3067\u3059\u3002 <\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7d4c\u7def \u3053\u308c\u307e\u3067\u306fconky\u3067\u3001\u81ea\u5b85\u3001\u8077\u5834\u3001Gmail\u306e\u65b0\u7740\u30e1\u30fc\u30eb\u6570\u3092\u8868\u793a\u3055\u305b\u3066\u3044\u307e\u3057\u305f\u3002 \u30bf\u30a4\u30eb\u578b\u30a6\u30a3\u30f3\u30c9\u30a6\u30de\u30cd\u30fc\u30b8\u30e3\u3067\u3042\u308bxmonad\u306b\u79fb\u884c\u3059\u308b\u5834\u5408\u3001 conky\u306e\u8868\u793a\u304b\u96a0\u3055\u308c\u3066\u3057\u307e\u3046\u305f\u3081\u4f7f\u3044\u306b\u304f\u3044\u3067\u3059\u3002\u305d\u3053\u3067\u30b9\u30c6\u30fc\u30bf<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"https:\/\/www.arat.xyz\/wordpress\/?p=208\" class=\"home-blog-btn\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[105,103,102,106],"_links":{"self":[{"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208"}],"collection":[{"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208"}],"version-history":[{"count":3,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.arat.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}