-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtransparent.pl
executable file
·59 lines (39 loc) · 1.12 KB
/
transparent.pl
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env perl
=head1 NAME
transparent.pl - Load a page with a transparent background
=head1 SYNOPSIS
transparent.pl file://$PWD/sample.html
=head1 DESCRIPTION
Loads an URI and displays the page in a transparent window. The page must use
the following CSS rule:
body {
background-color: rgba(0,0,0,0);
}
=cut
use strict;
use warnings;
use Glib ':constants';
use Gtk3 -init;
use Gtk3::WebKit;
use Data::Dumper;
sub main {
my ($url) = @ARGV;
$url ||= 'http://localhost:3001/';
my $window = Gtk3::Window->new('toplevel');
# Set the main window transparent
my $screen = $window->get_screen;
$window->set_visual($screen->get_rgba_visual || $screen->get_system_visual);
$window->set_default_size(800, 600);
$window->signal_connect(destroy => sub { Gtk3->main_quit() });
$window->set_decorated(FALSE);
my $view = Gtk3::WebKit::WebView->new();
$view->set_transparent(TRUE);
# Pack the widgets together
$window->add($view);
$window->show_all();
$view->load_uri($url);
$view->grab_focus();
Gtk3->main();
return 0;
}
exit main() unless caller;