App-wmiirc
view release on metacpan or search on metacpan
lib/App/wmiirc/Backlight.pm view on Meta::CPAN
{
$App::wmiirc::Backlight::VERSION = '1.000';
}
use App::wmiirc::Plugin;
with 'App::wmiirc::Role::Key';
# So on my vaio the down works here, but up doesn't(?!), I've hacked it into the
# acpi stuff instead -- urgh. Serves me right for buying proprietary Sony stuff
# I guess.
sub key_backlight_down(XF86MonBrightnessDown) {
system qw(xbacklight -steps 1 -time 0 -dec 10);
}
sub key_backlight_up(XF86MonBrightnessUp) {
system qw(xbacklight -steps 1 -time 0 -inc 10);
}
1;
__END__
=pod
=head1 NAME
lib/App/wmiirc/Client.pm view on Meta::CPAN
sub event_client_focus {
my($self, $id) = @_;
my $previous_id = $self->previous_id;
if($self->previous_id && (my $props = wmiir "/client/$previous_id/props")) {
@{$self->clients->{$previous_id}}[0..2] = split /:/, $props, 3;
}
$self->previous_id($id);
}
sub key_list_clients(Modkey-slash) {
my($self) = @_;
my @clients = map $self->clients->{$_}[2] . " ($_)",
grep defined $self->clients->{$_}[2], keys $self->clients;
# TODO: Stop showing the ID to the user somehow? Modify -S?
if(my $win = wimenu @clients) {
my($c) = $win =~ /\((0x[0-9a-f]+)\)$/;
if($c) {
my($tags) = wmiir "/client/$c/tags";
if($tags) {
lib/App/wmiirc/Client.pm view on Meta::CPAN
sub event_destroy_client {
my($self, $id) = @_;
$self->previous_id(undef) if $self->previous_id && $self->previous_id eq $id;
delete $self->clients->{$id};
}
# TODO: Fix SIGCHLD handling -- think about using IO::Async properly
# TODO: Maybe also a util function for running commands as it's done everywhere
sub key_terminal_here(Modkey-Control-Return) {
my($self) = @_;
my($cur_id) = wmiir "/client/sel/ctl";
my $pid = $self->clients->{$cur_id // ""}[3] || $$;
my $fork = fork;
return if $fork || not defined $fork;
if(-d "/proc/$pid/cwd") {
chdir "/proc/$pid/cwd";
} else {
# No /proc, try lsof
lib/App/wmiirc/Dwim.pm view on Meta::CPAN
for my $alias(keys %aliases) {
my $target = $aliases{$alias};
_getglob("action_$alias") = sub {
my($self, @args) = @_;
$self->action_default(sprintf $target, uri_escape_utf8 "@args");
};
}
sub action_xsel(Modkey-o) {
my($self, @args) = @_;
open my $fh, "-|", "xsel", "-o";
my $selection = join "", <$fh>;
$self->action_default($selection, @args);
}
sub action_default {
my($self, $action, @args) = @_;
if($action =~ m{^[/~]}) {
lib/App/wmiirc/Key.pm view on Meta::CPAN
}
sub event_key {
my($self, $key) = @_;
if(exists $self->core->{keys}{$key}) {
$self->core->{keys}{$key}->();
}
}
sub key_select(Modkey-DIR) {
my(undef, $dir) = @_;
wmiir "/tag/sel/ctl", "select $dir";
}
sub key_select_move(Modkey-Shift-DIR) {
my(undef, $dir) = @_;
wmiir "/tag/sel/ctl", "send sel $dir";
}
sub key_floating(Modkey-space) {
wmiir "/tag/sel/ctl", "select toggle";
}
sub key_floating_toggle(Modkey-Shift-space) {
wmiir "/tag/sel/ctl", "send sel toggle";
}
sub key_colmode_default(Modkey-d) {
wmiir "/tag/sel/ctl", "colmode sel default-max";
}
sub key_colmode_stack(Modkey-s) {
wmiir "/tag/sel/ctl", "colmode sel stack-max";
}
sub key_colmode_max(Modkey-m) {
wmiir "/tag/sel/ctl", "colmode sel stack+max";
}
sub key_fullscreen(Modkey-f) {
wmiir "/client/sel/ctl", "fullscreen toggle";
}
sub key_terminal(Modkey-Return) {
my($self) = @_;
system "wmiir setsid " . $self->core->main_config->{terminal} . "&";
}
sub key_close(Modkey-Shift-c) {
my($self) = @_;
wmiir "/client/sel/ctl", "kill";
}
sub key_action(Modkey-a) {
my($self) = @_;
my($action, @args) = split / /,
wimenu { name => "action:", history => "actions" },
sort grep !/^default$/, keys $self->core->{actions};
if($action) {
if(exists $self->core->{actions}{$action}) {
$self->core->{actions}{$action}->(@args);
} elsif(exists $self->core->{actions}{default}) {
$self->core->{actions}{default}->($action, @args);
}
}
}
my @progs;
sub key_run(Modkey-p) {
my($self) = @_;
if(!@progs) {
$self->action_rehash(sub { $self->key_run });
return;
}
if(my $run = wimenu { name => "run:", history => "progs" }, \@progs) {
system "$run &";
}
}
lib/App/wmiirc/Lock.pm view on Meta::CPAN
{
$App::wmiirc::Lock::VERSION = '1.000';
}
use App::wmiirc::Plugin;
with 'App::wmiirc::Role::Action';
sub action_lock {
system config("commands", "lock", "xscreensaver-command -lock");
}
sub action_sleep(XF86PowerOff) {
system config("commands", "sleep", "sudo pm-suspend");
}
sub action_hibernate {
system config("commands", "hibernate", "sudo pm-hibernate");
}
# TODO: Less hacky / more supported way? Probably involves dbus.
# On arch I currently have the following in /etc/acpi/actions/lm_lid.sh:
# DISPLAY=:0 sudo -u dgl ~dgl/bin/wmiir xwrite /event Lid $3
lib/App/wmiirc/Tag.pm view on Meta::CPAN
my($cur) = wmiir "/tag/sel/ctl";
wmiir "/lbar/$tag", $cur eq $tag ? $color{focus} : $color{norm};
}
sub event_left_bar_click {
my($self, $button, $tag) = @_;
wmiir "/ctl", "view $tag";
}
*event_left_bar_dnd = \&event_left_bar_click;
sub key_tag_back(Modkey-comma) {
my($self) = @_;
$self->key_tag_next(-1);
}
sub key_tag_next(Modkey-period) {
my($self, $dir) = @_;
my @tags = sort map s{/$}{}r, grep !/sel/, wmiir "/tag/";
@tags = reverse @tags if defined $dir && $dir == -1;
my($cur) = wmiir "/tag/sel/ctl";
my $l = "";
for my $tag(@tags) {
wmiir "/ctl", "view $tag" if $l eq $cur;
$l = $tag;
}
# Wrap around
wmiir "/ctl", "view $tags[0]" if $l eq $cur;
}
sub key_tag_num(Modkey-#) {
my(undef, $num) = @_;
my $tag = $num >= 1 ? $num - 1 : 9;
my @tags = sort map s{/$}{}r, grep !/sel/, wmiir "/tag/";
wmiir "/ctl", "view $tags[$tag]" if $tags[$tag];
}
sub key_retag_num(Modkey-Shift-#) {
my(undef, $tag) = @_;
wmiir "/client/sel/tags", $tag;
}
sub _tagmenu {
my @tags = sort map s{/$}{}r, grep !/sel/, wmiir "/tag/";
wimenu { name => "tag:", history => "tags" }, @tags;
}
sub key_tag_menu(Modkey-t) {
my($self) = @_;
my $tag = _tagmenu();
wmiir "/ctl", "view $tag" if length $tag;
}
sub key_retag_menu(Modkey-Shift-t) {
my($self) = @_;
my $tag = _tagmenu();
wmiir "/client/sel/tags", $tag if length $tag;
}
sub key_retag_go_menu(Modkey-Shift-r) {
my($self) = @_;
my $tag = _tagmenu();
if(length $tag) {
wmiir "/client/sel/tags", $tag;
wmiir "/ctl", "view $tag";
}
}
sub key_tag_swap(Modkey-Tab) {
my($self) = @_;
wmiir "/ctl", "view " . $self->last_tag if $self->last_tag;
}
1;
__END__
=pod
=head1 NAME
lib/App/wmiirc/Volume.pm view on Meta::CPAN
when(4) {
$self->set($self->volume + 2 . "%");
}
when(5) {
$self->set($self->volume - 2 . "%");
}
}
}
}
sub key_volume_down(XF86AudioLowerVolume) {
my($self) = @_;
$self->set("unmute") if $self->volume eq 'off';
$self->set($self->volume - 6 . "%");
}
sub key_volume_up(XF86AudioRaiseVolume) {
my($self) = @_;
$self->set("unmute") if $self->volume eq 'off';
$self->set($self->volume + 6 . "%");
}
sub key_volume_mute(XF86AudioMute) {
my($self) = @_;
$self->set($self->volume eq 'off' ? "unmute" : "mute");
}
sub set {
my($self, $level) = @_;
system "amixer", "set", "$self->{device},0", $level;
$self->render;
}
( run in 0.931 second using v1.01-cache-2.11-cpan-65fba6d93b7 )