sub on_osc_seq { my ($self, $seq, $value) = @_; # only handle icon setting return unless $seq == 1; # find a suitable full path my $icon = find_icon_path $self, $value; # command to set the icon my @cmd = ( 'set-icon.py', $icon, # full path to icon sprintf "0x%x", $self->{term}->parent # window ID ); # set up PATH, mainly %ENV = %{$self->env}; # system's return code is the opposite of what we want !system { $cmd[0] } @cmd; } sub find_icon_path { # do something to determine a nice icon filename my ($self, $search) = @_; # return the value if it looks like it might be a full path return $search if $search =~ m{/}; # try an icon dir my $fn = "/usr/share/icons/gnome/32x32/apps/$search.png"; return $fn if -e $fn; # fallback to a fixed default "/usr/share/icons/gnome/32x32/apps/gnome-terminal.png"; } # vim:set ft=perl: