Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/mit/ctwm ctwmrc: Split the automatically generated ...



details:   https://anonhg.NetBSD.org/src/rev/fe34166d880b
branches:  trunk
changeset: 366013:fe34166d880b
user:      nia <nia%NetBSD.org@localhost>
date:      Mon May 09 15:05:18 2022 +0000

description:
ctwmrc: Split the automatically generated pkgsrc applications menu
into categories similarly to MATE and Xfce.

diffstat:

 external/mit/ctwm/etc/system.ctwmrc     |   25 ++++-
 external/mit/ctwm/libexec/ctwm_app_menu |  143 +++++++++++++++++++++++--------
 2 files changed, 122 insertions(+), 46 deletions(-)

diffs (231 lines):

diff -r 888cea95e913 -r fe34166d880b external/mit/ctwm/etc/system.ctwmrc
--- a/external/mit/ctwm/etc/system.ctwmrc       Mon May 09 13:27:24 2022 +0000
+++ b/external/mit/ctwm/etc/system.ctwmrc       Mon May 09 15:05:18 2022 +0000
@@ -1,5 +1,5 @@
 #
-# $NetBSD: system.ctwmrc,v 1.16 2022/05/09 07:15:25 nia Exp $
+# $NetBSD: system.ctwmrc,v 1.17 2022/05/09 15:05:18 nia Exp $
 #
 # ctwmrc by nia
 #
@@ -260,16 +260,32 @@
     MapWindowBackground        "white"
 }
 
+syscmd(/usr/X11R7/libexec/ctwm_app_menu)
+
+menu "appmenu"
+{
+    "pkgsrc Applications"      f.title
+    " Accessories"             f.menu "Accessories"
+    " Games"                   f.menu "Games"
+    " Graphics"                        f.menu "Graphics"
+    " Internet"                        f.menu "Internet"
+    " Multimedia"              f.menu "Multimedia"
+    " Office"                  f.menu "Office"
+    " Programming"             f.menu "Programming"
+    " System"                  f.menu "System"
+    " Misc"                    f.menu "Misc"
+}
+
 menu "deskutils"
 {
     "Desktop utilities"                f.title
     " Calculator"              !"xcalc &"
-    " Clipboard"               !"xclipboard &"
     " Text editor"             !"xedit &"
+    " Manual pages"            !"LC_ALL=en_US.ISO8859-1 xman -notopbox &"
     ""                         f.separator
     " XEyes"                   !"xeyes &"
     " OpenGL Gears"            !"glxgears &"
-    " Icosahedron"             !"ico -sleep 0.016 &"
+    " Spinning cube"           !"ico -sleep 0.016 -obj cube -colors darkorange &"
     ""                         f.separator
     " Compositor (shadows)"    !"pkill xcompmgr; xcompmgr -c &"
     " Compositor (simple)"     !"pkill xcompmgr; xcompmgr -n &"
@@ -299,7 +315,6 @@
     "NetBSD"                   f.title
     ""                         f.separator
     " Terminal"                        !"uxterm &"
-    " Manual pages"            !"LC_ALL=en_US.ISO8859-1 xman -notopbox &"
     ""                         f.separator
     " Applications"            f.menu "appmenu"
     " Desktop utilities"       f.menu "deskutils"
@@ -309,8 +324,6 @@
     " Quit"                    f.quit
 }
 
-syscmd(/usr/X11R7/libexec/ctwm_app_menu)
-
 menu "titleops"
 {
     "Window"       f.title
diff -r 888cea95e913 -r fe34166d880b external/mit/ctwm/libexec/ctwm_app_menu
--- a/external/mit/ctwm/libexec/ctwm_app_menu   Mon May 09 13:27:24 2022 +0000
+++ b/external/mit/ctwm/libexec/ctwm_app_menu   Mon May 09 15:05:18 2022 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh
-#      $NetBSD: ctwm_app_menu,v 1.3 2021/03/01 15:40:40 nia Exp $
+#      $NetBSD: ctwm_app_menu,v 1.4 2022/05/09 15:05:18 nia Exp $
 #
-# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# Copyright (c) 2020-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
 # This code is derived from software contributed to The NetBSD Foundation
@@ -29,54 +29,117 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 LOCALBASE=$(pkg_info -Q LOCALBASE pkg_install 2>/dev/null || echo /usr/pkg)
+DESKTOPFILES=$(find $LOCALBASE/share/applications -name '*.desktop')
 OFS=$IFS
 IFS='
 '
-printf 'menu "appmenu"\n'
-printf '{\n'
-printf '\t"Applications"\tf.title\n'
-for app in $(find $LOCALBASE/share/applications -name '*.desktop');
-do
-       name=""
-       exec=""
-       terminal=""
-       nodisplay=""
-       while read line;
+do_category()
+{
+       printf 'menu "%s"\n' "$1"
+       printf '{\n'
+       printf '\t"%s"\tf.title\n' "$1"
+       for app in $DESKTOPFILES;
        do
-               case $line in
-                       Name=*)
-                               if ! [ -n "$name" ];
-                               then
-                                       name=$(printf '%s' "$line" | cut -c6- | tr -d '\r')
+               name=""
+               exec=""
+               terminal=""
+               nodisplay=""
+               category=$(grep -m 1 '^Categories=' "$app")
+               case "$category" in
+                       *Audio*)
+                               if [ "$1" != "Multimedia" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *Development*)
+                               if [ "$1" != "Programming" ]; then
+                                       continue
                                fi
                        ;;
-                       Exec=*)
-                               if ! [ -n "$exec" ];
-                               then
-                                       exec=$(printf '%s' "$line" | cut -c6- | sed -e 's/ %.*//g' | tr -d '\r')
+                       *Graphics*)
+                               if [ "$1" != "Graphics" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *Game*)
+                               if [ "$1" != "Games" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *Office*)
+                               if [ "$1" != "Office" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *Network*)
+                               if [ "$1" != "Internet" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *System*)
+                               if [ "$1" != "System" ]; then
+                                       continue
+                               fi
+                       ;;
+                       *Utility*)
+                               if [ "$1" != "Accessories" ]; then
+                                       continue
                                fi
                        ;;
-                       Terminal=true)
-                               terminal="true"
-                       ;;
-                       OnlyShowIn=*|NoDisplay=true)
-                               nodisplay="true"
+                       *)
+                               if [ "$1" != "Misc" ]; then
+                                       continue
+                               fi
                        ;;
                esac
-       done < "$app"
-       if [ -n "$nodisplay" ];
-       then
-               continue
-       fi
-       if [ -n "$name" -a -n "$exec" ];
-       then
-               if [ -n "$terminal" ];
+               while read line;
+               do
+                       case $line in
+                               Name=*)
+                                       if ! [ -n "$name" ];
+                                       then
+                                               name=$(printf '%s' "$line" | cut -c6- | tr -d '\r')
+                                       fi
+                               ;;
+                               Exec=*)
+                                       if ! [ -n "$exec" ];
+                                       then
+                                               exec=$(printf '%s' "$line" | cut -c6- | sed -e 's/ %.*//g' | tr -d '\r')
+                                       fi
+                               ;;
+                               Terminal=true)
+                                       terminal="true"
+                               ;;
+                               OnlyShowIn=*|NoDisplay=true)
+                                       nodisplay="true"
+                               ;;
+                       esac
+               done < "$app"
+               if [ -n "$nodisplay" ];
                then
-                       printf '\t" %s" !"uxterm %s &" \n' "$name" "$exec"
-               else
-                       printf '\t" %s" !"%s &" \n' "$name" "$exec"
+                       continue
+               fi
+               if [ -n "$name" -a -n "$exec" ];
+               then
+                       if [ -n "$terminal" ];
+                       then
+                               printf '\t" %s" !"xterm -class UXTerm -e %s &" \n' "$name" "$exec"
+                       else
+                               printf '\t" %s" !"%s &" \n' "$name" "$exec"
+                       fi
                fi
-       fi
-done | sort
-printf '}\n'
+       done | sort
+       printf '}\n'
+}
+
+do_category Accessories
+do_category Games
+do_category Graphics
+do_category Internet
+do_category Multimedia
+do_category Office
+do_category Programming
+do_category System
+do_category Misc
+
 IFS=$OIFS



Home | Main Index | Thread Index | Old Index