[UP] add many more ion3 cfg -_-, powerfull, and add thinkpad xorg.conf/.Xmodmap,...
[arrow.git] / archlinux_conf / etc / ion3 / lock_frame.lua
blobb8045acaeda5b1b9a639389ac8ca4d200d58de1a
1 --[[
2 Author: James Gray, Etan Reisner
3 Email: james at solitaryfield dot org, deryni@unreliablesource.net
4 IRC: yaarg, deryni
5 Summary: Allows locking
6 Version: 0.2
7 Last Updated: Fri Jun 22 00:59:06 EDT 2007
8 --]]
10 -- Usage:
11 -- F11 toggles the lock of keyboard close and resize on the currently active
12 -- frame.
13 -- META-F11 will save the name of the frame and lock it again in subsequent
14 -- sessions of ion.
16 -- You will need to rebind your close and kill bindings to use the
17 -- check_before_close and check_before_kill functions for this script to do
18 -- anything.
20 -- Adding
21 -- de.substyle("*-*-*-locked", {
22 -- background_colour = "yellow",
23 -- }),
25 -- de.substyle("*-*-*-*-locked_saved", {
26 -- background_colour = "white",
27 -- }),
28 -- to your theme's de.defstyle("tab-frame", {...}) style will cause locked and
29 -- locked+saved frames to be highlighted.
31 local locks = setmetatable({}, {__mode="k"})
32 local saved = {}
34 function lock_frame(frame, save)
35 local name = frame:name()
37 if locks[frame] then
38 locks[frame] = nil
39 frame:set_grattr("locked", "unset")
40 if save and name then
41 frame:set_grattr("locked_saved", "unset")
42 saved[name] = nil
43 end
44 else
45 locks[frame] = true
46 frame:set_grattr("locked", "set")
47 if save and name then
48 frame:set_grattr("locked_saved", "set")
49 saved[name] = true
50 end
51 end
52 end
54 function check_before_kill(reg)
55 if not locks[reg] then
56 WClientWin.kill(reg)
57 end
58 end
60 function check_before_close(reg, sub)
61 if (not locks[reg]) and (not locks[sub]) then
62 WRegion.rqclose_propagate(reg, sub)
63 end
64 end
66 ioncore.defbindings("WFrame",{
67 kpress("F11", "lock_frame(_)"),
68 kpress(META.."F11", "lock_frame(_, true)")
71 function save_locked()
72 ioncore.write_savefile("saved_lock_frame", saved)
73 end
75 function load_locked()
76 local locked = ioncore.read_savefile("saved_lock_frame") or {}
78 for k,v in pairs(locked) do
79 local reg = ioncore.lookup_region(k)
80 lock_frame(reg, true)
81 end
82 end
84 local hook = ioncore.get_hook("ioncore_deinit_hook")
85 if hook then
86 hook:add(save_locked)
87 end
88 hook = nil
90 load_locked()