source: lmd-client/trunk/fuentes/install/var/lib/ltsp-awesome-desktop/rc.lua @ 512

Last change on this file since 512 was 512, checked in by mabarracus, 5 years ago

copy trusty code

File size: 16.5 KB
Line 
1-- Standard awesome library
2require("awful")
3require("awful.autofocus")
4require("awful.rules")
5-- Theme handling library
6require("beautiful")
7-- Notification library
8require("naughty")
9
10-- Load Debian menu entries
11require("debian.menu")
12
13
14--require('freedesktop.desktop')
15--for s = 1, screen.count() do
16--        freedesktop.desktop.add_applications_icons({screen = s, showlabels = true, dir = '~/awesome/icons'})
17--        freedesktop.desktop.add_dirs_and_files_icons({screen = s, showlabels = true, dir = '~/awesome/icons'})
18--end
19
20
21-- {{{ Error handling
22-- Check if awesome encountered an error during startup and fell back to
23-- another config (This code will only ever execute for the fallback config)
24if awesome.startup_errors then
25    naughty.notify({ preset = naughty.config.presets.critical,
26                     title = "Oops, there were errors during startup!",
27                     text = awesome.startup_errors })
28end
29
30-- Handle runtime errors after startup
31do
32    local in_error = false
33    awesome.add_signal("debug::error", function (err)
34        -- Make sure we don't go into an endless error loop
35        if in_error then return end
36        in_error = true
37
38        naughty.notify({ preset = naughty.config.presets.critical,
39                         title = "Oops, an error happened!",
40                         text = err })
41        in_error = false
42    end)
43end
44-- }}}
45
46-- {{{ Variable definitions
47-- Themes define colours, icons, and wallpapers
48beautiful.init("/usr/share/awesome/themes/lliurex/theme.lua")
49
50-- This is used later as the default terminal and editor to run.
51terminal = "x-terminal-emulator"
52editor = os.getenv("EDITOR") or "editor"
53editor_cmd = terminal .. " -e " .. editor
54
55-- Default modkey.
56-- Usually, Mod4 is the key with a logo between Control and Alt.
57-- If you do not like this or do not have such a key,
58-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
59-- However, you can use another modifier like Mod1, but it may interact with others.
60modkey = "Mod4"
61
62-- Table of layouts to cover with awful.layout.inc, order matters.
63layouts =
64{
65    awful.layout.suit.floating,
66    awful.layout.suit.tile,
67    awful.layout.suit.tile.left,
68    awful.layout.suit.tile.bottom,
69    awful.layout.suit.tile.top,
70    awful.layout.suit.fair,
71    awful.layout.suit.fair.horizontal,
72    awful.layout.suit.spiral,
73    awful.layout.suit.spiral.dwindle,
74    awful.layout.suit.max,
75    awful.layout.suit.max.fullscreen,
76    awful.layout.suit.magnifier
77}
78-- }}}
79
80-- {{{ Tags
81-- Define a tag table which hold all screen tags.
82tags = {}
83for s = 1, screen.count() do
84    -- Each screen has its own tag table.
85    tags[s] = awful.tag({ 1, 2, 3, 4 }, s, layouts[1])
86    -- tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
87end
88-- }}}
89
90-- {{{ Menu
91-- Create a laucher widget and a main menu
92myawesomemenu = {
93   { "manual", terminal .. " -e man awesome" },
94   { "edit config", editor_cmd .. " " .. awesome.conffile },
95   { "restart", awesome.restart },
96   { "quit", awesome.quit }
97}
98
99---mymainmenu = awful.menu({ items = { { "Escriptori Awesome", myawesomemenu, beautiful.awesome_icon },
100mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
101
102                                    { "LliureX", debian.menu.Debian_menu.Debian },
103                                    { "Terminal", terminal }
104                                  }
105                        })
106
107mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
108                                     menu = mymainmenu })
109-- }}}
110
111-- {{{ Wibox
112-- Create a textclock widget
113mytextclock = awful.widget.textclock({ align = "right" })
114
115-- Create a systray
116mysystray = widget({ type = "systray" })
117
118-- Create a wibox for each screen and add it
119mywibox = {}
120mypromptbox = {}
121mylayoutbox = {}
122mytaglist = {}
123mytaglist.buttons = awful.util.table.join(
124                    awful.button({ }, 1, awful.tag.viewonly),
125                    awful.button({ modkey }, 1, awful.client.movetotag),
126                    awful.button({ }, 3, awful.tag.viewtoggle),
127                    awful.button({ modkey }, 3, awful.client.toggletag),
128                    awful.button({ }, 4, awful.tag.viewnext),
129                    awful.button({ }, 5, awful.tag.viewprev)
130                    )
131mytasklist = {}
132mytasklist.buttons = awful.util.table.join(
133                     awful.button({ }, 1, function (c)
134                                              if c == client.focus then
135                                                  c.minimized = true
136                                              else
137                                                  if not c:isvisible() then
138                                                      awful.tag.viewonly(c:tags()[1])
139                                                  end
140                                                  -- This will also un-minimize
141                                                  -- the client, if needed
142                                                  client.focus = c
143                                                  c:raise()
144                                              end
145                                          end),
146                     awful.button({ }, 3, function ()
147                                              if instance then
148                                                  instance:hide()
149                                                  instance = nil
150                                              else
151                                                  instance = awful.menu.clients({ width=250 })
152                                              end
153                                          end),
154                     awful.button({ }, 4, function ()
155                                              awful.client.focus.byidx(1)
156                                              if client.focus then client.focus:raise() end
157                                          end),
158                     awful.button({ }, 5, function ()
159                                              awful.client.focus.byidx(-1)
160                                              if client.focus then client.focus:raise() end
161                                          end))
162
163for s = 1, screen.count() do
164    -- Create a promptbox for each screen
165    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
166    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
167    -- We need one layoutbox per screen.
168    mylayoutbox[s] = awful.widget.layoutbox(s)
169    mylayoutbox[s]:buttons(awful.util.table.join(
170                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
171                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
172                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
173                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
174    -- Create a taglist widget
175    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
176
177    -- Create a tasklist widget
178    mytasklist[s] = awful.widget.tasklist(function(c)
179                                              return awful.widget.tasklist.label.currenttags(c, s)
180                                          end, mytasklist.buttons)
181
182    -- Create the wibox
183    mywibox[s] = awful.wibox({ position = "bottom", screen = s })
184    -- Add widgets to the wibox - order matters
185    mywibox[s].widgets = {
186        {
187            mylauncher,
188            mytaglist[s],
189            mypromptbox[s],
190            layout = awful.widget.layout.horizontal.leftright
191        },
192        mylayoutbox[s],
193        mytextclock,
194        s == 1 and mysystray or nil,
195        mytasklist[s],
196        layout = awful.widget.layout.horizontal.rightleft
197    }
198end
199-- }}}
200
201-- {{{ Mouse bindings
202root.buttons(awful.util.table.join(
203    awful.button({ }, 3, function () mymainmenu:toggle() end),
204    awful.button({ }, 4, awful.tag.viewnext),
205    awful.button({ }, 5, awful.tag.viewprev)
206))
207-- }}}
208
209-- {{{ Key bindings
210globalkeys = awful.util.table.join(
211    awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
212    awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
213    awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
214
215    awful.key({ modkey,           }, "j",
216        function ()
217            awful.client.focus.byidx( 1)
218            if client.focus then client.focus:raise() end
219        end),
220    awful.key({ modkey,           }, "k",
221        function ()
222            awful.client.focus.byidx(-1)
223            if client.focus then client.focus:raise() end
224        end),
225    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
226
227    -- Layout manipulation
228    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
229    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
230    awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
231    awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
232    awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
233    awful.key({ modkey,           }, "Tab",
234        function ()
235            awful.client.focus.history.previous()
236            if client.focus then
237                client.focus:raise()
238            end
239        end),
240
241    -- Standard program
242    awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
243    awful.key({ modkey, "Control" }, "r", awesome.restart),
244    awful.key({ modkey, "Shift"   }, "q", awesome.quit),
245
246    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
247    awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
248    awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
249    awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
250    awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
251    awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
252    awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
253    awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
254
255    awful.key({ modkey, "Control" }, "n", awful.client.restore),
256
257    -- Prompt
258    awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
259
260    awful.key({ modkey }, "x",
261              function ()
262                  awful.prompt.run({ prompt = "Run Lua code: " },
263                  mypromptbox[mouse.screen].widget,
264                  awful.util.eval, nil,
265                  awful.util.getdir("cache") .. "/history_eval")
266              end)
267)
268
269clientkeys = awful.util.table.join(
270    awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
271    awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
272    awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
273    awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
274    awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
275    awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
276    awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
277    awful.key({ modkey,           }, "n",
278        function (c)
279            -- The client currently has the input focus, so it cannot be
280            -- minimized, since minimized clients can't have the focus.
281            c.minimized = true
282        end),
283    awful.key({ modkey,           }, "m",
284        function (c)
285            c.maximized_horizontal = not c.maximized_horizontal
286            c.maximized_vertical   = not c.maximized_vertical
287        end)
288)
289
290-- Compute the maximum number of digit we need, limited to 9
291keynumber = 0
292for s = 1, screen.count() do
293   keynumber = math.min(9, math.max(#tags[s], keynumber));
294end
295
296-- Bind all key numbers to tags.
297-- Be careful: we use keycodes to make it works on any keyboard layout.
298-- This should map on the top row of your keyboard, usually 1 to 9.
299for i = 1, keynumber do
300    globalkeys = awful.util.table.join(globalkeys,
301        awful.key({ modkey }, "#" .. i + 9,
302                  function ()
303                        local screen = mouse.screen
304                        if tags[screen][i] then
305                            awful.tag.viewonly(tags[screen][i])
306                        end
307                  end),
308        awful.key({ modkey, "Control" }, "#" .. i + 9,
309                  function ()
310                      local screen = mouse.screen
311                      if tags[screen][i] then
312                          awful.tag.viewtoggle(tags[screen][i])
313                      end
314                  end),
315        awful.key({ modkey, "Shift" }, "#" .. i + 9,
316                  function ()
317                      if client.focus and tags[client.focus.screen][i] then
318                          awful.client.movetotag(tags[client.focus.screen][i])
319                      end
320                  end),
321        awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
322                  function ()
323                      if client.focus and tags[client.focus.screen][i] then
324                          awful.client.toggletag(tags[client.focus.screen][i])
325                      end
326                  end))
327end
328
329clientbuttons = awful.util.table.join(
330    awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
331    awful.button({ modkey }, 1, awful.mouse.client.move),
332    awful.button({ modkey }, 3, awful.mouse.client.resize))
333
334-- Set keys
335root.keys(globalkeys)
336-- }}}
337
338-- {{{ Rules
339awful.rules.rules = {
340    -- All clients will match this rule.
341    { rule = { },
342      properties = { border_width = beautiful.border_width,
343                     border_color = beautiful.border_normal,
344                     focus = true,
345                     keys = clientkeys,
346                     buttons = clientbuttons } },
347    { rule = { class = "MPlayer" },
348      properties = { floating = true } },
349    { rule = { class = "pinentry" },
350      properties = { floating = true } },
351    { rule = { class = "gimp" },
352      properties = { floating = true } },
353    -- Set Firefox to always map on tags number 2 of screen 1.
354    -- { rule = { class = "Firefox" },
355    --   properties = { tag = tags[1][2] } },
356}
357-- }}}
358
359-- {{{ Signals
360-- Signal function to execute when a new client appears.
361client.add_signal("manage", function (c, startup)
362    -- Add a titlebar
363    awful.titlebar.add(c, { modkey = modkey })
364
365    -- Enable sloppy focus
366    c:add_signal("mouse::enter", function(c)
367        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
368            and awful.client.focus.filter(c) then
369            client.focus = c
370        end
371    end)
372
373    if not startup then
374        -- Set the windows at the slave,
375        -- i.e. put it at the end of others instead of setting it master.
376        -- awful.client.setslave(c)
377
378        -- Put windows in a smart way, only if they does not set an initial position.
379        if not c.size_hints.user_position and not c.size_hints.program_position then
380            awful.placement.no_overlap(c)
381            awful.placement.no_offscreen(c)
382        end
383    end
384end)
385
386client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
387client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
388-- }}}
389
390-- Keyboard map indicator and changer
391--kbdcfg = {}
392--kbdcfg.cmd = "setxkbmap"
393--kbdcfg.layout = { "es", "en", "fr" }
394--kbdcfg.current = 1  -- us is our default layout
395--kbdcfg.widget = widget({ type = "textbox", align = "right" })
396--kbdcfg.widget.text = " " .. kbdcfg.layout[kbdcfg.current] .. " "
397--kbdcfg.switch = function ()
398--   kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
399--   local t = " " .. kbdcfg.layout[kbdcfg.current] .. " "
400--   kbdcfg.widget.text = t
401--   os.execute( kbdcfg.cmd .. t )
402--end
403
404os.execute("shopt -s expand_aliases")
405os.execute("setxkbmap es")
406-- Avoid shuddown
407os.execute("cp /etc/skel/.bashrc /root/.bashrc")
408os.execute("echo \"alias shutdown='echo Bad luck, guy!'\" >> /root/.bashrc")
409os.execute("echo \"alias halt='echo Bad luck, guy!'\" >> /root/.bashrc")
410os.execute("echo \"alias init='echo Bad luck, guy!'\" >> /root/.bashrc")
411os.execute("echo \"alias telinit='echo Bad luck, guy!'\" >> /root/.bashrc")
412os.execute("echo \"alias zic='echo Bad luck, guy!'\" >> /root/.bashrc")
413
Note: See TracBrowser for help on using the repository browser.