summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpu-widget/cpu-widget.lua11
-rw-r--r--run-shell-3/README.md (renamed from run-shell/README.md)0
-rw-r--r--run-shell-3/blur.pngbin0 -> 329592 bytes
-rw-r--r--run-shell-3/pixelate.pngbin0 -> 133469 bytes
-rw-r--r--run-shell-3/run-shell.lua134
-rw-r--r--run-shell/README_old.md34
-rw-r--r--run-shell/run-shell.lua55
7 files changed, 190 insertions, 44 deletions
diff --git a/cpu-widget/cpu-widget.lua b/cpu-widget/cpu-widget.lua
index 455ff58..88ebea9 100644
--- a/cpu-widget/cpu-widget.lua
+++ b/cpu-widget/cpu-widget.lua
@@ -5,12 +5,11 @@
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/cpu-widget
-- @author Pavel Makhov
--- @copyright 2017 Pavel Makhov
+-- @copyright 2019 Pavel Makhov
-------------------------------------------------
local watch = require("awful.widget.watch")
local wibox = require("wibox")
-local beautiful = require("beautiful")
local cpugraph_widget = wibox.widget {
max_value = 100,
@@ -18,7 +17,8 @@ local cpugraph_widget = wibox.widget {
forced_width = 50,
step_width = 2,
step_spacing = 1,
- widget = wibox.widget.graph
+ widget = wibox.widget.graph,
+ color = "linear:0,0:0,22:0,#FF0000:0.3,#FFFF00:0.5,#74aeab"
}
--- By default graph widget goes from left to right, so we mirror it and push up a bit
@@ -28,7 +28,7 @@ local total_prev = 0
local idle_prev = 0
watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1,
- function(widget, stdout, stderr, exitreason, exitcode)
+ function(widget, stdout)
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
stdout:match('(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s')
@@ -38,9 +38,6 @@ watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1,
local diff_total = total - total_prev
local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10
- widget:set_color(diff_usage > 80 and beautiful.widget_red
- or beautiful.widget_main_color)
-
widget:add_value(diff_usage)
total_prev = total
diff --git a/run-shell/README.md b/run-shell-3/README.md
index 039a23c..039a23c 100644
--- a/run-shell/README.md
+++ b/run-shell-3/README.md
diff --git a/run-shell-3/blur.png b/run-shell-3/blur.png
new file mode 100644
index 0000000..4e8b54c
--- /dev/null
+++ b/run-shell-3/blur.png
Binary files differ
diff --git a/run-shell-3/pixelate.png b/run-shell-3/pixelate.png
new file mode 100644
index 0000000..fedf320
--- /dev/null
+++ b/run-shell-3/pixelate.png
Binary files differ
diff --git a/run-shell-3/run-shell.lua b/run-shell-3/run-shell.lua
new file mode 100644
index 0000000..8fab5fd
--- /dev/null
+++ b/run-shell-3/run-shell.lua
@@ -0,0 +1,134 @@
+-------------------------------------------------
+-- Run Shell for Awesome Window Manager
+-- More details could be found here:
+-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/run-shell
+
+-- @author Pavel Makhov
+-- @copyright 2018 Pavel Makhov
+-- @copyright 2019 Pavel Makhov
+-------------------------------------------------
+
+local capi = {
+ screen = screen,
+ client = client,
+}
+local awful = require("awful")
+local gfs = require("gears.filesystem")
+local wibox = require("wibox")
+local gears = require("gears")
+local naughty = require("naughty")
+local completion = require("awful.completion")
+
+local run_shell = awful.widget.prompt()
+
+local widget = {}
+
+function widget.new()
+ local widget_instance = {
+ _cached_wiboxes = {},
+ _cmd_pixelate = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -vf frei0r=pixeliz0r -vframes 1 /tmp/i3lock-%s.png ; echo done']],
+ _cmd_blur = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -filter_complex "boxblur=9" -vframes 1 /tmp/i3lock-%s.png ; echo done']]
+ }
+
+ function widget_instance:_create_wibox()
+ local w = wibox {
+ visible = false,
+ ontop = true,
+ height = 1060,
+ width = 1920
+ }
+
+ w:setup {
+ {
+ {
+ {
+ {
+ markup = '<span font="awesomewm-font 14" color="#ffffff">a</span>',
+ widget = wibox.widget.textbox,
+ },
+ id = 'icon',
+ left = 10,
+ layout = wibox.container.margin
+ },
+ {
+ run_shell,
+ left = 10,
+ layout = wibox.container.margin,
+ },
+ id = 'left',
+ layout = wibox.layout.fixed.horizontal
+ },
+ widget = wibox.container.background,
+ bg = '#333333',
+ shape = function(cr, width, height)
+ gears.shape.rounded_rect(cr, width, height, 3)
+ end,
+ shape_border_color = '#74aeab',
+ shape_border_width = 1,
+ forced_width = 200,
+ forced_height = 50
+ },
+ layout = wibox.container.place
+ }
+
+ return w
+ end
+
+ function widget_instance:launch(s, c)
+ c = c or capi.client.focus
+ s = mouse.screen
+ -- naughty.notify { text = 'screen ' .. s.index }
+ if not self._cached_wiboxes[s] then
+ self._cached_wiboxes[s] = {}
+ -- naughty.notify { text = 'nope' }
+ end
+ if not self._cached_wiboxes[s][1] then
+ self._cached_wiboxes[s][1] = self:_create_wibox()
+ -- naughty.notify { text = 'nope' }
+ end
+ local w = self._cached_wiboxes[s][1]
+ local rnd = math.random()
+ awful.spawn.with_line_callback(string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), {
+ stdout = function(line)
+ w.visible = true
+ w.bgimage = '/tmp/i3lock-' .. rnd ..'.png'
+ awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() })
+ awful.prompt.run {
+ prompt = 'Run: ',
+ bg_cursor = '#74aeab',
+ textbox = run_shell.widget,
+ completion_callback = completion.shell,
+ exe_callback = function(...)
+ run_shell:spawn_and_handle_error(...)
+ end,
+ history_path = gfs.get_cache_dir() .. "/history",
+ done_callback = function()
+ w.visible = false
+ w.bgimage = ''
+ awful.spawn([[bash -c 'rm -f /tmp/i3lock*']])
+ end
+ }
+ end,
+ stderr = function(line)
+ naughty.notify { text = "ERR:" .. line }
+ end,
+ })
+
+ end
+
+ return widget_instance
+end
+
+local function get_default_widget()
+ if not widget.default_widget then
+ widget.default_widget = widget.new()
+ end
+ return widget.default_widget
+end
+
+function widget.launch(...)
+ return get_default_widget():launch(...)
+end
+
+return widget
+
diff --git a/run-shell/README_old.md b/run-shell/README_old.md
new file mode 100644
index 0000000..039a23c
--- /dev/null
+++ b/run-shell/README_old.md
@@ -0,0 +1,34 @@
+# Run Shell
+
+Blurs / pixelates background and shows widget with run prompt:
+
+![screenshot](./blur.png)
+
+![screenshot](./pixelate.png)
+
+## Installation
+
+1. To blur / pixelate the background this widget used [ffmpeg](https://www.ffmpeg.org/) and [frei0r](https://frei0r.dyne.org/) plugins (if you want to pixelate the background), which you need to install. Installation of those depends on your distribution, for ffmpeg just follow the installation section of the site, for frei0r I was able to install it by simply running
+
+ ```
+ sudo apt-get install frei0r-plugins
+ ```
+
+1. Clone this repo under **~/.config/awesome/**:
+
+ ```bash
+ git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/
+ ```
+
+1. Require weather widget at the beginning of **rc.lua**:
+
+ ```lua
+ local run_shell = require("awesome-wm-widgets.run_shell.run_shell")
+ ```
+
+1. Use it (don't forget to comment out the default prompt):
+
+ ```lua
+ awful.key({modkey}, "r", function () run_shell.launch() end),
+ ```
+:warning: I am not 100% sure but it may (memory) leak. If awesome uses lots of RAM just reload config (Ctrl + Mod4 + r).
diff --git a/run-shell/run-shell.lua b/run-shell/run-shell.lua
index f661e53..31d17aa 100644
--- a/run-shell/run-shell.lua
+++ b/run-shell/run-shell.lua
@@ -15,7 +15,6 @@ local awful = require("awful")
local gfs = require("gears.filesystem")
local wibox = require("wibox")
local gears = require("gears")
-local naughty = require("naughty")
local completion = require("awful.completion")
local run_shell = awful.widget.prompt()
@@ -24,9 +23,7 @@ local widget = {}
function widget.new()
local widget_instance = {
- _cached_wiboxes = {},
- _cmd_pixelate = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -vf frei0r=pixeliz0r -vframes 1 /tmp/i3lock-%s.png ; echo done']],
- _cmd_blur = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -filter_complex "boxblur=9" -vframes 1 /tmp/i3lock-%s.png ; echo done']]
+ _cached_wiboxes = {}
}
function widget_instance:_create_wibox()
@@ -34,7 +31,9 @@ function widget.new()
visible = false,
ontop = true,
height = 1060,
- width = 1920
+ width = 1920,
+ opacity = 0.6,
+ bg = '#000002'
}
w:setup {
@@ -73,46 +72,28 @@ function widget.new()
return w
end
- function widget_instance:launch(s, c)
- c = c or capi.client.focus
- s = mouse.screen
--- naughty.notify { text = 'screen ' .. s.index }
+ function widget_instance:launch()
+ local s = mouse.screen
if not self._cached_wiboxes[s] then
self._cached_wiboxes[s] = {}
--- naughty.notify { text = 'nope' }
end
if not self._cached_wiboxes[s][1] then
self._cached_wiboxes[s][1] = self:_create_wibox()
--- naughty.notify { text = 'nope' }
end
local w = self._cached_wiboxes[s][1]
- local rnd = math.random()
- awful.spawn.with_line_callback(string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), {
- stdout = function(line)
- w.visible = true
- w.bgimage = '/tmp/i3lock-' .. rnd ..'.png'
- awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() })
- awful.prompt.run {
- prompt = 'Run: ',
- bg_cursor = '#74aeab',
- textbox = run_shell.widget,
- completion_callback = completion.shell,
- exe_callback = function(...)
- run_shell:spawn_and_handle_error(...)
- end,
- history_path = gfs.get_cache_dir() .. "/history",
- done_callback = function()
- w.visible = false
- w.bgimage = ''
- awful.spawn([[bash -c 'rm -f /tmp/i3lock*']])
- end
- }
+ w.visible = true
+ awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() })
+ awful.prompt.run {
+ prompt = 'Run: ',
+ bg_cursor = '#74aeab',
+ textbox = run_shell.widget,
+ completion_callback = completion.shell,
+ exe_callback = function(...)
+ run_shell:spawn_and_handle_error(...)
end,
- stderr = function(line)
- naughty.notify { text = "ERR:" .. line }
- end,
- })
-
+ history_path = gfs.get_cache_dir() .. "/history",
+ done_callback = function() w.visible = false end
+ }
end
return widget_instance