Leser: 1
7 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#!/usr/bin/perl use strict; use warnings; use X11::Protocol; # Nummer des Desktops auf den man wechseln will my $desktop_nr=shift(@ARGV) || 0; # ein Paar Konstante my @const = ('AnyPropertyType', 0, -1, 0); my $x = X11::Protocol->new(); my $root=$x->root; # Anzahl der verfügbaren Desktops my $desktops=unpack('L',($x->GetProperty($root, $x->atom('_NET_NUMBER_OF_DESKTOPS'), @const))[0]); # Namen der Desktops my @desktop_names=split("\000",($x->GetProperty($root, $x->atom('_NET_DESKTOP_NAMES'), @const))[0]); # Nummer des gerade Aktiven Desktops my $desktop_now=unpack('L',($x->GetProperty($root, $x->atom('_NET_CURRENT_DESKTOP'), @const))[0]); print "Desktops: ".$desktops."\n"; print "Names: ".join(' | ',@desktop_names)."\n"; print "Active: ".$desktop_now."\n"; $desktop_nr-=$desktops while($desktop_nr>=$desktops); $desktop_nr+=$desktops while($desktop_nr<0); # Desktop wechseln # Ziehmlich schlecht Dokumentiert das ganze. # habe einen Tag gebraucht um die nötigen Informationen zusammen zu suchen... $x->SendEvent( $root, 0, $x->pack_event_mask('SubstructureNotify', 'SubstructureRedirect'), $x->pack_event( name=>'ClientMessage', format=>32, window=>$root, type=>$x->atom('_NET_CURRENT_DESKTOP'), data=>pack('LLxxxxxxxxxxxx',$desktop_nr,time()) ) );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use strict;
use Tk;
use Tk::Xlib;
my $desktop_nr = shift; !defined $desktop_nr and die;
my $mw = new MainWindow;
$mw->withdraw;
sub _root_property {
my($prop) = @_;
my(undef, @vals) = eval {
$mw->property("get", "_NET_" . uc($prop), "root");
};
warn $@ if $@;
@vals;
}
for my $prop (qw(number_of_desktops current_desktop)) {
no strict 'refs';
*{$prop} = sub {
my($val) = _root_property($prop);
$val;
};
}
sub desktop_names {
my($names) = eval {
$mw->property("get", "_NET_DESKTOP_NAMES", "root");
};
warn $@ if $@;
split /\0/, $names;
}
print "Desktops: " . number_of_desktops() . "\n";
print "Names: " . join(" | ", desktop_names()) . "\n";
print "Active: " . current_desktop() . "\n";
my $root = $mw->Display->RootWindow;
# Hier scheitert es:
$mw->SendClientMessage('_NET_CURRENT_DESKTOP', $$root, 32, pack('LLxxxxxxxxxxxx',$desktop_nr,time()));
print "Active now: " . current_desktop() . "\n";
__END__
$x->flush();
7 Einträge, 1 Seite |