i3: prefer j4-dmenu-desktop if available

Mon, 02 Jun 2014 17:31:29 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 02 Jun 2014 17:31:29 -0400
changeset 22
96aa7ad42dfe
parent 21
aa620cdf1022
child 23
a61d6f99a162
child 26
0d463cf25e9d

i3: prefer j4-dmenu-desktop if available

.i3/config file | annotate | diff | comparison | revisions
.i3/i3-dmenu-desktop file | annotate | diff | comparison | revisions
--- a/.i3/config
+++ b/.i3/config
@@ -36,6 +36,7 @@ bindsym $mod+Shift+q kill
 # shipping a .desktop file. It is a wrapper around dmenu, so you need that
 # installed.
 bindsym $mod+d exec --no-startup-id ~/.i3/i3-dmenu-desktop
+# bindsym $mod+d exec --no-startup-id ~/.i3/j4-dmenu-desktop --dmenu="dmenu -i -b -p ] -nf \#CCC -nb \#555"
 
 # change focus
 bindsym $mod+j focus left
--- a/.i3/i3-dmenu-desktop
+++ b/.i3/i3-dmenu-desktop
@@ -7,15 +7,44 @@
 
 use strict;
 use warnings qw(FATAL utf8);
+use v5.10;
+
+my $dmenu_cmd;
+my @entry_types;
+
+BEGIN {
+    $dmenu_cmd = 'dmenu -b -i -p ] -nf \#CCC -nb \#555';
+
+    use Getopt::Long;
+    my $result = GetOptions(
+        'dmenu=s' => \$dmenu_cmd,
+        'entry-type=s' => \@entry_types,
+        'version' => sub {
+            say "dmenu-desktop 1.5~custom~mhoward";
+            exit 0;
+        },
+        'help' => sub {
+            pod2usage(-exitval => 0);
+        });
+
+    die "Could not parse command line options" unless $result;
+
+    # if j4-dmenu-desktop is available, let it take over asap
+    #    https://github.com/enkore/j4-dmenu-desktop
+    if ( -x $ENV{HOME} . '/.i3/j4-dmenu-desktop' ){
+        exec $ENV{HOME} . "/.i3/j4-dmenu-desktop --dmenu='${dmenu_cmd}'";
+    }
+    
+    #otherwise we do the same thing as stock i3-dmenu-desktop, but cache the result
+}
+
 use Data::Dumper;
 use IPC::Open2;
 use POSIX qw(locale_h);
 use File::Find;
 use File::Basename qw(basename);
 use File::Temp qw(tempfile);
-use Getopt::Long;
 use Pod::Usage;
-use v5.10;
 use utf8;
 use open ':encoding(UTF-8)';
 
@@ -41,21 +70,6 @@ sub slurp {
     }
 }
 
-my @entry_types;
-my $dmenu_cmd = 'dmenu -b -i -p ] -nf \#CCC -nb \#555';
-my $result = GetOptions(
-    'dmenu=s' => \$dmenu_cmd,
-    'entry-type=s' => \@entry_types,
-    'version' => sub {
-        say "dmenu-desktop 1.5 © 2012-2013 Michael Stapelberg";
-        exit 0;
-    },
-    'help' => sub {
-        pod2usage(-exitval => 0);
-    });
-
-die "Could not parse command line options" unless $result;
-
 my ( %apps, %choices );
 my $cachefile = $ENV{HOME} . '/.cache/i3-dmenu-desktop.bin';
 

mercurial