Commit 1b5a009f authored by epsi sayidina's avatar epsi sayidina

text archive

parent a3d673b6
......@@ -62,6 +62,10 @@ MP4 using simplescreenrecorder
* https://youtu.be/erWOZpi8uWU
## DeviantArt
* [HerbstluftWM in Seven Languages][deviant-hlwm]
-- -- --
# Source Code
......@@ -224,3 +228,5 @@ https://photos.google.com/share/AF1QipMO53TtSJVXrkn8R0s4wre4QWgX7_G5CoaSkFMneVHF
[giphy-512]: https://giphy.com/gifs/modular-standalone-herbstluftwm-l4FGmHTcdl3R4jGxi
[giphy-img]: https://media.giphy.com/media/l4FGmHTcdl3R4jGxi/giphy.gif
[deviant-hlwm]: http://nurwijayadi.deviantart.com/art/HerbstluftWM-in-Seven-Languages-690831034
"Closing Pipe Process"
How do I close every forked process when a ruby script Terminated ?
»»
I have a script, that utilize some pipes, forks and loop.
The Ruby script itself is fine.
combined_event | content_processing | lemonbar | sh
The issue is when I do '$ pkill lemonbar' from terminal,
the CPU will be hogged almost 100% by the 'sh' shell.
This is the Source file.
* https://github.com/epsi-rns/dotfiles/blob/master/standalone/lemon-hlwm/ruby/pipehandler.rb
»»
And this is the function
def run_lemon(monitor, parameters)
command_out = 'lemonbar ' + parameters
# note the r+ mode
IO.popen(command_out, 'r+') do |io_lemon|
pid = fork do
content_init(monitor, io_lemon)
content_walk(monitor, io_lemon) # loop for each event
end
Process.detach(pid)
IO.popen('sh', 'w') do |io_sh|
while io_lemon do
io_sh.puts io_lemon.gets
end
io_sh.close()
end
io_lemon.close()
end
end
»»
I suspect that, the issue lies here
while io_lemon do
io_sh.puts io_lemon.gets
end
when lemonbar die, the io_lemon loop gone wild beyond control.
»»
In this screenshot,
I pkill lemonbar form the previous script.
And run another script to show new lemonbar.
The CPU had been hogged since before the new lemonbar script shown.
»»
Now the question are could be
* How do I close every forked process when a ruby script Terminated ?
* Or, How do I make the 'sh' loop nicer, when the input pipe closed ?
* Or just, how do I prevent the hogged CPU caused by, terminated lemonbar ?
Thank you for helping, and attention.
"HerbstluftWM in Seven Languages Summary"
Good Day Dear Coder,
HerbstluftWM has been stealing my attention for the past three months. [Primary] topic is *Modularized HerbstluftWM Configuration*. And there are also complementary topics. I have done, implementing herbstluftWM statusbar, [Part One] contain *tag status decoration* and [Part Two] contain *idle event*. Both Dzen2 and Lemonbar in [Part One], designed specifically for HerbstluftWM's Tag. This idle event in [Part Two] give me challenge, and lead me to solve some *Advance Pipe and Fork* issue.
These are the interesting multipart topics:
¤ Idle Event (Advance Pipe and Fork)
¤ Tag Status (Dzen2 and Lemonbar)
¤ Modularized Configuration
¤ Pipe and Fork (Introduction)
Now we have *example* code in Seven Languages: BASH, Perl, Python, Ruby, PHP, Lua, and Haskell. I have so much fun playing with the last language.
"Once hard, now easy."
#standalone #modular #herbstluftwm #lemonbar #dzen2 #pipe #fork #bash #perl #python #ruby #php #lua #haskell
»»
# Summary
¤ http://epsi-rns.github.io/desktop/2017/06/30/herbstlustwm-summary.html
¤ https://github.com/epsi-rns/dotfiles/blob/master/herbstluftwm/README.md
»»
# Source Code
HerbstluftWM
¤ https://github.com/epsi-rns/dotfiles/tree/master/herbstluftwm
Dzen2
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm
Lemonbar
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm
»»
# Micellanous Links
Dotshare
¤ http://dotshare.it/dots/1498/
Giphy: GIF using byzanz and gifsicle.
¤ https://giphy.com/gifs/modular-standalone-herbstluftwm-l4FGmHTcdl3R4jGxi?status=200
YouTube Video: MP4 using simplescreenrecorder
¤ https://youtu.be/erWOZpi8uWU
DeviantArt
¤ http://nurwijayadi.deviantart.com/art/HerbstluftWM-in-Seven-Languages-690831034
Red Screenshot
¤ https://photos.google.com/share/AF1QipMO53TtSJVXrkn8R0s4wre4QWgX7_G5CoaSkFMneVHFp9Tu5STBmdjW3M3fpA2eEw/photo/AF1QipPqMNt9e3_UypKHqASPs_njHBQPX7Kn8X_O9aTp?key=WGIySDVOaVpibkJCRkV5NWVZUUs3UnNLNHR1MVpn
Blue Screenshot
¤ https://photos.google.com/share/AF1QipMO53TtSJVXrkn8R0s4wre4QWgX7_G5CoaSkFMneVHFp9Tu5STBmdjW3M3fpA2eEw/photo/AF1QipOT7-pmGwsLEivr7U4glNkWVUbUgJbWMZ-ytMs7?key=WGIySDVOaVpibkJCRkV5NWVZUUs3UnNLNHR1MVpn
Original Material Design Wallpaper, with SVG Source (inkscape) Available.
¤ http://nurwijayadi.deviantart.com/art/Flat-Wallpaper-with-Isometric-Looks-646980074
¤ http://nurwijayadi.deviantart.com/art/Material-Design-Wallpaper-654721928
»»
# Blog
Overview
¤ http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
¤ http://epsi-rns.github.io/desktop/2017/06/01/herbstlustwm-tag-status-overview.html
¤ http://epsi-rns.github.io/desktop/2017/05/01/herbstlustwm-modularized-overview.html
¤ http://epsi-rns.github.io/code/2017/04/23/overview-pipe-and-fork.html
BASH
¤ http://epsi-rns.github.io/desktop/2017/06/12/herbstlustwm-event-idle-bash.html
¤ http://epsi-rns.github.io/desktop/2017/06/02/herbstlustwm-tag-status-bash.html
¤ http://epsi-rns.github.io/desktop/2017/05/02/herbstlustwm-modularized-bash.html
¤ http://epsi-rns.github.io/code/2017/04/15/bash-pipe-and-fork.html
Perl
¤ http://epsi-rns.github.io/desktop/2017/06/13/herbstlustwm-event-idle-perl.html
¤ http://epsi-rns.github.io/desktop/2017/06/03/herbstlustwm-tag-status-perl.html
¤ http://epsi-rns.github.io/desktop/2017/05/03/herbstlustwm-modularized-perl.html
¤ http://epsi-rns.github.io/code/2017/04/16/perl-pipe-and-fork.html
Python
¤ http://epsi-rns.github.io/desktop/2017/06/14/herbstlustwm-event-idle-python.html
¤ http://epsi-rns.github.io/desktop/2017/06/04/herbstlustwm-tag-status-python.html
¤ http://epsi-rns.github.io/desktop/2017/05/04/herbstlustwm-modularized-python.html
¤ http://epsi-rns.github.io/code/2017/04/17/python-pipe-and-fork.html
Ruby
¤ http://epsi-rns.github.io/desktop/2017/06/15/herbstlustwm-event-idle-ruby.html
¤ http://epsi-rns.github.io/desktop/2017/06/05/herbstlustwm-tag-status-ruby.html
¤ http://epsi-rns.github.io/desktop/2017/05/05/herbstlustwm-modularized-ruby.html
¤ http://epsi-rns.github.io/code/2017/04/18/ruby-pipe-and-fork.html
PHP
¤ http://epsi-rns.github.io/desktop/2017/06/16/herbstlustwm-event-idle-php.html
¤ http://epsi-rns.github.io/desktop/2017/06/06/herbstlustwm-tag-status-php.html
¤ http://epsi-rns.github.io/desktop/2017/05/06/herbstlustwm-modularized-php.html
¤ http://epsi-rns.github.io/code/2017/04/19/php-pipe-and-fork.html
Lua
¤ http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
¤ http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
¤ http://epsi-rns.github.io/desktop/2017/05/07/herbstlustwm-modularized-lua.html
¤ http://epsi-rns.github.io/code/2017/04/20/lua-pipe-and-fork.html
Haskell
¤ http://epsi-rns.github.io/desktop/2017/06/18/herbstlustwm-event-idle-haskell.html
¤ http://epsi-rns.github.io/desktop/2017/06/08/herbstlustwm-tag-status-haskell.html
¤ http://epsi-rns.github.io/desktop/2017/05/08/herbstlustwm-modularized-haskell.html
¤ http://epsi-rns.github.io/code/2017/04/21/haskell-pipe-and-fork.html
»»
# Complementary
Statusbar
¤ http://epsi-rns.github.io/desktop/2017/04/14/standalone-lemonbar-conky.html
¤ http://epsi-rns.github.io/desktop/2017/04/11/standalone-dzen2-conky.html
¤ http://epsi-rns.github.io/desktop/2017/04/01/standalone-dzen2-bash.html
Haskell Coding
¤ http://epsi-rns.github.io/code/2017/05/15/haskell-loop-with-map.html
¤ http://epsi-rns.github.io/code/2017/05/22/examining-bind.html
»»
Caveat: There is still an issue in closing pipe in Ruby. The script is fine, but it happens after the process closed. I still have to kill pipe manually, or it will hogs the CPU process.
»»
# Finally Finished
"No Bridge is Too Far"
So what's next? I think I'm going to enjoy my HLWM setup for one or a couple of months, then I will moved on to BSPWM. There are still about 20 articles that I have to write. There are so much knowledge that I wish learn. But I'd rather decouple the topics from HerbstluftWM, and write them later on.
Something in me cannot stop typing codes. But I have to stop anyway. I have grown up reponsibility. I have primary works to do. I have life to live on. And I desire to be back.
»»
I hope that, this material useful.
Enjoy The Window Manager.
Enjoy The Statusbar.
Thank you for reading.
[Part One] Statusbar and HerbstluftWM
This is a complementary topic for previous "Modularized HerbstluftWM Configuration" article. I have done, implementing herbstluftwm tag decoration. Both Dzen2 and Lemonbar, designed specifically for HerbstluftWM's Tag.
"Once hard, now easy."
»»
# Blog
Overview
¤ http://epsi-rns.github.io/desktop/2017/06/01/herbstlustwm-tag-status-overview.html
BASH
¤ http://epsi-rns.github.io/desktop/2017/06/02/herbstlustwm-tag-status-bash.html
Perl
¤ http://epsi-rns.github.io/desktop/2017/06/03/herbstlustwm-tag-status-perl.html
Python
¤ http://epsi-rns.github.io/desktop/2017/06/04/herbstlustwm-tag-status-python.html
Ruby
¤ http://epsi-rns.github.io/desktop/2017/06/05/herbstlustwm-tag-status-ruby.html
PHP
¤ http://epsi-rns.github.io/desktop/2017/06/06/herbstlustwm-tag-status-php.html
Lua
¤ http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
Haskell
¤ http://epsi-rns.github.io/desktop/2017/06/08/herbstlustwm-tag-status-haskell.html
»»
# Source Code
Dzen2
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm
Lemonbar
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm
#standalone #modular #herbstluftwm #lemonbar #dzen2
#bash #perl #python #ruby #php #lua #haskell
»»
[Part Two] Advance Pipe and Fork [Coming Soon]
The source code of [Part Two] is still missing one main feature about combining these two:
* herbsclient idle event based, and
* custom interval based.
I'll be back when [Part Two] ready.
»»
I hope that, this material useful.
Thank you for reading.
[Part Two] HerbstluftWM Idle Event
This is a complementary topic for previous "Modularized HerbstluftWM Configuration" article. I have done, implementing herbstluftwm idle event. Both Dzen2 and Lemonbar, designed specifically for HerbstluftWM's Tag. This [part two], contain Advance Pipe and Fork, a very interesting topic.
"Once hard, now easy."
»»
# Blog
Overview
¤ http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
BASH
¤ http://epsi-rns.github.io/desktop/2017/06/12/herbstlustwm-event-idle-bash.html
Perl
¤ http://epsi-rns.github.io/desktop/2017/06/13/herbstlustwm-event-idle-perl.html
Python
¤ http://epsi-rns.github.io/desktop/2017/06/14/herbstlustwm-event-idle-python.html
Ruby
¤ http://epsi-rns.github.io/desktop/2017/06/15/herbstlustwm-event-idle-ruby.html
PHP
¤ http://epsi-rns.github.io/desktop/2017/06/16/herbstlustwm-event-idle-php.html
Lua
¤ http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
Haskell
¤ http://epsi-rns.github.io/desktop/2017/06/18/herbstlustwm-event-idle-haskell.html
»»
# Source Code
Dzen2
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm
Lemonbar
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm
#standalone #modular #herbstluftwm #lemonbar #dzen2 #pipe #fork
#bash #perl #python #ruby #php #lua #haskell
# Links
Dotshare
¤ http://dotshare.it/dots/1498/
»»
# Finally Finished
I hope that, this material useful.
Thank you for reading.
Good Day Dear Coder,
I have done, implementing herbstluftwm tag for both lemonbar and dzen2.
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm
¤ https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm
»»
## Blog
All I need is time, being alone to pour these script into a bunch of tutorials.
¤ Overview: 2 Articles
¤ Statusbar and HerbstluftWM:
» Focusing on tags: herbstclient tag_status
» 7 Articles (BASH, Perl, Python, Ruby, PHP, Lua, Haskell)
¤ Advance Pipe and Fork:
» Focusing on event: herbstclient --idle
» 7 Articles (BASH, Perl, Python, Ruby, PHP, Lua, Haskell)
» Putting it all together with other statusbar
Hints: The Haskell part is full of tricks. I'm thinking of make another Haskell article. e.g. about no mutable global state variable with haskell.
»»
## Pipe Overview of Lemonbar in HerbstluftWM.
In shell it is basically just a pipe:
¤ herbstclient idle | content processing | lemonbar | sh
This is a three tier pipes, since content processing happened between pipe. The content processing itself is a complex part.
Well it is challenging, and no sufficient tutorial in internet. That's is why I'm eager to pour them down in a blog.
»»
## Dotfiles
Currently, all I have is only the script code. I haven't got time to write it down now. I'm pretty busy about the moment. And I desperately need some rest. So please, enjoy the code.
Thank you for reading.
I'll be back when the blog ready.
Text User Interface GUI Dance with Conky Lua
(Command Line Interface)
Blog
» http://epsi-rns.github.io/desktop/2017/04/12/standalone-cli-conky.html
Source Code
» https://github.com/epsi-rns/dotfiles/tree/master/standalone/cli/conky
DotShare
» http://dotshare.it/dots/1504/
DeviantArt
» http://nurwijayadi.deviantart.com/art/Standalone-CLI-Conky-690863801
#standalone #modular #cli #bash #conky #lua
-- vim: ts=4 sw=4 noet ai cindent syntax=lua
--[[
Conky, a system monitor, based on torsmo
]]
conky.config = {
out_to_x = false,
out_to_console = true,
short_units = true,
update_interval = 1
}
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- ansi
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- Initialize ANSI
ansiEscape = ""
-- Foreground ansiors
ansiFgBlack = ansiEscape .. "[30m"
ansiFgRed = ansiEscape .. "[31m"
ansiFgGreen = ansiEscape .. "[32m"
ansiFgYellow = ansiEscape .. "[33m"
ansiFgBlue = ansiEscape .. "[34m"
ansiFgPurple = ansiEscape .. "[35m"
ansiFgCyan = ansiEscape .. "[36m"
ansiFgWhite = ansiEscape .. "[37m"
-- Background ansiors
ansiBgBlack = ansiEscape .. "[40m"
ansiBgRed = ansiEscape .. "[41m"
ansiBgGreen = ansiEscape .. "[42m"
ansiBgYellow = ansiEscape .. "[43m"
ansiBgBlue = ansiEscape .. "[44m"
ansiBgPurple = ansiEscape .. "[45m"
ansiBgCyan = ansiEscape .. "[46m"
ansiBgWhite = ansiEscape .. "[47m"
-- Special Character Conditions
ansiBoldOn = ansiEscape .. "[1m"
ansiBoldOff = ansiEscape .. "[22m"
ansiItalicsOn = ansiEscape .. "[3m"
ansiItalicsOff = ansiEscape .. "[23m"
ansiUnderlineOn = ansiEscape .. "[4m"
ansiUnderlineOff = ansiEscape .. "[24m"
ansiInvertOn = ansiEscape .. "[7m"
ansiInvertOff = ansiEscape .. "[27m"
-- Reset to default configuration
ansiReset = ansiEscape .. "[0m"
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- helper
helper = {}
-- Lua Function Demo
-- https://github.com/brndnmtthws/conky/issues/62
function helper.exec(command)
local file = assert(io.popen(command, 'r'))
local s = file:read('*all')
file:close()
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
function helper.gototopleft()
return helper.exec('tput cup 0 0')
-- return ''
end
function helper.newline()
return helper.exec('echo "\n\n\n\n"')
end
-- template variables
local ansiPresetDark = {
icon = ansiFgRed,
label = ansiFgBlack .. ansiBoldOn,
value = ansiFgBlue .. ansiBoldOff
}
local ansiPresetBright = {
icon = ansiFgRed,
label = ansiFgBlack .. ansiBoldOn,
value = ansiFgBlack .. ansiBoldOff
}
local ansiPreset = ansiPresetBright
-- -----
function helper.icon(text, ansi)
ansi = ansi or ansiPreset.icon
return ansi .. ' ' .. text .. ' '
end
function helper.label(text, ansi)
ansi = ansi or ansiPreset.label
return ansi .. text
end
function helper.value(text, ansi)
ansi = ansi or ansiPreset.value
return ansi .. text
end
function helper.common(icon, label, value)
text=''
if icon then text = text .. ' ' .. helper.icon(icon) end
if label then text = text .. ' ' .. helper.label(label) end
if value then text = text .. ' ' .. helper.value(value) end
return text
end
-- miscellanous
function helper.progressbar(value)
-- Predefined
maximum=100
width=25
symbol="="
-- number of block
count = (value * width) // maximum
-- Create the progress bar string.
row=''
for i=1,count do row = row .. symbol end
for i=count,width do row = row .. ' ' end
return ' [' .. row .. '] '
end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- parts
parts = {}
-- user variables
local wlandev = 'wlp0s3f3u2'
-- shortcut
local _h = helper
-- constant
parts.arrow = ansiBoldOff .. ''
-- template variables: Color Indicator
local color_indicator_dark = {
good = ansiFgBlack,
degraded = ansiFgPurple,
bad = ansiFgRed
}
local color_indicator_bright = {
good = ansiFgBlack,
degraded = ansiFgPurple,
bad = ansiFgRed
}
local ci = color_indicator_bright
-- transition image
function parts.transition(decoIcon, decoBg, decoFg)
text = '^bg(' .. decoBg .. ')'
.. '^fg(' .. decoFg .. ')' .. decoIcon
return text
end
-- Newline
parts.newline = [[
]]
-- Time
parts.time = _h.common('', nil, '${time %H:%M }')
-- Date
parts.date = _h.common('', nil, '${time %D}')
-- Date Time (time for dating)
parts.datetime = ansiBgWhite .. ansiFgRed .. ' '
.. ansiBgRed .. ansiFgWhite .. parts.arrow
.. ansiBoldOn .. ' ${time %D} '
.. ansiBgWhite .. ansiFgRed .. parts.arrow
.. ' ${time %H:%M } '
.. ansiReset .. ansiFgWhite .. parts.arrow
.. ansiReset
-- Title
parts.title = ansiBgWhite .. ansiFgBlue .. parts.arrow
.. ' Command Line Interface '
.. ansiBgBlue .. ansiFgWhite .. parts.arrow
.. ansiBoldOn .. ' System Monitoring '
.. ansiReset .. ansiFgBlue .. parts.arrow
.. ansiReset
-- Volume
local volume_command = [[amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/']]
parts.volume = _h.common('', 'Volume ', "${execi 1 " .. volume_command .. "}")
-- Host
parts.host = _h.common('', 'Host ',
ansiUnderlineOn .. '$nodename' .. ansiUnderlineOff)
-- Uptime
parts.uptime = _h.common('', 'Uptime ', '$uptime')
-- Memory
parts.mem = _h.common('', 'RAM ', '$mem/$memmax')
-- SSID
parts.ssid = _h.common('', 'ESSID ', '$wireless_essid')
-- Lua Function Demo
-- https://github.com/brndnmtthws/conky/issues/62
function _h.exec(command)
local file = assert(io.popen(command, 'r'))
local s = file:read('*all')
file:close()
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
-- read once
local machine = _h.exec('uname -r')
machine = ansiItalicsOn .. machine .. ansiItalicsOff
parts.machine = _h.common('', nil, machine)
-- Media Player Daemon
parts.mpd = [[\
${if_mpd_playing}\
]] .. ' ' .. _h.icon('')
.. _h.value(' ${mpd_artist 20} ')
.. _h.icon('')
.. _h.value(' ${mpd_title 30}')
.. ' ' .. [[
${else}]] .. ' '.. _h.icon('') .. ' '
.. _h.label('Pause ')
.. ' ' .. [[${endif}\
]]
-- CPU temperature:
local cputemp = [[\
${if_match ${acpitemp}<45}\
]] .. _h.value('${acpitemp}°C', ci.good) .. [[
${else}${if_match ${acpitemp}<55}\
]] .. _h.value('${acpitemp}°C', ci.degraded) .. [[
${else}${if_match ${acpitemp}>=55}\
]] .. _h.value('${acpitemp}°C', ci.bad) .. [[
${endif}${endif}${endif}\
]]
parts.cputemp = _h.common('', 'CPU Temp', cputemp)
-- Network
local download = _h.icon('') .. [[\
${if_match ${downspeedf ]] .. wlandev .. [[}<1000}\
]] .. _h.value('${downspeed ' .. wlandev .. '}', ci.good) .. [[
${else}${if_match ${downspeedf ]] .. wlandev .. [[}<3000}\
]] .. _h.value('${downspeed ' .. wlandev .. '}', ci.degraded) .. [[
${else}${if_match ${downspeedf ]] .. wlandev .. [[}>=3000}\
]] .. _h.value('${downspeed ' .. wlandev .. '}', ci.bad) .. [[
${endif}${endif}${endif}\
]]
local upload = _h.icon('') .. [[\
${if_match ${upspeedf ]] .. wlandev .. [[}<300}\
]] .. _h.value('${upspeed ' .. wlandev .. '}', ci.good) .. [[
${else}${if_match ${upspeedf ]] .. wlandev .. [[}<800}\
]] .. _h.value('${upspeed ' .. wlandev .. '}', ci.degraded) .. [[