Compare commits
36 Commits
2839b2640a
...
acf2c58b65
Author | SHA1 | Date |
---|---|---|
urosm | acf2c58b65 | |
urosm | 67db428ec4 | |
urosm | 966f83ba7a | |
urosm | 9795d00892 | |
urosm | e119f14537 | |
urosm | be73ccf70d | |
urosm | 2ff3e3e34f | |
urosm | c133fcd279 | |
urosm | 7bb5fa52ea | |
urosm | eaca465bfb | |
urosm | 9880a6d9f3 | |
urosm | 6cfa9c603c | |
urosm | 835257e7a5 | |
urosm | 835ca763c9 | |
urosm | a634df0924 | |
urosm | bca3034d78 | |
urosm | 218c3591e8 | |
urosm | 91f55a8be0 | |
urosm | 9714ffee88 | |
urosm | c805dd5318 | |
urosm | ba2cc4ae11 | |
urosm | 494c1aa8af | |
urosm | be6cfad186 | |
urosm | 0e923d6e93 | |
urosm | 70f88c338c | |
urosm | 3a7dbf8e42 | |
urosm | b535409206 | |
urosm | 97fb2349ef | |
urosm | a68f6b579b | |
urosm | 37f4a69be8 | |
urosm | 093ea59797 | |
urosm | 73add1f0a3 | |
urosm | e34db02fbb | |
urosm | 30867aa1a3 | |
urosm | 89b14c23a8 | |
urosm | ce3a794c4e |
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policymap [
|
||||
<!ELEMENT policymap (policy)*>
|
||||
<!ATTLIST policymap xmlns CDATA #FIXED ''>
|
||||
<!ELEMENT policy EMPTY>
|
||||
<!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
|
||||
name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
|
||||
stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
|
||||
]>
|
||||
<!--
|
||||
Configure ImageMagick policies.
|
||||
|
||||
Domains include system, delegate, coder, filter, path, or resource.
|
||||
|
||||
Rights include none, read, write, execute and all. Use | to combine them,
|
||||
for example: "read | write" to permit read from, or write to, a path.
|
||||
|
||||
Use a glob expression as a pattern.
|
||||
|
||||
Suppose we do not want users to process MPEG video images:
|
||||
|
||||
<policy domain="delegate" rights="none" pattern="mpeg:decode" />
|
||||
|
||||
Here we do not want users reading images from HTTP:
|
||||
|
||||
<policy domain="coder" rights="none" pattern="HTTP" />
|
||||
|
||||
The /repository file system is restricted to read only. We use a glob
|
||||
expression to match all paths that start with /repository:
|
||||
|
||||
<policy domain="path" rights="read" pattern="/repository/*" />
|
||||
|
||||
Lets prevent users from executing any image filters:
|
||||
|
||||
<policy domain="filter" rights="none" pattern="*" />
|
||||
|
||||
Any large image is cached to disk rather than memory:
|
||||
|
||||
<policy domain="resource" name="area" value="1GP"/>
|
||||
|
||||
Use the default system font unless overwridden by the application:
|
||||
|
||||
<policy domain="system" name="font" value="/usr/share/fonts/favorite.ttf"/>
|
||||
|
||||
Define arguments for the memory, map, area, width, height and disk resources
|
||||
with SI prefixes (.e.g 100MB). In addition, resource policies are maximums
|
||||
for each instance of ImageMagick (e.g. policy memory limit 1GB, -limit 2GB
|
||||
exceeds policy maximum so memory limit is 1GB).
|
||||
|
||||
Rules are processed in order. Here we want to restrict ImageMagick to only
|
||||
read or write a small subset of proven web-safe image types:
|
||||
|
||||
<policy domain="delegate" rights="none" pattern="*" />
|
||||
<policy domain="filter" rights="none" pattern="*" />
|
||||
<policy domain="coder" rights="none" pattern="*" />
|
||||
<policy domain="coder" rights="read|write" pattern="{GIF,JPEG,PNG,WEBP}" />
|
||||
-->
|
||||
<policymap>
|
||||
<!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
|
||||
<policy domain="resource" name="memory" value="8GiB"/>
|
||||
<policy domain="resource" name="map" value="8GiB"/>
|
||||
<policy domain="resource" name="width" value="16KP"/>
|
||||
<policy domain="resource" name="height" value="16KP"/>
|
||||
<!-- <policy domain="resource" name="list-length" value="128"/> -->
|
||||
<policy domain="resource" name="area" value="128MP"/>
|
||||
<policy domain="resource" name="disk" value="8GiB"/>
|
||||
<!-- <policy domain="resource" name="file" value="768"/> -->
|
||||
<!-- <policy domain="resource" name="thread" value="4"/> -->
|
||||
<!-- <policy domain="resource" name="throttle" value="0"/> -->
|
||||
<!-- <policy domain="resource" name="time" value="3600"/> -->
|
||||
<!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
|
||||
<!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
|
||||
<!-- <policy domain="path" rights="none" pattern="@*" /> -->
|
||||
<!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->
|
||||
<!-- <policy domain="cache" name="synchronize" value="True"/> -->
|
||||
<!-- <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
|
||||
<!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->
|
||||
<!-- <policy domain="system" name="shred" value="2"/> -->
|
||||
<!-- <policy domain="system" name="precision" value="6"/> -->
|
||||
<!-- <policy domain="system" name="font" value="/path/to/font.ttf"/> -->
|
||||
<!-- <policy domain="system" name="pixel-cache-memory" value="anonymous"/> -->
|
||||
<!-- <policy domain="system" name="shred" value="2"/> -->
|
||||
<!-- <policy domain="system" name="precision" value="6"/> -->
|
||||
<!-- not needed due to the need to use explicitly by mvg: -->
|
||||
<!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
|
||||
<!-- use curl -->
|
||||
<policy domain="delegate" rights="none" pattern="URL" />
|
||||
<policy domain="delegate" rights="none" pattern="HTTPS" />
|
||||
<policy domain="delegate" rights="none" pattern="HTTP" />
|
||||
<!-- in order to avoid to get image with password text -->
|
||||
<policy domain="path" rights="none" pattern="@*"/>
|
||||
<!-- disable ghostscript format types -->
|
||||
<policy domain="coder" rights="none" pattern="PS" />
|
||||
<policy domain="coder" rights="none" pattern="PS2" />
|
||||
<policy domain="coder" rights="none" pattern="PS3" />
|
||||
<policy domain="coder" rights="none" pattern="EPS" />
|
||||
<!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
|
||||
<policy domain="coder" rights="none" pattern="XPS" />
|
||||
</policymap>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
|
||||
<fontconfig>
|
||||
<alias>
|
||||
<family>monospace</family>
|
||||
<prefer><family>Agave</family></prefer>
|
||||
</alias>
|
||||
</fontconfig>
|
|
@ -0,0 +1,28 @@
|
|||
[main]
|
||||
dpi-aware=no
|
||||
font=monospace:size=13
|
||||
|
||||
[colors]
|
||||
foreground=e3e0e1
|
||||
background=292526
|
||||
regular0=292526
|
||||
regular1=ff404f
|
||||
regular2=00a147
|
||||
regular3=e06e00
|
||||
regular4=6185ff
|
||||
regular5=ff3e8b
|
||||
regular6=0095d7
|
||||
regular7=e3e0e1
|
||||
bright0=958a8d
|
||||
bright1=ffb3b6
|
||||
bright2=00e46a
|
||||
bright3=ffb598
|
||||
bright4=b8c3ff
|
||||
bright5=ffb1c5
|
||||
bright6=92ccff
|
||||
bright7=f4f3f3
|
||||
|
||||
[search-bindings]
|
||||
find-prev=Control+Shift+n
|
||||
find-next=Control+n
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
[main]
|
||||
dpi-aware=no
|
||||
font=monospace:size=13
|
||||
icons-enabled=no
|
||||
width=72
|
||||
|
||||
[colors]
|
||||
background=e3e0e1ff
|
||||
text=292526ff
|
||||
match=ff3e8bff
|
||||
selection=e3e0e1ff
|
||||
selection-text=6185ffff
|
||||
selection-match=ff3e8bff
|
||||
border=6185ffff
|
||||
|
||||
[border]
|
||||
radius=0
|
|
@ -0,0 +1,11 @@
|
|||
font=monospace 13
|
||||
background-color=#e3e0e1
|
||||
text-color=#292526
|
||||
border-size=1
|
||||
border-color=#6185ff
|
||||
icons=0
|
||||
format=%s\n%b
|
||||
anchor=bottom-right
|
||||
|
||||
[urgency=critical]
|
||||
border-color=#ff404f
|
|
@ -0,0 +1,19 @@
|
|||
[Default Applications]
|
||||
application/pdf=org.pwmt.zathura.desktop
|
||||
text/english=nvim.desktop
|
||||
text/plain=nvim.desktop
|
||||
text/x-makefile=nvim.desktop
|
||||
text/x-c++hdr=nvim.desktop
|
||||
text/x-c++src=nvim.desktop
|
||||
text/x-chdr=nvim.desktop
|
||||
text/x-csrc=nvim.desktop
|
||||
text/x-java=nvim.desktop
|
||||
text/x-moc=nvim.desktop
|
||||
text/x-pascal=nvim.desktop
|
||||
text/x-tcl=nvim.desktop
|
||||
text/x-tex=nvim.desktop
|
||||
application/x-shellscript=nvim.desktop
|
||||
text/x-c=nvim.desktop
|
||||
text/x-c++=nvim.desktop
|
||||
x-scheme-handler/http=firefox-esr.desktop
|
||||
x-scheme-handler/https=firefox-esr.desktop
|
|
@ -0,0 +1,10 @@
|
|||
UP ignore
|
||||
DOWN ignore
|
||||
LEFT repeatable playlist-prev
|
||||
RIGHT repeatable playlist-next
|
||||
|
||||
MBTN_RIGHT script-binding drag-to-pan
|
||||
MBTN_LEFT script-binding pan-follows-cursor
|
||||
MBTN_LEFT_DBL ignore
|
||||
WHEEL_UP script-message cursor-centric-zoom 0.1
|
||||
WHEEL_DOWN script-message cursor-centric-zoom -0.1
|
|
@ -0,0 +1,8 @@
|
|||
# window
|
||||
image-display-duration=inf
|
||||
|
||||
# osd
|
||||
osd-level=0
|
||||
|
||||
# gpu renderer options
|
||||
background="#292526"
|
|
@ -0,0 +1,282 @@
|
|||
local opts = {
|
||||
drag_to_pan_margin = 50,
|
||||
drag_to_pan_move_if_full_view = false,
|
||||
|
||||
pan_follows_cursor_margin = 50,
|
||||
|
||||
cursor_centric_zoom_margin = 50,
|
||||
cursor_centric_zoom_auto_center = true,
|
||||
cursor_centric_zoom_dezoom_if_full_view = false,
|
||||
}
|
||||
local options = require 'mp.options'
|
||||
local msg = require 'mp.msg'
|
||||
local assdraw = require 'mp.assdraw'
|
||||
|
||||
options.read_options(opts, nil, function() end)
|
||||
|
||||
function clamp(value, low, high)
|
||||
if value <= low then
|
||||
return low
|
||||
elseif value >= high then
|
||||
return high
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
local cleanup = nil -- function set up by drag-to-pan/pan-follows cursor and must be called to clean lingering state
|
||||
|
||||
function drag_to_pan_handler(table)
|
||||
if cleanup then
|
||||
cleanup()
|
||||
cleanup = nil
|
||||
end
|
||||
if table["event"] == "down" then
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
local mouse_pos_origin, video_pan_origin = {}, {}
|
||||
local moved = false
|
||||
mouse_pos_origin[1], mouse_pos_origin[2] = mp.get_mouse_pos()
|
||||
video_pan_origin[1] = mp.get_property_number("video-pan-x")
|
||||
video_pan_origin[2] = mp.get_property_number("video-pan-y")
|
||||
local video_size = { dim.w - dim.ml - dim.mr, dim.h - dim.mt - dim.mb }
|
||||
local margin = opts.drag_to_pan_margin
|
||||
local move_up = true
|
||||
local move_lateral = true
|
||||
if not opts.drag_to_pan_move_if_full_view then
|
||||
if dim.ml >= 0 and dim.mr >= 0 then
|
||||
move_lateral = false
|
||||
end
|
||||
if dim.mt >= 0 and dim.mb >= 0 then
|
||||
move_up = false
|
||||
end
|
||||
end
|
||||
if not move_up and not move_lateral then return end
|
||||
local idle = function()
|
||||
if moved then
|
||||
local mX, mY = mp.get_mouse_pos()
|
||||
local pX = video_pan_origin[1]
|
||||
local pY = video_pan_origin[2]
|
||||
if move_lateral then
|
||||
pX = video_pan_origin[1] + (mX - mouse_pos_origin[1]) / video_size[1]
|
||||
if 2 * margin > dim.ml + dim.mr then
|
||||
pX = clamp(pX,
|
||||
(-margin + dim.w / 2) / video_size[1] - 0.5,
|
||||
(margin - dim.w / 2) / video_size[1] + 0.5)
|
||||
else
|
||||
pX = clamp(pX,
|
||||
(margin - dim.w / 2) / video_size[1] + 0.5,
|
||||
(-margin + dim.w / 2) / video_size[1] - 0.5)
|
||||
end
|
||||
end
|
||||
if move_up then
|
||||
pY = video_pan_origin[2] + (mY - mouse_pos_origin[2]) / video_size[2]
|
||||
if 2 * margin > dim.mt + dim.mb then
|
||||
pY = clamp(pY,
|
||||
(-margin + dim.h / 2) / video_size[2] - 0.5,
|
||||
(margin - dim.h / 2) / video_size[2] + 0.5)
|
||||
else
|
||||
pY = clamp(pY,
|
||||
(margin - dim.h / 2) / video_size[2] + 0.5,
|
||||
(-margin + dim.h / 2) / video_size[2] - 0.5)
|
||||
end
|
||||
end
|
||||
mp.command("no-osd set video-pan-x " .. clamp(pX, -3, 3) .. "; no-osd set video-pan-y " .. clamp(pY, -3, 3))
|
||||
moved = false
|
||||
end
|
||||
end
|
||||
mp.register_idle(idle)
|
||||
mp.add_forced_key_binding("mouse_move", "image-viewer-mouse-move", function() moved = true end)
|
||||
cleanup = function()
|
||||
mp.remove_key_binding("image-viewer-mouse-move")
|
||||
mp.unregister_idle(idle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pan_follows_cursor_handler(table)
|
||||
if cleanup then
|
||||
cleanup()
|
||||
cleanup = nil
|
||||
end
|
||||
if table["event"] == "down" then
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
local video_size = { dim.w - dim.ml - dim.mr, dim.h - dim.mt - dim.mb }
|
||||
local moved = true
|
||||
local idle = function()
|
||||
if moved then
|
||||
local mX, mY = mp.get_mouse_pos()
|
||||
local x = math.min(1, math.max(-2 * mX / dim.w + 1, -1))
|
||||
local y = math.min(1, math.max(-2 * mY / dim.h + 1, -1))
|
||||
local command = ""
|
||||
local margin = opts.pan_follows_cursor_margin
|
||||
if dim.ml + dim.mr < 0 then
|
||||
command = command ..
|
||||
"no-osd set video-pan-x " .. clamp(x * (2 * margin - dim.ml - dim.mr) / (2 * video_size[1]), -3, 3) .. ";"
|
||||
elseif mp.get_property_number("video-pan-x") ~= 0 then
|
||||
command = command .. "no-osd set video-pan-x " .. "0;"
|
||||
end
|
||||
if dim.mt + dim.mb < 0 then
|
||||
command = command ..
|
||||
"no-osd set video-pan-y " .. clamp(y * (2 * margin - dim.mt - dim.mb) / (2 * video_size[2]), -3, 3) .. ";"
|
||||
elseif mp.get_property_number("video-pan-y") ~= 0 then
|
||||
command = command .. "no-osd set video-pan-y " .. "0;"
|
||||
end
|
||||
if command ~= "" then
|
||||
mp.command(command)
|
||||
end
|
||||
moved = false
|
||||
end
|
||||
end
|
||||
mp.register_idle(idle)
|
||||
mp.add_forced_key_binding("mouse_move", "image-viewer-mouse-move", function() moved = true end)
|
||||
cleanup = function()
|
||||
mp.remove_key_binding("image-viewer-mouse-move")
|
||||
mp.unregister_idle(idle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cursor_centric_zoom_handler(amt)
|
||||
local zoom_inc = tonumber(amt)
|
||||
if not zoom_inc or zoom_inc == 0 then return end
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
|
||||
local margin = opts.cursor_centric_zoom_margin
|
||||
|
||||
local video_size = { dim.w - dim.ml - dim.mr, dim.h - dim.mt - dim.mb }
|
||||
|
||||
-- the size in pixels of the (in|de)crement
|
||||
local diff_width = (2 ^ zoom_inc - 1) * video_size[1]
|
||||
local diff_height = (2 ^ zoom_inc - 1) * video_size[2]
|
||||
if not opts.cursor_centric_zoom_dezoom_if_full_view and
|
||||
zoom_inc < 0 and
|
||||
video_size[1] + diff_width + 2 * margin <= dim.w and
|
||||
video_size[2] + diff_height + 2 * margin <= dim.h
|
||||
then
|
||||
-- the zoom decrement is too much, reduce it such that the full image is visible, no more, no less
|
||||
-- in addition, this should take care of trying too zoom out while everything is already visible
|
||||
local new_zoom_inc_x = math.log((dim.w - 2 * margin) / video_size[1]) / math.log(2)
|
||||
local new_zoom_inc_y = math.log((dim.h - 2 * margin) / video_size[2]) / math.log(2)
|
||||
local new_zoom_inc = math.min(0, math.min(new_zoom_inc_x, new_zoom_inc_y))
|
||||
zoom_inc = new_zoom_inc
|
||||
diff_width = (2 ^ zoom_inc - 1) * video_size[1]
|
||||
diff_height = (2 ^ zoom_inc - 1) * video_size[2]
|
||||
end
|
||||
local new_width = video_size[1] + diff_width
|
||||
local new_height = video_size[2] + diff_height
|
||||
|
||||
local mouse_pos_origin = {}
|
||||
mouse_pos_origin[1], mouse_pos_origin[2] = mp.get_mouse_pos()
|
||||
local new_pan_x, new_pan_y
|
||||
|
||||
-- some additional constraints:
|
||||
-- if image can be fully visible (in either direction), set pan to 0
|
||||
-- if border would show on either side, then prefer adjusting the pan even if not cursor-centric
|
||||
local auto_c = opts.cursor_centric_zoom_auto_center
|
||||
if auto_c and video_size[1] + diff_width + 2 * margin <= dim.w then
|
||||
new_pan_x = 0
|
||||
else
|
||||
local pan_x = mp.get_property("video-pan-x")
|
||||
local rx = (dim.ml + video_size[1] / 2 - mouse_pos_origin[1]) / (video_size[1] / 2)
|
||||
new_pan_x = (pan_x * video_size[1] + rx * diff_width / 2) / new_width
|
||||
if auto_c then
|
||||
new_pan_x = clamp(new_pan_x, (dim.w - 2 * margin) / (2 * new_width) - 0.5,
|
||||
-(dim.w - 2 * margin) / (2 * new_width) + 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
if auto_c and video_size[2] + diff_height + 2 * margin <= dim.h then
|
||||
new_pan_y = 0
|
||||
else
|
||||
local pan_y = mp.get_property("video-pan-y")
|
||||
local ry = (dim.mt + video_size[2] / 2 - mouse_pos_origin[2]) / (video_size[2] / 2)
|
||||
new_pan_y = (pan_y * video_size[2] + ry * diff_height / 2) / new_height
|
||||
if auto_c then
|
||||
new_pan_y = clamp(new_pan_y, (dim.h - 2 * margin) / (2 * new_height) - 0.5,
|
||||
-(dim.h - 2 * margin) / (2 * new_height) + 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
local zoom_origin = mp.get_property("video-zoom")
|
||||
mp.command("no-osd set video-zoom " ..
|
||||
zoom_origin + zoom_inc ..
|
||||
"; no-osd set video-pan-x " .. clamp(new_pan_x, -3, 3) .. "; no-osd set video-pan-y " .. clamp(new_pan_y, -3, 3))
|
||||
end
|
||||
|
||||
function align_border(x, y)
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
local video_size = { dim.w - dim.ml - dim.mr, dim.h - dim.mt - dim.mb }
|
||||
local x, y = tonumber(x), tonumber(y)
|
||||
local command = ""
|
||||
if x then
|
||||
command = command .. "no-osd set video-pan-x " .. clamp(-x * (dim.ml + dim.mr) / (2 * video_size[1]), -3, 3) .. ";"
|
||||
end
|
||||
if y then
|
||||
command = command .. "no-osd set video-pan-y " .. clamp(-y * (dim.mt + dim.mb) / (2 * video_size[2]), -3, 3) .. ";"
|
||||
end
|
||||
if command ~= "" then
|
||||
mp.command(command)
|
||||
end
|
||||
end
|
||||
|
||||
function pan_image(axis, amount, zoom_invariant, image_constrained)
|
||||
amount = tonumber(amount)
|
||||
if not amount or amount == 0 or axis ~= "x" and axis ~= "y" then return end
|
||||
if zoom_invariant == "yes" then
|
||||
amount = amount / 2 ^ mp.get_property_number("video-zoom")
|
||||
end
|
||||
local prop = "video-pan-" .. axis
|
||||
local old_pan = mp.get_property_number(prop)
|
||||
if image_constrained == "yes" then
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
local margin =
|
||||
(axis == "x" and amount > 0) and dim.ml
|
||||
or (axis == "x" and amount < 0) and dim.mr
|
||||
or (amount > 0) and dim.mt
|
||||
or (amount < 0) and dim.mb
|
||||
local vid_size = (axis == "x") and (dim.w - dim.ml - dim.mr) or (dim.h - dim.mt - dim.mb)
|
||||
local pixels_moved = math.abs(amount) * vid_size
|
||||
-- the margin is already visible, no point going further
|
||||
if margin >= 0 then
|
||||
return
|
||||
elseif margin + pixels_moved > 0 then
|
||||
amount = -(math.abs(amount) / amount) * margin / vid_size
|
||||
end
|
||||
end
|
||||
mp.set_property_number(prop, old_pan + amount)
|
||||
end
|
||||
|
||||
function rotate_video(amt)
|
||||
local rot = mp.get_property_number("video-rotate")
|
||||
rot = (rot + amt) % 360
|
||||
mp.set_property_number("video-rotate", rot)
|
||||
end
|
||||
|
||||
function reset_pan_if_visible()
|
||||
local dim = mp.get_property_native("osd-dimensions")
|
||||
if not dim then return end
|
||||
local command = ""
|
||||
if (dim.ml + dim.mr >= 0) then
|
||||
command = command .. "no-osd set video-pan-x 0" .. ";"
|
||||
end
|
||||
if (dim.mt + dim.mb >= 0) then
|
||||
command = command .. "no-osd set video-pan-y 0" .. ";"
|
||||
end
|
||||
if command ~= "" then
|
||||
mp.command(command)
|
||||
end
|
||||
end
|
||||
|
||||
mp.add_key_binding(nil, "drag-to-pan", drag_to_pan_handler, { complex = true })
|
||||
mp.add_key_binding(nil, "pan-follows-cursor", pan_follows_cursor_handler, { complex = true })
|
||||
mp.add_key_binding(nil, "cursor-centric-zoom", cursor_centric_zoom_handler)
|
||||
mp.add_key_binding(nil, "align-border", align_border)
|
||||
mp.add_key_binding(nil, "pan-image", pan_image)
|
||||
mp.add_key_binding(nil, "rotate-video", rotate_video)
|
||||
mp.add_key_binding(nil, "reset-pan-if-visible", reset_pan_if_visible)
|
||||
mp.add_key_binding(nil, "force-print-filename", force_print_filename)
|
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import atexit
|
||||
import readline
|
||||
|
||||
if "PYTHONHISTFILE" in os.environ:
|
||||
histfile = os.path.expanduser(os.environ["PYTHONHISTFILE"])
|
||||
elif "XDG_STATE_HOME" in os.environ:
|
||||
histfile = os.path.join(os.path.expanduser(
|
||||
os.environ["XDG_STATE_HOME"]), "python", "python_history")
|
||||
else:
|
||||
histfile = os.path.join(os.path.expanduser("~"), ".python_history")
|
||||
|
||||
|
||||
histfile = os.path.abspath(histfile)
|
||||
_dir, _ = os.path.split(histfile)
|
||||
os.makedirs(_dir, exist_ok=True)
|
||||
|
||||
|
||||
try:
|
||||
readline.read_history_file(histfile)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
atexit.register(readline.write_history_file, histfile)
|
|
@ -11,17 +11,19 @@ set keyseq-timeout 50
|
|||
# history search
|
||||
$if mode=vi
|
||||
set keymap vi-command
|
||||
"j": history-search-forward
|
||||
"k": history-search-backward
|
||||
"j": history-substring-search-forward
|
||||
"k": history-substring-search-backward
|
||||
set keymap vi-insert
|
||||
"\e[A": history-search-backward
|
||||
"\e[B": history-search-forward
|
||||
"\e[A": history-substring-search-backward
|
||||
"\e[B": history-substring-search-forward
|
||||
$endif
|
||||
|
||||
# faster completion
|
||||
"\t":menu-complete
|
||||
"\e[Z":menu-complete-backward
|
||||
set completion-ignore-case on
|
||||
set show-all-if-ambiguous on
|
||||
set completion-display-width 0
|
||||
|
||||
# color
|
||||
set colored-stats on
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
startup_message off
|
||||
maptimeout 5
|
||||
# hardstatus
|
||||
hardstatus off
|
||||
hardstatus alwayslastline
|
||||
hardstatus string "%{= b} %S %?%E%{m}%?ESC%{b}%=%?%-Lw%?%{m}%n%f %t%?(%u)%?%{-}%?%+Lw%?%= %D %M %d %c"
|
||||
# caption
|
||||
caption always
|
||||
caption string "%?%F%{= m}%:%{= b}%?%=> %n%f %t%? (%u)%? <%="
|
||||
# rendition
|
||||
rendition so "=00"
|
||||
|
||||
bind h focus left
|
||||
bind j focus down
|
||||
bind k focus up
|
||||
bind l focus right
|
||||
|
||||
altscreen on
|
||||
nonblock on
|
||||
|
||||
termcapinfo foot* ti@:te@
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
printf "{\"version\":1}\n"
|
||||
printf "[\n"
|
||||
while true
|
||||
do
|
||||
printf [
|
||||
printf "{\"full_text\":\"%s\"},"\
|
||||
"$(swaymsg -t get_inputs | jq -Mcj '
|
||||
[.[]
|
||||
| select(.type == "keyboard")][0]
|
||||
| .xkb_active_layout_name')"\
|
||||
"$(cat /sys/class/power_supply/BAT0/capacity)"\
|
||||
"$(date +%c)"
|
||||
printf ],
|
||||
timeout 1 swaymsg -t subscribe '["input"]' >/dev/null
|
||||
done
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
# variables ####################################################################
|
||||
# logo key
|
||||
set $mod Mod4
|
||||
# home row direction keys
|
||||
set $left h
|
||||
set $down j
|
||||
set $up k
|
||||
set $right l
|
||||
|
||||
# key bindings #################################################################
|
||||
# start terminal
|
||||
bindsym $mod+return exec footclient
|
||||
bindsym $mod+shift+return exec foot
|
||||
# start browser
|
||||
bindsym $mod+w exec firefox
|
||||
bindsym $mod+shift+w exec thunderbird
|
||||
# start menu
|
||||
bindsym $mod+space exec fuzzel
|
||||
bindsym $mod+home exec nmcli -g "type,name,active" connection show \
|
||||
| awk -P 'BEGIN{FS=":"}{printf($3=="yes")?"* %s\\n":" %s\\n",$2}' \
|
||||
| fuzzel -d \
|
||||
| awk -P '{printf($1=="*")?"nmcli connection down \\"%s\\"":"nmcli connection up \\"%s\\"",substr($0,3)}' \
|
||||
| sh \
|
||||
| xargs -tI{} notify-send "{}"
|
||||
bindsym $mod+shift+home exec footclient nmtui
|
||||
bindsym $mod+o exec find -not -path "*/.*" \
|
||||
| fuzzel -d \
|
||||
| xargs -I{} xdg-open "{}"
|
||||
bindsym $mod+shift+o exec find -L -type d \
|
||||
| fuzzel -d \
|
||||
| xargs -I{} footclient -D "{}"
|
||||
bindsym $mod+insert exec lsblk -nrpo"name,type,mountpoint" \
|
||||
| awk -P '$2=="part"{printf"%-12s %s\\n",$1,$3}' \
|
||||
| fuzzel -d \
|
||||
| awk -P '{printf($2=="")?"udisksctl mount -b %s":"udisksctl unmount -b %s",$1}' \
|
||||
| sh \
|
||||
| xargs -I{} notify-send "{}"
|
||||
# notifications
|
||||
bindsym $mod+x exec makoctl dismiss
|
||||
bindsym $mod+shift+x exec makoctl dismiss -a
|
||||
bindsym --to-code $mod+z exec makoctl restore
|
||||
# kill window
|
||||
bindsym $mod+q kill
|
||||
# move focus
|
||||
bindsym $mod+$up focus up
|
||||
bindsym $mod+$down focus down
|
||||
bindsym $mod+$left focus left
|
||||
bindsym $mod+$right focus right
|
||||
# move focused window
|
||||
bindsym $mod+shift+$up move up
|
||||
bindsym $mod+shift+$down move down
|
||||
bindsym $mod+shift+$left move left
|
||||
bindsym $mod+shift+$right move right
|
||||
# switch to workspace
|
||||
bindsym $mod+1 workspace number 1
|
||||
bindsym $mod+2 workspace number 2
|
||||
bindsym $mod+3 workspace number 3
|
||||
bindsym $mod+4 workspace number 4
|
||||
bindsym $mod+5 workspace number 5
|
||||
bindsym $mod+6 workspace number 6
|
||||
bindsym $mod+7 workspace number 7
|
||||
bindsym $mod+8 workspace number 8
|
||||
bindsym $mod+9 workspace number 9
|
||||
bindsym $mod+0 workspace number 10
|
||||
bindsym $mod+next workspace next
|
||||
bindsym $mod+prior workspace prev
|
||||
# move focused to workspace
|
||||
bindsym $mod+shift+1 move container to workspace number 1, workspace number 1
|
||||
bindsym $mod+shift+2 move container to workspace number 2, workspace number 2
|
||||
bindsym $mod+shift+3 move container to workspace number 3, workspace number 3
|
||||
bindsym $mod+shift+4 move container to workspace number 4, workspace number 4
|
||||
bindsym $mod+shift+5 move container to workspace number 5, workspace number 5
|
||||
bindsym $mod+shift+6 move container to workspace number 6, workspace number 6
|
||||
bindsym $mod+shift+7 move container to workspace number 7, workspace number 7
|
||||
bindsym $mod+shift+8 move container to workspace number 8, workspace number 8
|
||||
bindsym $mod+shift+9 move container to workspace number 9, workspace number 9
|
||||
bindsym $mod+shift+0 move container to workspace number 10, workspace number 10
|
||||
bindsym $mod+shift+next move container to workspace next, workspace next
|
||||
bindsym $mod+shift+prior move container to workspace prev, workspace prev
|
||||
# resize
|
||||
bindsym $mod+control+$left resize shrink width
|
||||
bindsym $mod+control+$down resize grow height
|
||||
bindsym $mod+control+$up resize shrink height
|
||||
bindsym $mod+control+$right resize grow width
|
||||
# layout
|
||||
bindsym $mod+a focus parent
|
||||
bindsym $mod+shift+a focus child
|
||||
bindsym $mod+s layout toggle split
|
||||
bindsym $mod+shift+s split toggle
|
||||
bindsym $mod+d layout toggle tabbed split
|
||||
bindsym $mod+f fullscreen toggle
|
||||
bindsym $mod+shift+f floating toggle
|
||||
bindsym $mod+g focus mode_toggle
|
||||
bindsym $mod+shift+g sticky toggle
|
||||
bindsym $mod+period scratchpad show
|
||||
bindsym $mod+shift+period move scratchpad
|
||||
# mouse
|
||||
floating_modifier $mod normal
|
||||
# laptop
|
||||
bindsym XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+;\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio_sink "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
|
||||
bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-;\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio_sink "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
|
||||
bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle;\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio_sink "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
|
||||
bindsym XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle;\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio_source "$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)"
|
||||
bindsym XF86MonBrightnessUp exec brightnessctl set "+1%";\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
|
||||
bindsym XF86MonBrightnessDown exec brightnessctl set "1%-";\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
|
||||
bindsym shift+XF86MonBrightnessUp exec brightnessctl set "+10%";\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
|
||||
bindsym shift+XF86MonBrightnessDown exec brightnessctl set "10%-";\
|
||||
exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
|
||||
# screenshots
|
||||
bindsym print exec grim - | wl-copy
|
||||
|
||||
# mark mode ####################################################################
|
||||
set $mark_mode "mark [abc]"
|
||||
mode $mark_mode {
|
||||
bindsym a mark --toggle a, mode default
|
||||
bindsym b mark --toggle b, mode default
|
||||
bindsym c mark --toggle c, mode default
|
||||
bindsym backspace unmark, mode default
|
||||
# return
|
||||
bindsym escape mode "default"
|
||||
bindsym $mod+escape mode "default"
|
||||
}
|
||||
bindsym $mod+m mode $mark_mode
|
||||
|
||||
# tab mode #####################################################################
|
||||
set $tab_mode "tab [abc]"
|
||||
mode $tab_mode {
|
||||
bindsym a [con_mark="a"] focus, mode default
|
||||
bindsym b [con_mark="b"] focus, mode default
|
||||
bindsym c [con_mark="c"] focus, mode default
|
||||
# return
|
||||
bindsym escape mode "default"
|
||||
bindsym $mod+escape mode "default"
|
||||
}
|
||||
bindsym $mod+tab mode $tab_mode
|
||||
|
||||
# session mode #################################################################
|
||||
set $session_mode "session: (r)eload (l)ock (q)uit (s)uspend re(b)oot (p)oweroff"
|
||||
mode $session_mode {
|
||||
bindsym r reload, mode default
|
||||
bindsym l exec swaylock, mode default
|
||||
bindsym q exit, mode default
|
||||
bindsym s exec systemctl suspend, mode default
|
||||
bindsym b exec systemctl reboot, mode default
|
||||
bindsym p exec systemctl poweroff, mode default
|
||||
# return
|
||||
bindsym escape mode default
|
||||
bindsym $mod+escape mode default
|
||||
}
|
||||
bindsym $mod+escape mode $session_mode
|
||||
|
||||
# visuals ######################################################################
|
||||
set $bg #292526
|
||||
set $dimmed #6185ff
|
||||
set $accent #ff3e8b
|
||||
set $error #ff404f
|
||||
|
||||
# output
|
||||
output * {
|
||||
background $bg solid_color
|
||||
adaptive_sync on
|
||||
}
|
||||
|
||||
# font
|
||||
font monospace 13
|
||||
|
||||
# border
|
||||
default_border normal 1
|
||||
default_floating_border normal 1
|
||||
|
||||
# class border background text indicator child_border
|
||||
client.focused $accent $accent $bg $error $bg
|
||||
client.focused_inactive $dimmed $dimmed $bg $bg $bg
|
||||
client.unfocused $dimmed $dimmed $bg $bg $bg
|
||||
client.urgent $error $error $bg $error $bg
|
||||
|
||||
# behaviour ####################################################################
|
||||
workspace_layout tabbed
|
||||
focus_follows_mouse yes
|
||||
focus_wrapping yes
|
||||
|
||||
# statusbar ####################################################################
|
||||
bar {
|
||||
status_command ~/.config/sway/bin/status.sh
|
||||
separator_symbol " | "
|
||||
colors {
|
||||
background $bg
|
||||
statusline $dimmed
|
||||
separator $dimmed
|
||||
# border background text
|
||||
focused_workspace $bg $bg $accent
|
||||
active_workspace $dimmed $bg $dimmed
|
||||
inactive_workspace $bg $bg $dimmed
|
||||
urgent_workspace $bg $bg $error
|
||||
}
|
||||
}
|
||||
|
||||
# xwayland #####################################################################
|
||||
xwayland disable
|
||||
|
||||
# autostart ####################################################################
|
||||
exec swayidle
|
||||
exec wlsunset -l 45 -L 15
|
||||
exec mako
|
||||
exec foot --server
|
||||
|
||||
# include ######################################################################
|
||||
include ~/.config/sway/`hostname`
|
|
@ -0,0 +1,14 @@
|
|||
# input
|
||||
input "type:keyboard" {
|
||||
xkb_layout gb,si
|
||||
xkb_options caps:escape,grp:alt_shift_toggle
|
||||
repeat_delay 200
|
||||
repeat_rate 30
|
||||
}
|
||||
|
||||
input "type:touchpad" {
|
||||
tap enabled
|
||||
}
|
||||
|
||||
# seat
|
||||
seat * hide_cursor 5000
|
|
@ -0,0 +1,20 @@
|
|||
# clamshell
|
||||
set $laptop LVDS-1
|
||||
bindswitch --reload --locked lid:on output $laptop disable
|
||||
bindswitch --reload --locked lid:off output $laptop enable
|
||||
|
||||
# input
|
||||
input "type:keyboard" {
|
||||
xkb_layout us,si
|
||||
xkb_options caps:escape,grp:alt_shift_toggle
|
||||
xkb_numlock enabled
|
||||
repeat_delay 300
|
||||
repeat_rate 30
|
||||
}
|
||||
|
||||
input "type:touchpad" {
|
||||
tap enabled
|
||||
}
|
||||
|
||||
# seat
|
||||
seat * hide_cursor 5000
|
|
@ -0,0 +1,3 @@
|
|||
timeout 300 'swaylock'
|
||||
timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
|
||||
before-sleep 'swaylock'
|
|
@ -0,0 +1,32 @@
|
|||
show-failed-attempts
|
||||
daemonize
|
||||
color=292526
|
||||
bs-hl-color=00000000
|
||||
caps-lock-bs-hl-color=00000000
|
||||
caps-lock-key-hl-color=00000000
|
||||
font=monospace
|
||||
inside-color=00000000
|
||||
inside-clear-color=00000000
|
||||
inside-caps-lock-color=00000000
|
||||
inside-ver-color=00000000
|
||||
inside-wrong-color=00000000
|
||||
key-hl-color=00000000
|
||||
layout-bg-color=00000000
|
||||
layout-border-color=00000000
|
||||
layout-text-color=6185ff
|
||||
line-color=00000000
|
||||
line-clear-color=00000000
|
||||
line-caps-lock-color=00000000
|
||||
line-ver-color=00000000
|
||||
line-wrong-color=00000000
|
||||
ring-color=00000000
|
||||
ring-clear-color=00000000
|
||||
ring-caps-lock-color=00000000
|
||||
ring-ver-color=00000000
|
||||
ring-wrong-color=00000000
|
||||
separator-color=00000000
|
||||
text-color=6185ff
|
||||
text-clear-color=6185ff
|
||||
text-caps-lock-color=6185ff
|
||||
text-ver-color=ff3e8b
|
||||
text-wrong-color=ff404f
|
|
@ -0,0 +1,8 @@
|
|||
XDG_DOCUMENTS_DIR="$HOME/doc"
|
||||
XDG_DOWNLOAD_DIR="$HOME/net"
|
||||
XDG_DESKTOP_DIR="$HOME/net"
|
||||
XDG_MUSIC_DIR="$HOME/net"
|
||||
XDG_PICTURES_DIR="$HOME/net"
|
||||
XDG_PUBLICSHARE_DIR="$HOME/net"
|
||||
XDG_TEMPLATES_DIR="$HOME/net"
|
||||
XDG_VIDEOS_DIR="$HOME/net"
|
|
@ -0,0 +1,31 @@
|
|||
set selection-clipboard clipboard
|
||||
set completion-bg "#e3e0e1"
|
||||
set completion-fg "#ff3e8b"
|
||||
set completion-group-bg "#e3e0e1"
|
||||
set completion-group-fg "#6185ff"
|
||||
set completion-highlight-bg "#ff3e8b"
|
||||
set completion-highlight-fg "#e3e0e1"
|
||||
set default-fg "#e3e0e1"
|
||||
set default-bg "#292526"
|
||||
set inputbar-bg "#292526"
|
||||
set inputbar-fg "#6185ff"
|
||||
set notification-bg "#292526"
|
||||
set notification-fg "#6185ff"
|
||||
set notification-error-bg "#292526"
|
||||
set notification-error-fg "#ff404f"
|
||||
set notification-warning-bg "#292526"
|
||||
set notification-warning-fg "#e06e00"
|
||||
set statusbar-bg "#292526"
|
||||
set statusbar-fg "#ff3e8b"
|
||||
set highlight-color "#6185ff"
|
||||
set highlight-fg "#00ff00" # find out what this does
|
||||
set highlight-active-color "#ff3e8b"
|
||||
set recolor-darkcolor "#e3e0e1"
|
||||
set recolor-lightcolor "#292526"
|
||||
set render-loading-bg "#292526"
|
||||
set render-loading-fg "#6185ff"
|
||||
set index-fg "#ff3e8b"
|
||||
set index-bg "#e3e0e1"
|
||||
set index-active-fg "#e3e0e1"
|
||||
set index-active-bg "#ff3e8b"
|
||||
set font "monospace 13"
|
6
.profile
6
.profile
|
@ -88,7 +88,9 @@ if [ "$(tty)" = "/dev/tty1" ] && command -v sway &>/dev/null; then
|
|||
# wayland
|
||||
# export WLR_DRM_NO_ATOMIC=1
|
||||
|
||||
# ssh agent
|
||||
eval $(ssh-agent)
|
||||
|
||||
# run sway
|
||||
# exec systemd-cat --identifier=sway ssh-agent sway
|
||||
exec ssh-agent sway
|
||||
exec systemd-cat --identifier=sway sway
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
```sh
|
||||
# dotfiles
|
||||
sudo apt install git
|
||||
cd
|
||||
git init
|
||||
git remote add origin gitea@git.kompot.si:urosm/dot.git
|
||||
git pull
|
||||
git checkout main -f
|
||||
# locale setup
|
||||
sudo dpkg-reconfigure locales
|
||||
# utils
|
||||
sudo apt install unzip
|
||||
sudo apt install curl
|
||||
sudo apt install jq
|
||||
sudo apt install screen
|
||||
sudo apt install rsync
|
||||
sudo apt install udisks2
|
||||
# networking
|
||||
sudo apt install network-manager
|
||||
# firewall
|
||||
sudo apt install ufw
|
||||
sudo ufw allow "SSH"
|
||||
sudo ufw allow 1194/udp
|
||||
sudo ufw enable
|
||||
# neovim
|
||||
sudo apt install neovim
|
||||
# sway
|
||||
sudo apt install --no-install-recommends sway
|
||||
sudo apt install swayidle swaylock
|
||||
sudo apt install xdg-desktop-portal-wlr
|
||||
sudo apt install foot
|
||||
sudo apt install fuzzel
|
||||
sudo apt install brightnessctl wlsunset
|
||||
sudo apt install fonts-agave
|
||||
sudo apt install grim
|
||||
sudo apt install wl-clipboard
|
||||
# notifications
|
||||
sudo apt install mako-notifier libnotify-bin
|
||||
# audio
|
||||
sudo apt install pipewire-audio
|
||||
systemctl --user enable --now wireplumber.service
|
||||
# web and media
|
||||
sudo apt install firefox-esr
|
||||
sudo apt install thunderbird
|
||||
sudo apt install mpv
|
||||
sudo apt install zathura zathura-djvu
|
||||
# writing
|
||||
sudo apt install pandoc
|
||||
sudo apt install texlive-latex-recommended texlive-fonts-extra # TODO
|
||||
# office
|
||||
sudo apt install libreoffice
|
||||
sudo apt install libreoffice-gtk3
|
||||
sudo apt install libreoffice-l10n-sl
|
||||
# printing and scanning
|
||||
sudo apt install cups
|
||||
sudo apt install simple-scan
|
||||
# pdf processing
|
||||
sudo apt install qpdf
|
||||
sudo apt install imagemagick
|
||||
sudo apt install ocrmypdf
|
||||
# remote desktop
|
||||
sudo apt install remmina
|
||||
sudo apt install wireguard-tools
|
||||
```
|
Loading…
Reference in New Issue