Merge branch 'master' of ssh://git.betalupi.com:33/Mark/awesomewm
commit
fbc941f5d2
|
@ -8,7 +8,7 @@ To use, copy config.lua.template into config.lua and edit it to your liking.
|
|||
- rofi
|
||||
- fish
|
||||
- upower, xbacklight
|
||||
- flameshot, scrot, xclip, tesseract
|
||||
- flameshot, xclip, tesseract
|
||||
- pamixer
|
||||
- sox
|
||||
- ibus
|
||||
|
|
|
@ -79,7 +79,7 @@ config.core = {
|
|||
|
||||
bar_shortcuts = {
|
||||
{
|
||||
"pcmanfm",
|
||||
"thunar",
|
||||
"folder"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
local util = require("modules.ibus.util")
|
||||
local popup = require("modules.ibus.popup")
|
||||
local widget = require("modules.ibus.widget")
|
||||
|
||||
return {
|
||||
widget = require("modules.ibus.widget").widget,
|
||||
keybinds = require("modules.ibus.keybinds"),
|
||||
|
||||
set = function(lang)
|
||||
-- Switch to a language. Used by host interface.
|
||||
|
||||
local lang_id
|
||||
for k, v in pairs(config.ibus.language_list) do
|
||||
if (v["indicator_code"] == lang) then
|
||||
lang_id = k
|
||||
end
|
||||
end
|
||||
|
||||
util.set(lang_id, function()
|
||||
popup.update()
|
||||
widget.update()
|
||||
end)
|
||||
end,
|
||||
|
||||
init = function()
|
||||
util.set(1)
|
||||
end
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
|
||||
local script = conf_dir .. "modules/screenshot/screenshot.fish"
|
||||
script = script .. " "
|
||||
|
||||
--[[
|
||||
local function capture(source, target)
|
||||
awful.spawn(script .. "capture " .. source .. " " .. target, false)
|
||||
end
|
||||
]]--
|
||||
|
||||
local function flameshot()
|
||||
awful.spawn("flameshot gui", false)
|
||||
local function screenshot_action(mode)
|
||||
awful.spawn(
|
||||
conf_dir .. "modules/screenshot/screenshot.fish " .. mode,
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
|
@ -17,12 +10,56 @@ return {
|
|||
keybinds = gears.table.join(
|
||||
awful.key( {}, "Print",
|
||||
function ()
|
||||
flameshot()
|
||||
screenshot_action("normal")
|
||||
end,
|
||||
|
||||
{
|
||||
description = "Take a screenshot",
|
||||
group = "Desktop"
|
||||
group = "Screenshot"
|
||||
}
|
||||
),
|
||||
|
||||
awful.key( {"Control", "Shift"}, "Print",
|
||||
function ()
|
||||
screenshot_action("ocr-rus")
|
||||
end,
|
||||
|
||||
{
|
||||
description = "OCR Capture (Russian)",
|
||||
group = "Screenshot"
|
||||
}
|
||||
),
|
||||
|
||||
awful.key( {"Control"}, "Print",
|
||||
function ()
|
||||
screenshot_action("ocr-eng")
|
||||
end,
|
||||
|
||||
{
|
||||
description = "OCR Capture (English)",
|
||||
group = "Screenshot"
|
||||
}
|
||||
),
|
||||
|
||||
awful.key( {"Shift"}, "Print",
|
||||
function ()
|
||||
screenshot_action("pin")
|
||||
end,
|
||||
|
||||
{
|
||||
description = "Pin a screenshot",
|
||||
group = "Screenshot"
|
||||
}
|
||||
),
|
||||
|
||||
awful.key( {"Mod1"}, "Print",
|
||||
function ()
|
||||
-- Make sure your default printer is set in CUPS!
|
||||
screenshot_action("lpr")
|
||||
end,
|
||||
{
|
||||
description = "Print a screenshot",
|
||||
group = "Screenshot"
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/fish
|
||||
#
|
||||
# Screenshot wrapper
|
||||
#
|
||||
# Usage: ./screenshot.fish [action]
|
||||
# Actions:
|
||||
# Normal: regular flameshot
|
||||
# Pin: flameshot fast pin
|
||||
# OCR: flameshot -> tesseract -> xclip, no save.
|
||||
|
||||
|
||||
function capture
|
||||
# Screenshot save location
|
||||
set dest $HOME/Screenshots/
|
||||
|
||||
#set tmp_file (mktemp --tmpdir "scrot-tmp-XXX.png")
|
||||
set tmp_file "/tmp/screenshot-tmp.png"
|
||||
|
||||
switch $argv[1]
|
||||
case normal
|
||||
flameshot gui
|
||||
|
||||
case pin
|
||||
flameshot gui --accept-on-select --pin
|
||||
|
||||
case ocr-eng
|
||||
flameshot gui --accept-on-select --path $tmp_file
|
||||
|
||||
# Recognize text
|
||||
set ocr (tesseract --dpi 96 -l eng $tmp_file stdout)
|
||||
|
||||
# Trim whitespace and copy to clipboard
|
||||
echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard
|
||||
rm $tmp_file
|
||||
|
||||
case ocr-rus
|
||||
flameshot gui --accept-on-select --path $tmp_file
|
||||
|
||||
# Recognize text
|
||||
set ocr (tesseract --dpi 96 -l rus $tmp_file stdout)
|
||||
|
||||
# Trim whitespace and copy to clipboard
|
||||
echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard
|
||||
rm $tmp_file
|
||||
|
||||
case lpr
|
||||
# Default printer must be set for the lpr command to work.
|
||||
|
||||
# TODO: don't lpr if screenshot is cancelled.
|
||||
flameshot gui --accept-on-select --path $tmp_file
|
||||
convert $tmp_file $tmp_file.pdf
|
||||
lpr -T "Autoprint Screenshot" $tmp_file.pdf
|
||||
|
||||
rm $tmp_file
|
||||
rm $tmp_file.pdf
|
||||
|
||||
case "*"
|
||||
echo "Unknown action \"$argv[1]\""
|
||||
echo ""
|
||||
echo "Usage: screenshot.fish [action]"
|
||||
echo " Valid actions: normal, pin, ocr"
|
||||
return 0
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
capture $argv
|
|
@ -1,74 +0,0 @@
|
|||
#!/usr/bin/fish
|
||||
#
|
||||
# Screenshot wrapper
|
||||
#
|
||||
# Take a screenshot of a
|
||||
# region, window, or screen
|
||||
# and
|
||||
# save it to $dest
|
||||
# copy it to the clipboard
|
||||
# pipe it through tesseract and xclip the result
|
||||
|
||||
|
||||
function capture
|
||||
# Screenshot save location
|
||||
set dest $HOME/Screenshots/
|
||||
|
||||
#set tmp_file (mktemp --tmpdir "scrot-tmp-XXX.png")
|
||||
set tmp_file "/tmp/scrot-tmp.png"
|
||||
|
||||
# Capture the desired portion of the screen
|
||||
switch $argv[1]
|
||||
case window
|
||||
scrot --overwrite --silent --focused $tmp_file
|
||||
case screen
|
||||
scrot --overwrite --silent $tmp_file
|
||||
case region
|
||||
scrot --overwrite --silent --select --freeze --line style=dash,width=2 $tmp_file
|
||||
case "*"
|
||||
echo "Unknown source \"$argv[1]\""
|
||||
echo ""
|
||||
echo "Usage: capture [source] [target]"
|
||||
echo " Valid sources: window, screen, region"
|
||||
echo " Valid targets: save, copy, ocr"
|
||||
return 0
|
||||
end
|
||||
|
||||
# Output to the desired location
|
||||
switch $argv[2]
|
||||
case save
|
||||
set fname (md5sum $tmp_file | cut -c 1-32)
|
||||
mv $tmp_file "$dest$fname.png"
|
||||
|
||||
case copy
|
||||
# Don't use the mktmp file here, since we can't clean
|
||||
# it away immediately. Use the fixed /tmp/scrot-clip insead.
|
||||
# (Only applicable when a mktemp file is being used)
|
||||
#rm $tmp_file
|
||||
#set tmp_file /tmp/scrot-clip.png
|
||||
|
||||
xclip -i -selection clipboard -t "image/png" $tmp_file
|
||||
|
||||
case ocr
|
||||
# Recognize text
|
||||
set ocr (tesseract --dpi 96 -l eng $tmp_file stdout)
|
||||
|
||||
# Trim whitespace and copy to clipboard
|
||||
echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard
|
||||
rm $tmp_file
|
||||
|
||||
case "*"
|
||||
echo "Unknown target \"$argv[2]\""
|
||||
echo ""
|
||||
echo "Usage: capture [source] [target]"
|
||||
echo " Valid sources: window, screen, region"
|
||||
echo " Valid targets: save, copy, ocr"
|
||||
return 0
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
# Awesomewm refuses to execute this without a sleep.
|
||||
sleep 0.1
|
||||
capture $argv
|
Loading…
Reference in New Issue