diff mbox

gnu: Add rofi.

Message ID 20160520062952.314ba37f@scratchpost.org
State New
Headers show

Commit Message

Danny Milosavljevic May 20, 2016, 4:29 a.m. UTC
From: Danny Milosavljevic <dannym@scratchpost.org>

* gnu/packages/xdisorg.scm (rofi): New variable.
---
 gnu/packages/xdisorg.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Leo Famulari May 23, 2016, 4:28 a.m. UTC | #1
On Fri, May 20, 2016 at 06:29:52AM +0200, Danny Milosavljevic wrote:
> * gnu/packages/xdisorg.scm (rofi): New variable.

Thanks for the patch! I'd never heard of this program but as someone who
uses dmenu a lot, I'd like to try it out.

> +(define-public rofi

> +              (uri (string-append "https://github.com/DaveDavenport/rofi/releases/download/" version "/rofi-" version ".tar.xz"))

Lines should be shorter than 80 characters whenever possible. `guix lint
rofi` should warn about this :)

> +    (arguments
> +     `(#:tests? #f))

The failing test (helper_expand) seems to fail when it can't find
`which`. There are examples of how to patch scripts with the path to our
`which` in gnu/packages. Can you try it out?

> +    (synopsis "Application Launcher")
> +    (description "Rofi is a minimalist Application Launcher.  It memorizes which applications you regularily use and also allows you to search for an application by name.")

I think that "Launcher" should not start with a capital letter.
Danny Milosavljevic May 24, 2016, 6:55 a.m. UTC | #2
On Mon, 23 May 2016 00:28:26 -0400
Leo Famulari <leo@famulari.name> wrote:

> The failing test (helper_expand) seems to fail when it can't find
> `which`. 

The failing test is test/helper-expand.c and it tries to do this:

int main ( int argc, char ** argv )
{
    cmd_set_arguments ( argc, argv );

    if ( setlocale ( LC_ALL, "" ) == NULL ) {
        fprintf ( stderr, "Failed to set locale.\n" );
        return EXIT_FAILURE;
    }

    /**
     * Test some path functions. Not easy as not sure what is right output on travis.
     */
    // Test if root is preserved.
    char *str = rofi_expand_path ( "/" );
    TASSERT ( strcmp ( str, "/" ) == 0 );
    g_free ( str );
    // Test is relative path is preserved.
    str = rofi_expand_path ( "../AUTHORS" );
    TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
    g_free ( str );
    // Test another one.
    str = rofi_expand_path ( "/bin/false" );
    TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
    g_free ( str );
    // See if user paths get expanded in full path.
    str = rofi_expand_path ( "~/" ); <----- oh oh
    const char *hd = g_get_home_dir ();
    TASSERT ( strcmp ( str, hd ) == 0 );
    g_free ( str );
    str = rofi_expand_path ( "~root/" );   <--- oh oh
    TASSERT ( str[0] == '/' );
    g_free ( str );
}

And rofi_expand_path does

char *rofi_expand_path ( const char *input )
{
    char **str = g_strsplit ( input, G_DIR_SEPARATOR_S, -1 );
    for ( unsigned int i = 0; str && str[i]; i++ ) {
        // Replace ~ with current user homedir.
        if ( str[i][0] == '~' && str[i][1] == '\0' ) {
            g_free ( str[i] );
            str[i] = g_strdup ( g_get_home_dir () ); <----------- oh oh
        }
        // If other user, ask getpwnam.
        else if ( str[i][0] == '~' ) {
            struct passwd *p = getpwnam ( &( str[i][1] ) ); <---------- oh oh
            if ( p != NULL ) {
                g_free ( str[i] );
                str[i] = g_strdup ( p->pw_dir );
            }
        }
        else if ( i == 0 ) {
            char * s = str[i];
            if ( input[0] == G_DIR_SEPARATOR ) {
                str[i] = g_strdup_printf ( "%s%s", G_DIR_SEPARATOR_S, s );
                g_free ( s );
            }
        }
    }
    char *retv = g_build_filenamev ( str );
    g_strfreev ( str );
    return retv;
}

What should we do about it?

The "which" part is just rofi trying to find out whether it has been checked out from git or expanded from a release tarball.
Leo Famulari May 25, 2016, 3:38 a.m. UTC | #3
On Tue, May 24, 2016 at 08:55:02AM +0200, Danny Milosavljevic wrote:
> On Mon, 23 May 2016 00:28:26 -0400
> Leo Famulari <leo@famulari.name> wrote:
> 
> > The failing test (helper_expand) seems to fail when it can't find
> > `which`. 
> 
> The failing test is test/helper-expand.c and it tries to do this:
>
>     str = rofi_expand_path ( "~/" ); <----- oh oh
[...]
>     str = rofi_expand_path ( "~root/" );   <--- oh oh
[...]
>             str[i] = g_strdup ( g_get_home_dir () ); <----------- oh oh
[...]
>             struct passwd *p = getpwnam ( &( str[i][1] ) ); <---------- oh oh

> What should we do about it?

How about disabling that test only? You can comment it out of wherever
it's invoked, or make it return true immediately. I'm not sure if we
have a canonical method... I think it depends on the language and
implementation.
diff mbox

Patch

diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm
index ca198c3..9f708e5 100644
--- a/gnu/packages/xdisorg.scm
+++ b/gnu/packages/xdisorg.scm
@@ -907,3 +907,35 @@  demos.  It also acts as a nice screen locker.")
               (string-append
                "http://metadata.ftp-master.debian.org/changelogs/"
                "/main/x/xscreensaver/xscreensaver_5.34-2_copyright")))))
+
+(define-public rofi
+  (package
+    (name "rofi")
+    (version "1.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/DaveDavenport/rofi/releases/download/" version "/rofi-" version ".tar.xz"))
+              (sha256
+               (base32
+                "01jxml9vk4cw7pngpan7dipmb98s6ibh6f0023lw3hbgxy650637"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f))
+    (home-page "https://davedavenport.github.io/rofi/")
+    (synopsis "Application Launcher")
+    (description "Rofi is a minimalist Application Launcher.  It memorizes which applications you regularily use and also allows you to search for an application by name.")
+    (inputs
+     `(("libx11" ,libx11)
+       ("libxinerama" ,libxinerama)
+       ("libxft" ,libxft)
+       ("pango" ,pango)
+       ("cairo" ,cairo)
+       ("glib" ,glib)
+       ("startup-notification" ,startup-notification)
+       ("libxkbcommon" ,libxkbcommon)
+       ("libxcb" ,libxcb)
+       ("xcb-util" ,xcb-util)
+       ("xcb-util-wm" ,xcb-util-wm)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (license license:expat)))