Class: Awesomer
- Inherits:
-
Object
- Object
- Awesomer
- Defined in:
- lib/awesomer.rb
Overview
Awesomer is a ruby library for interacting with the awesome
window manager. It replaces the awesome-client
distributed with the window manager.
It’s used by either creating a new Awesomer object, connecting, performing actions, and lastly close the connection:
a = Awesomer.new
a.connect
a.tag_view 2
sleep 1
a.tag_view 3
a.close
A better way to handle this is to contact the window manager using a block. Connecting and closing are then handled automatically:
Awesomer.contact do |a|
a.tag_view 4
a.spawn :urxvt
sleep 3
a.tag_view 5
a.spawn :urxvt
end
Constant Summary collapse
- VERSION =
'1.1.0'
Instance Attribute Summary collapse
-
#screen ⇒ Object
Returns the value of attribute screen.
-
#socket ⇒ Object
Returns the value of attribute socket.
-
#statusbar ⇒ Object
Returns the value of attribute statusbar.
Class Method Summary collapse
-
.contact(screen = 0) {|awesome| ... } ⇒ Object
Contact the awesome window manager using a block.
Instance Method Summary collapse
-
#close ⇒ Object
Close connection to the awesome window manager socket.
-
#connect ⇒ Object
Connect to the awesome window manager socket.
-
#initialize(screen = 0) ⇒ Awesomer
constructor
A new instance of Awesomer.
-
#method_missing(method, *args) ⇒ Object
We take all method calls as possible UICB functions.
Constructor Details
#initialize(screen = 0) ⇒ Awesomer
Returns a new instance of Awesomer.
35 36 37 |
# File 'lib/awesomer.rb', line 35 def initialize(screen = 0) @screen = screen end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
We take all method calls as possible UICB functions.
48 49 50 51 52 53 54 |
# File 'lib/awesomer.rb', line 48 def method_missing(method, *args) if method == :widget_tell && send(method, args.unshift(@statusbar).join(' ')) else send(method, args.join(' ')) end end |
Instance Attribute Details
#screen ⇒ Object
Returns the value of attribute screen.
31 32 33 |
# File 'lib/awesomer.rb', line 31 def screen @screen end |
#socket ⇒ Object
Returns the value of attribute socket.
33 34 35 |
# File 'lib/awesomer.rb', line 33 def socket @socket end |
#statusbar ⇒ Object
Returns the value of attribute statusbar.
32 33 34 |
# File 'lib/awesomer.rb', line 32 def @statusbar end |
Class Method Details
Instance Method Details
#close ⇒ Object
Close connection to the awesome window manager socket.
69 70 71 |
# File 'lib/awesomer.rb', line 69 def close @socket.close end |
#connect ⇒ Object
Connect to the awesome window manager socket.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/awesomer.rb', line 57 def connect @socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0) path = File.join(ENV['HOME'], ".awesome_ctl.#@screen") if File.exists? path @socket.connect(Socket.pack_sockaddr_un(path)) else sleep 1 connect end end |