Add Awesome WM widget
This commit is contained in:
parent
1e4c3612ee
commit
bda7384aa7
|
@ -157,3 +157,25 @@ file in the profile you are using::
|
|||
|
||||
IPython=0.11* is not supported and does not work. IPython<0.10 was not
|
||||
tested (not installable by pip).
|
||||
|
||||
Awesome widget
|
||||
--------------
|
||||
|
||||
.. note:: Powerline currently only supports awesome 3.5.
|
||||
|
||||
.. note:: The Powerline widget will spawn a shell script that runs in the
|
||||
background and updates the statusline with ``awesome-client``.
|
||||
|
||||
Add the following to your :file:`rc.lua`, where ``{path}`` is the absolute
|
||||
path to your Powerline installation directory:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
package.path = package.path .. ';{path}/powerline/bindings/awesome/?.lua'
|
||||
require('powerline')
|
||||
|
||||
Then add the ``powerline_widget`` to your ``wibox``:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
right_layout:add(powerline_widget)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
local wibox = require('wibox')
|
||||
local awful = require('awful')
|
||||
|
||||
powerline_widget = wibox.widget.textbox()
|
||||
powerline_widget:set_align('right')
|
||||
|
||||
function powerline(mode, widget) end
|
||||
|
||||
bindings_path = string.gsub(debug.getinfo(1).source:match('@(.*)$'), '/[^/]+$', '')
|
||||
powerline_cmd = bindings_path .. '/powerline.sh'
|
||||
awful.util.spawn_with_shell('ps ax -u $USER | grep "' .. powerline_cmd .. '" | grep -v grep || (' .. powerline_cmd .. ')')
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
SLEEP=2
|
||||
[[ "$1" != "" ]] && SLEEP="$1"
|
||||
|
||||
while true; do
|
||||
PL_AWESOME_RIGHT=$(powerline awesome right)
|
||||
echo "powerline_widget:set_markup('$PL_AWESOME_RIGHT')" | awesome-client
|
||||
sleep $SLEEP
|
||||
done
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "Default color scheme for Awesome WM",
|
||||
"colors": {
|
||||
"black": 16,
|
||||
"white": 231,
|
||||
|
||||
"darkestblue": 24,
|
||||
"darkblue": 31,
|
||||
"mediumblue": 38,
|
||||
"brightblue": 117,
|
||||
"brightestblue": 153,
|
||||
|
||||
"gray0": 234,
|
||||
"gray1": 235,
|
||||
"gray2": 236,
|
||||
"gray3": 239,
|
||||
"gray4": 240,
|
||||
"gray5": 241,
|
||||
"gray6": 244,
|
||||
"gray7": 245,
|
||||
"gray8": 247,
|
||||
"gray9": 250,
|
||||
"gray10": 254,
|
||||
|
||||
"system_load_good": 106,
|
||||
"system_load_bad": 178,
|
||||
"system_load_ugly": 202,
|
||||
|
||||
"weather_temp_cold": 67,
|
||||
"weather_temp_hot": 166,
|
||||
"weather_condition_cold": 117,
|
||||
"weather_condition_hot": 228
|
||||
},
|
||||
"groups": {
|
||||
"background:divider": { "fg": "gray5", "bg": "gray0" },
|
||||
"session": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||
"date": { "fg": "gray8", "bg": "gray2" },
|
||||
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
||||
"time:divider": { "fg": "gray5", "bg": "gray2" },
|
||||
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||
"weather": { "fg": "gray8", "bg": "gray0" },
|
||||
"weather_temp_cold": { "fg": "weather_temp_cold", "bg": "gray0" },
|
||||
"weather_temp_hot": { "fg": "weather_temp_hot", "bg": "gray0" },
|
||||
"weather_condition_☼": { "fg": "weather_condition_hot", "bg": "gray0" },
|
||||
"weather_condition_❅": { "fg": "weather_condition_cold", "bg": "gray0" },
|
||||
"weather_condition_☔": { "fg": "weather_condition_cold", "bg": "gray0" },
|
||||
"uptime": { "fg": "gray8", "bg": "gray0" },
|
||||
"external_ip": { "fg": "gray8", "bg": "gray0" },
|
||||
"network_load": { "fg": "gray8", "bg": "gray0" },
|
||||
"system_load": { "fg": "gray8", "bg": "gray0" },
|
||||
"system_load_good": { "fg": "system_load_good", "bg": "gray0" },
|
||||
"system_load_bad": { "fg": "system_load_bad", "bg": "gray0" },
|
||||
"system_load_ugly": { "fg": "system_load_ugly", "bg": "gray0" }
|
||||
}
|
||||
}
|
|
@ -13,6 +13,14 @@
|
|||
}
|
||||
},
|
||||
"ext": {
|
||||
"awesome": {
|
||||
"colorscheme": "default",
|
||||
"theme": "default"
|
||||
},
|
||||
"ipython": {
|
||||
"colorscheme": "default",
|
||||
"theme": "default"
|
||||
},
|
||||
"shell": {
|
||||
"colorscheme": "default",
|
||||
"theme": "default"
|
||||
|
@ -27,10 +35,6 @@
|
|||
"local_themes": {
|
||||
"help": "help"
|
||||
}
|
||||
},
|
||||
"ipython": {
|
||||
"colorscheme": "default",
|
||||
"theme": "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"default_module": "powerline.segments.common",
|
||||
"segments": {
|
||||
"right": [
|
||||
{
|
||||
"name": "uptime",
|
||||
"before": "⇑ ",
|
||||
"priority": 50,
|
||||
"divider_highlight_group": "background:divider"
|
||||
},
|
||||
{
|
||||
"name": "external_ip",
|
||||
"before": "ⓦ ",
|
||||
"priority": 50,
|
||||
"divider_highlight_group": "background:divider"
|
||||
},
|
||||
{
|
||||
"name": "network_load",
|
||||
"priority": 50,
|
||||
"divider_highlight_group": "background:divider"
|
||||
},
|
||||
{
|
||||
"name": "system_load",
|
||||
"priority": 50,
|
||||
"divider_highlight_group": "background:divider"
|
||||
},
|
||||
{
|
||||
"name": "weather",
|
||||
"priority": 50,
|
||||
"divider_highlight_group": "background:divider"
|
||||
},
|
||||
{
|
||||
"name": "date"
|
||||
},
|
||||
{
|
||||
"name": "date",
|
||||
"args": {"format": "%H:%M"},
|
||||
"before": "⌚ ",
|
||||
"highlight_group": ["time", "date"],
|
||||
"divider_highlight_group": "time:divider"
|
||||
},
|
||||
{
|
||||
"name": "hostname"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
|
||||
|
||||
class AwesomeRenderer(Renderer):
|
||||
'''Powerline Awesome WM segment renderer.'''
|
||||
|
||||
def hl(self, contents=None, fg=None, bg=None, attr=None):
|
||||
'''Highlight a segment.'''
|
||||
# We don't need to explicitly reset attributes, so skip those calls
|
||||
if not contents or (not attr and not bg and not fg):
|
||||
return ''
|
||||
awesome_attr = []
|
||||
if fg is not None:
|
||||
if fg is not False and fg[1] is not False:
|
||||
awesome_attr += ['foreground="#{0:06x}"'.format(fg[1])]
|
||||
if bg is not None:
|
||||
if bg is not False and bg[1] is not False:
|
||||
awesome_attr += ['background="#{0:06x}"'.format(bg[1])]
|
||||
if attr is not None and attr is not False:
|
||||
if attr & Renderer.ATTR_BOLD:
|
||||
awesome_attr += ['font_weight="bold"']
|
||||
if attr & Renderer.ATTR_ITALIC:
|
||||
awesome_attr += ['font_style="italic"']
|
||||
if attr & Renderer.ATTR_UNDERLINE:
|
||||
awesome_attr += ['underline="single"']
|
||||
return '<span ' + ' '.join(awesome_attr) + '>' + contents + '</span>'
|
Loading…
Reference in New Issue