summaryrefslogtreecommitdiffstats
path: root/dmenuclip
blob: cb6abd1499277f42942340fac86026f582dbd3e3 (plain)
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
#!/usr/bin/perl
# dmenuclip - Really nasty dmenu launcher to be used in combination with
# clipbored
use strict;

my $xsels     = "$ENV{XDG_DATA_HOME}/clipbored/clips";

my $font      = (exists $ENV{CLIPBORED_DMENU_FONT})
  ? $ENV{CLIPBORED_DMENU_FONT}
  : '-*-fixed-*-*-*-*-15-*-*-*-*-*-*-*';
my $normal_bg = (exists $ENV{CLIPBORED_DMENU_NORMAL_BG})
  ? $ENV{CLIPBORED_DMENU_NORMAL_BG}
  :  "#1c1c1c";
my $normal_fg = (exists $ENV{CLIPBORED_DMENU_NORMAL_FG})
  ? $ENV{CLIPBORED_DMENU_NORMAL_FG}
  : "#ffffff";
my $select_bg = (exists $ENV{CLIPBORED_DMENU_SELECT_BG})
  ? $ENV{CLIPBORED_DMENU_SELECT_BG}
  : "#484848";
my $select_fg = (exists $ENV{CLIPBORED_DMENU_SELECT_FG})
  ? $ENV{CLIPBORED_DMENU_SELECT_FG}
  :  "#ffffff";

my $list_mode = (exists $ENV{CLIPBORED_DMENU_LISTMODE})
  ? dmenu_mode($ENV{CLIPBORED_DMENU_LISTMODE})
  : dmenu_mode('vertical');

# If defined, we want vertical mode
if(exists($ENV{CLIPBORED_DMENU_LINES})) {
  $list_mode = "-l $ENV{CLIPBORED_DMENU_LINES}";
}

sub dmenu_mode {
  my $what = shift;

  if($what eq 'vertical') {
    return("-l 15");
  }
  else {
    return("");
  }
}

$normal_bg =~ s/^(#)/\\$1/;
$normal_fg =~ s/^(#)/\\$1/;
$select_bg =~ s/^(#)/\\$1/;
$select_fg =~ s/^(#)/\\$1/;

my $dmenu =  "dmenu -i -b $list_mode "
  . "-nb $normal_bg -nf $normal_fg -sb $select_bg -sf $select_fg";

system("printf \"\$(\\tac $xsels|$dmenu  -fn $font -p dmenuclip)\"|xclip -i -l 0|xclip -o");