Compare commits
3 commits
main
...
install-na
Author | SHA1 | Date | |
---|---|---|---|
a192c31de1 | |||
|
2a1f31a88b | ||
|
5749750507 |
7 changed files with 142 additions and 247 deletions
9
LICENSE
9
LICENSE
|
@ -1,9 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024 DeltaLima
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,3 +1,7 @@
|
|||
# !! THIS BRANCH IS JUST EXPERIMENTAL !!
|
||||
# !! IT INSTALLS NANODESK TO YOUR ACTUAL MACHINE AS ADDITIONAL DESKTOP SEESION !!
|
||||
# !! FILES GET OVERWRITTEN !!
|
||||
|
||||
# nanodesk - lightweight linux (live) desktop
|
||||
|
||||
Origin: https://git.la10cy.net/DeltaLima/nanodesk
|
||||
|
@ -201,4 +205,3 @@ Download: [http://pub.la10cy.net/nanodesk/](http://pub.la10cy.net/nanodesk/)
|
|||
- xdgmenumaker deb package: https://bgstack15.wordpress.com/2020/03/03/package-for-devuan-xdgmenumaker/
|
||||
- How To debootstrap a small desktop system: https://git.la10cy.net/DeltaLima/devnull/src/branch/main/debootstrap_minimal_dekstop_from_scratch.md
|
||||
- How To create a linux live cd: https://www.willhaley.com/blog/custom-debian-live-environment/
|
||||
- Tux: https://archive.org/details/linuxmandrake7.2chipedition
|
||||
|
|
|
@ -33,10 +33,10 @@ error ()
|
|||
}
|
||||
|
||||
### hostname setting
|
||||
echo nanodesk > /etc/hostname
|
||||
#echo nanodesk > /etc/hostname
|
||||
|
||||
message "set hostname in hosts"
|
||||
sed -i 's/localhost/localhost nanodesk/g' /etc/hosts
|
||||
#message "set hostname in hosts"
|
||||
#sed -i 's/localhost/localhost nanodesk/g' /etc/hosts
|
||||
|
||||
### noninteractive
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
@ -74,7 +74,6 @@ apt install -y --no-install-recommends \
|
|||
zip \
|
||||
bzip2 \
|
||||
zstd \
|
||||
grub-pc \
|
||||
host \
|
||||
wireless-tools \
|
||||
unrar \
|
||||
|
@ -91,7 +90,6 @@ apt install -y --no-install-recommends \
|
|||
xdg-utils \
|
||||
xdg-user-dirs \
|
||||
xterm \
|
||||
xdm \
|
||||
jwm \
|
||||
mc \
|
||||
wget \
|
||||
|
@ -128,13 +126,10 @@ apt install -y --no-install-recommends \
|
|||
tango-icon-theme \
|
||||
squashfs-tools \
|
||||
synaptic \
|
||||
imagemagick \
|
||||
ifstat \
|
||||
/tmp/xdgmenumaker*.deb || error
|
||||
|
||||
message "install nanodesk base packages with recommends"
|
||||
apt install -y \
|
||||
grub-pc \
|
||||
network-manager \
|
||||
network-manager-gnome \
|
||||
net-tools \
|
||||
|
@ -154,14 +149,14 @@ apt install -y \
|
|||
#dpkg-reconfigure keyboard-configuration
|
||||
###https://serverfault.com/a/689947
|
||||
|
||||
message "set locales and tzdata"
|
||||
echo "Europe/Berlin" > /etc/timezone && \
|
||||
dpkg-reconfigure -f noninteractive tzdata && \
|
||||
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
|
||||
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
|
||||
dpkg-reconfigure --frontend=noninteractive locales && \
|
||||
locale-gen en_US.UTF-8 && \
|
||||
update-locale LANG=en_US.UTF-8
|
||||
#message "set locales and tzdata"
|
||||
#echo "Europe/Berlin" > /etc/timezone && \
|
||||
# dpkg-reconfigure -f noninteractive tzdata && \
|
||||
# sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
|
||||
# echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
|
||||
# dpkg-reconfigure --frontend=noninteractive locales && \
|
||||
# locale-gen en_US.UTF-8 && \
|
||||
# update-locale LANG=en_US.UTF-8
|
||||
|
||||
######
|
||||
####
|
||||
|
@ -183,8 +178,8 @@ message "run custom steps from /tmp/install_base.customsteps.sh"
|
|||
######
|
||||
|
||||
### clean cache
|
||||
message "apt clean"
|
||||
apt clean
|
||||
#message "apt clean"
|
||||
#apt clean
|
||||
|
||||
KERNEL_VER="$(ls -1 /boot/|grep "vmlinuz-"|sed 's/vmlinuz-//'|sort -g|head -n +1)"
|
||||
test -n "$KERNEL_VER" || error
|
||||
|
@ -192,11 +187,11 @@ message "KERNEL_VER=${YELLOW}${KERNEL_VER}${ENDCOLOR}"
|
|||
|
||||
### but fetch packages for grub and kernel, so we do not need to download them
|
||||
### in case nanodesk get installed to diska
|
||||
message "apt --download linux-image and grub packages to have them in cache for nanodesk-installer.sh offline installation"
|
||||
apt -d --reinstall install \
|
||||
linux-image-amd64 \
|
||||
linux-image-$KERNEL_VER \
|
||||
grub-pc grub-pc-bin \
|
||||
grub-common \
|
||||
grub2-common \
|
||||
os-prober || error
|
||||
#message "apt --download linux-image and grub packages to have them in cache for nanodesk-installer.sh offline installation"
|
||||
#apt -d --reinstall install \
|
||||
# linux-image-amd64 \
|
||||
# linux-image-$KERNEL_VER \
|
||||
# grub-pc grub-pc-bin \
|
||||
# grub-common \
|
||||
# grub2-common \
|
||||
# os-prober || error
|
||||
|
|
231
makeanything.sh
231
makeanything.sh
|
@ -52,22 +52,12 @@ error ()
|
|||
exit 1
|
||||
}
|
||||
|
||||
message "installing requirements"
|
||||
### https://www.willhaley.com/blog/custom-debian-live-environment/
|
||||
sudo apt install \
|
||||
debootstrap \
|
||||
squashfs-tools \
|
||||
xorriso \
|
||||
isolinux \
|
||||
syslinux-efi \
|
||||
grub-pc-bin \
|
||||
grub-efi-amd64-bin \
|
||||
grub-efi-ia32-bin \
|
||||
mtools \
|
||||
dosfstools \
|
||||
#message "installing requirements"
|
||||
#### https://www.willhaley.com/blog/custom-debian-live-environment/
|
||||
apt install \
|
||||
coreutils \
|
||||
pandoc || error
|
||||
|
||||
#
|
||||
|
||||
|
||||
message "start building nanodesk ${YELLOW}${VERSION}${ENDCOLOR}"
|
||||
|
@ -82,20 +72,20 @@ do
|
|||
message "$dir"
|
||||
test -d $dir || mkdir -p $dir
|
||||
done
|
||||
|
||||
message "running debootstrap $DEBOOTSTRAP_OPTS $DEBOOTSTRAP_SUITE $MIRROR"
|
||||
sudo debootstrap ${DEBOOTSTRAP_OPTS} ${DEBOOTSTRAP_SUITE} build/chroot/ $MIRROR || message warn "debootstrap exited with code $?"
|
||||
#
|
||||
#message "running debootstrap $DEBOOTSTRAP_OPTS $DEBOOTSTRAP_SUITE $MIRROR"
|
||||
#sudo debootstrap ${DEBOOTSTRAP_OPTS} ${DEBOOTSTRAP_SUITE} build/chroot/ $MIRROR || message warn "debootstrap exited with code $?"
|
||||
|
||||
message "copy xdgmenumaker deb file into chroot"
|
||||
sudo cp deb/xdgmenumaker* build/chroot/tmp || error
|
||||
cp deb/xdgmenumaker* /tmp || error
|
||||
|
||||
message "copy install_base scripts to build/chroot/tmp/"
|
||||
sudo cp install_base/* build/chroot/tmp/ || error
|
||||
cp install_base/* /tmp/ || error
|
||||
|
||||
|
||||
#### install_base
|
||||
message "run install_base.sh"
|
||||
$CHROOTCMD /bin/bash /tmp/install_base.sh || error
|
||||
/bin/bash /tmp/install_base.sh || error
|
||||
####
|
||||
|
||||
### copy nanodesk files in nanodesk-files/ to build/nanodesk-files/ so we can make changes there,
|
||||
|
@ -112,115 +102,124 @@ for md in $(find build/nanodesk-files/usr/share/doc/nanodesk/ -name "*.md")
|
|||
done
|
||||
|
||||
message "copy build/nanodesk-files/ to build/chroot/"
|
||||
sudo cp -r build/nanodesk-files/* build/chroot/
|
||||
cp -r build/nanodesk-files/* /
|
||||
|
||||
message "generate icon path list for jwm config"
|
||||
find /usr/share/icons/ -type d | sed 's/build\/chroot//g' > build/tmp/jwm.iconlist
|
||||
sed -i -e 's/^/\ \ \ \ <IconPath>/g' -e 's/$/<\/IconPath>/g' build/tmp/jwm.iconlist
|
||||
cp build/tmp/jwm.iconlist /tmp/ || error
|
||||
|
||||
message "putting generated icon path list to /etc/jwm/system.nanodesk.jwmrc"
|
||||
sed -i '/<\!-- GENERATED ICONLIST -->/r /tmp/jwm.iconlist' /etc/jwm/system.nanodesk.jwmrc || error
|
||||
|
||||
message "correct file permissions"
|
||||
#$CHROOTCMD /usr/bin/chmod 440 /etc/sudoers || error
|
||||
$CHROOTCMD /usr/bin/chmod 755 /usr/sbin/nanodesk-installer || error
|
||||
$CHROOTCMD /usr/bin/chmod 755 /usr/bin/nanodesk-installer-gxm || error
|
||||
$CHROOTCMD /usr/bin/chmod 755 /usr/bin/nanodesk || error
|
||||
$CHROOTCMD /usr/bin/chmod 755 /usr/bin/nanodesk-first-start || error
|
||||
$CHROOTCMD /usr/bin/chmod 755 /usr/bin/nanodesk-gen-iconlist || error
|
||||
/usr/bin/chmod 755 /usr/sbin/nanodesk-installer || error
|
||||
/usr/bin/chmod 755 /usr/bin/nanodesk-installer-gxm || error
|
||||
/usr/bin/chmod 755 /usr/bin/nanodesk || error
|
||||
/usr/bin/chmod 755 /usr/bin/nanodesk-first-start || error
|
||||
|
||||
message "set x-terminal-emulator to lxterminal"
|
||||
$CHROOTCMD /usr/bin/update-alternatives --set x-terminal-emulator /usr/bin/lxterminal
|
||||
/usr/bin/update-alternatives --set x-terminal-emulator /usr/bin/lxterminal
|
||||
|
||||
message "set x-window-manager to jwm-nanodesk"
|
||||
$CHROOTCMD /usr/bin/update-alternatives --install /usr/bin/x-window-manager x-window-manager /usr/bin/nanodesk 25
|
||||
$CHROOTCMD /usr/bin/update-alternatives --set x-window-manager /usr/bin/nanodesk
|
||||
#message "set x-window-manager to jwm-nanodesk"
|
||||
#/usr/bin/update-alternatives --install /usr/bin/x-window-manager x-window-manager /usr/bin/nanodesk 25
|
||||
#/usr/bin/update-alternatives --set x-window-manager /usr/bin/nanodesk
|
||||
|
||||
### set root password
|
||||
#message "set root password to 'debian'"
|
||||
#echo -e "debian\ndebian" | $CHROOTCMD /usr/bin/passwd root
|
||||
|
||||
### add debian user
|
||||
message "create user debian, password 'debian'"
|
||||
echo -e "debian\ndebian\nDebian\n\n\n\n\y\n" | $CHROOTCMD /usr/sbin/adduser debian
|
||||
#message "create user debian, password 'debian'"
|
||||
#echo -e "debian\ndebian\nDebian\n\n\n\n\y\n" | $CHROOTCMD /usr/sbin/adduser debian
|
||||
|
||||
message "add user debian to group sudo"
|
||||
$CHROOTCMD /usr/sbin/usermod -a -G sudo debian
|
||||
#message "add user debian to group sudo"
|
||||
#$CHROOTCMD /usr/sbin/usermod -a -G sudo debian
|
||||
|
||||
message "clear /tmp"
|
||||
$CHROOTCMD /usr/bin/rm -Rf /tmp/* || error
|
||||
#message "clear /tmp"
|
||||
#$CHROOTCMD /usr/bin/rm -Rf /tmp/* || error
|
||||
|
||||
### liveboot part, https://www.willhaley.com/blog/custom-debian-live-environment/
|
||||
message "make squashfs"
|
||||
test -f build/staging/live/filesystem.squashfs && sudo rm build/staging/live/filesystem.squashfs
|
||||
sudo mksquashfs \
|
||||
build/chroot \
|
||||
build/staging/live/filesystem.squashfs \
|
||||
-comp xz \
|
||||
-e boot || error
|
||||
|
||||
|
||||
message "copy kernel and initrd images"
|
||||
cp build/chroot/boot/vmlinuz-* build/staging/live/vmlinuz || error
|
||||
cp build/chroot/boot/initrd.img-* build/staging/live/initrd || error
|
||||
|
||||
message "generate isolinux.cfg"
|
||||
sed "s/%VERSION%/${VERSION}/g" templates/isolinux.tpl.cfg > build/staging/isolinux/isolinux.cfg
|
||||
|
||||
message "generate grub.cfg"
|
||||
sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/boot/grub/grub.cfg
|
||||
sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/EFI/BOOT/grub.cfg
|
||||
|
||||
message "copy grub-embed.cfg"
|
||||
cp templates/grub-embed.tpl.cfg build/tmp/grub-embed.cfg
|
||||
|
||||
message "copy isolinux"
|
||||
cp /usr/lib/ISOLINUX/isolinux.bin "build/staging/isolinux/" || error
|
||||
cp /usr/lib/syslinux/modules/bios/* "build/staging/isolinux/" || error
|
||||
|
||||
message "copy grub-efi"
|
||||
cp -r /usr/lib/grub/x86_64-efi/* "build/staging/boot/grub/x86_64-efi/" || error
|
||||
|
||||
message "make efi images"
|
||||
grub-mkstandalone -O i386-efi \
|
||||
--modules="part_gpt part_msdos fat iso9660" \
|
||||
--locales="" \
|
||||
--themes="" \
|
||||
--fonts="" \
|
||||
--output="build/staging/EFI/BOOT/BOOTIA32.EFI" \
|
||||
"boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
||||
|
||||
grub-mkstandalone -O x86_64-efi \
|
||||
--modules="part_gpt part_msdos fat iso9660" \
|
||||
--locales="" \
|
||||
--themes="" \
|
||||
--fonts="" \
|
||||
--output="build/staging/EFI/BOOT/BOOTx64.EFI" \
|
||||
"boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
||||
|
||||
(cd build/staging && \
|
||||
dd if=/dev/zero of=efiboot.img bs=1M count=20 && \
|
||||
/usr/sbin/mkfs.vfat efiboot.img && \
|
||||
mmd -i efiboot.img ::/EFI ::/EFI/BOOT && \
|
||||
mcopy -vi efiboot.img \
|
||||
../../build/staging/EFI/BOOT/BOOTIA32.EFI \
|
||||
../../build/staging/EFI/BOOT/BOOTx64.EFI \
|
||||
../../build/staging/boot/grub/grub.cfg \
|
||||
::/EFI/BOOT/
|
||||
) || error
|
||||
|
||||
message "generate .iso"
|
||||
xorriso \
|
||||
-as mkisofs \
|
||||
-iso-level 3 \
|
||||
-o "build/nanodesk_$VERSION.iso" \
|
||||
-full-iso9660-filenames \
|
||||
-volid "NANODESK" \
|
||||
--mbr-force-bootable -partition_offset 16 \
|
||||
-joliet -joliet-long -rational-rock \
|
||||
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
||||
-eltorito-boot \
|
||||
isolinux/isolinux.bin \
|
||||
-no-emul-boot \
|
||||
-boot-load-size 4 \
|
||||
-boot-info-table \
|
||||
--eltorito-catalog isolinux/isolinux.cat \
|
||||
-eltorito-alt-boot \
|
||||
-e --interval:appended_partition_2:all:: \
|
||||
-no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B build/staging/efiboot.img \
|
||||
"build/staging"
|
||||
#message "make squashfs"
|
||||
#test -f build/staging/live/filesystem.squashfs && sudo rm build/staging/live/filesystem.squashfs
|
||||
#sudo mksquashfs \
|
||||
# build/chroot \
|
||||
# build/staging/live/filesystem.squashfs \
|
||||
# -comp xz \
|
||||
# -e boot || error
|
||||
#
|
||||
#
|
||||
#message "copy kernel and initrd images"
|
||||
#cp build/chroot/boot/vmlinuz-* build/staging/live/vmlinuz || error
|
||||
#cp build/chroot/boot/initrd.img-* build/staging/live/initrd || error
|
||||
#
|
||||
#message "generate isolinux.cfg"
|
||||
#sed "s/%VERSION%/${VERSION}/g" templates/isolinux.tpl.cfg > build/staging/isolinux/isolinux.cfg
|
||||
#
|
||||
#message "generate grub.cfg"
|
||||
#sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/boot/grub/grub.cfg
|
||||
#sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/EFI/BOOT/grub.cfg
|
||||
#
|
||||
#message "copy grub-embed.cfg"
|
||||
#cp templates/grub-embed.tpl.cfg build/tmp/grub-embed.cfg
|
||||
#
|
||||
#message "copy isolinux"
|
||||
#cp /usr/lib/ISOLINUX/isolinux.bin "build/staging/isolinux/" || error
|
||||
#cp /usr/lib/syslinux/modules/bios/* "build/staging/isolinux/" || error
|
||||
#
|
||||
#message "copy grub-efi"
|
||||
#cp -r /usr/lib/grub/x86_64-efi/* "build/staging/boot/grub/x86_64-efi/" || error
|
||||
#
|
||||
#message "make efi images"
|
||||
#grub-mkstandalone -O i386-efi \
|
||||
# --modules="part_gpt part_msdos fat iso9660" \
|
||||
# --locales="" \
|
||||
# --themes="" \
|
||||
# --fonts="" \
|
||||
# --output="build/staging/EFI/BOOT/BOOTIA32.EFI" \
|
||||
# "boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
||||
#
|
||||
#grub-mkstandalone -O x86_64-efi \
|
||||
# --modules="part_gpt part_msdos fat iso9660" \
|
||||
# --locales="" \
|
||||
# --themes="" \
|
||||
# --fonts="" \
|
||||
# --output="build/staging/EFI/BOOT/BOOTx64.EFI" \
|
||||
# "boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
||||
#
|
||||
#(cd build/staging && \
|
||||
# dd if=/dev/zero of=efiboot.img bs=1M count=20 && \
|
||||
# /usr/sbin/mkfs.vfat efiboot.img && \
|
||||
# mmd -i efiboot.img ::/EFI ::/EFI/BOOT && \
|
||||
# mcopy -vi efiboot.img \
|
||||
# ../../build/staging/EFI/BOOT/BOOTIA32.EFI \
|
||||
# ../../build/staging/EFI/BOOT/BOOTx64.EFI \
|
||||
# ../../build/staging/boot/grub/grub.cfg \
|
||||
# ::/EFI/BOOT/
|
||||
#) || error
|
||||
#
|
||||
#message "generate .iso"
|
||||
#xorriso \
|
||||
# -as mkisofs \
|
||||
# -iso-level 3 \
|
||||
# -o "build/nanodesk_$VERSION.iso" \
|
||||
# -full-iso9660-filenames \
|
||||
# -volid "NANODESK" \
|
||||
# --mbr-force-bootable -partition_offset 16 \
|
||||
# -joliet -joliet-long -rational-rock \
|
||||
# -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
||||
# -eltorito-boot \
|
||||
# isolinux/isolinux.bin \
|
||||
# -no-emul-boot \
|
||||
# -boot-load-size 4 \
|
||||
# -boot-info-table \
|
||||
# --eltorito-catalog isolinux/isolinux.cat \
|
||||
# -eltorito-alt-boot \
|
||||
# -e --interval:appended_partition_2:all:: \
|
||||
# -no-emul-boot \
|
||||
# -isohybrid-gpt-basdat \
|
||||
# -append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B build/staging/efiboot.img \
|
||||
# "build/staging"
|
||||
#
|
||||
message "Your system is now nanodeskized :)"
|
||||
|
|
|
@ -136,8 +136,8 @@
|
|||
<IconPath>
|
||||
/usr/local/share/jwm
|
||||
</IconPath>
|
||||
<!-- List of IconPath gets generated by nanodesk-gen-iconlist helperscript -->
|
||||
<Include>exec:nanodesk-gen-iconlist</Include>
|
||||
<!-- the comment below is important for nanodesk to put in the actual IconPaths of the system generated by makeanything.sh -->
|
||||
<!-- GENERATED ICONLIST -->
|
||||
|
||||
|
||||
<!-- Virtual Desktops -->
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
echo "<JWM>"
|
||||
find /usr/share/icons/ -type d | sed -e 's/^/\ \ \ \ <IconPath>/g' -e 's/$/<\/IconPath>/g'
|
||||
echo "</JWM>"
|
|
@ -1,89 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#
|
||||
# nanodesk-menumaker - generate menu from .desktop files for jwm
|
||||
#
|
||||
# WORK IN PROGRESS
|
||||
#
|
||||
# DOES NOT WORK ATM
|
||||
|
||||
declare -A APPS_NAME
|
||||
declare -A APPS_ICON
|
||||
declare -A APPS_EXEC
|
||||
declare -A CATEGORIES_APPS
|
||||
|
||||
# excluding 'Audio' and 'Video' because they are kind of redundant with 'AudioVideo'
|
||||
FREEDESKTOP_CATEGORIES="AudioVideo Development Education Game Graphics Network Office Science Settings System Utility"
|
||||
|
||||
get_desktop_entry() {
|
||||
# only get [Desktop Entry] section
|
||||
# explanation https://stackoverflow.com/a/52957039
|
||||
sed -n '/\[Desktop Entry\]/,/.*:\[.*\]/ {//!p}'
|
||||
}
|
||||
|
||||
# Main freedesktop categories we iterate through later
|
||||
# https://specifications.freedesktop.org/menu-spec/latest/apa.html
|
||||
|
||||
# put filename in front of its content with awk
|
||||
# https://www.unix.com/302929136-post4.html?s=5d91d8bbc9c7a884772b0b84b3ca6c3f
|
||||
#
|
||||
# dumping all files into a variable is much faster then grepping each file by file
|
||||
# sed for remove path from filename: sed 's/^\/.*\/\(.*\.desktop:\)/\1/'
|
||||
# awk remove path from filename: https://stackoverflow.com/a/55149591
|
||||
DESKTOPFILES="$(awk '{n=split(FILENAME,array,"/"); split(array[n],arraym,"."); print arraym[1]":" $0 }' /usr/share/applications/*.desktop $HOME/.local/share/applications/*.desktop | get_desktop_entry |grep -E ':Name=|:Icon=|:Categories=|:NoDisplay=|:Exec=' )"
|
||||
|
||||
APPS_NODISPLAY="$(echo "$DESKTOPFILES" | grep "NoDisplay=true" | cut -d : -f1 | xargs | tr ' ' '|')"
|
||||
APPS="$(echo "$DESKTOPFILES" | grep -vE "$APPS_NODISPLAY" | cut -d : -f1 | uniq)"
|
||||
|
||||
# put the apps into the freedesktop categories
|
||||
for category in $FREEDESKTOP_CATEGORIES
|
||||
do
|
||||
# echo === CATEGORY $category ===
|
||||
CATEGORIES_APPS[$category]="$(echo "$DESKTOPFILES" | grep -i $category | cut -d : -f1 | uniq | xargs)"
|
||||
# echo ${CATEGORIES_APPS[$category]}
|
||||
|
||||
done
|
||||
|
||||
|
||||
for appname in $APPS
|
||||
do
|
||||
APPS_NAME[$appname]="$(echo "$DESKTOPFILES" | grep -E "^$appname.*Name=" | cut -d = -f2)"
|
||||
APPS_ICON[$appname]="$(echo "$DESKTOPFILES" | grep -E "^$appname.*Icon=" | cut -d = -f2)"
|
||||
APPS_EXEC[$appname]="$(echo "$DESKTOPFILES" | grep -E "^$appname.*Exec=" | cut -d = -f2)"
|
||||
done
|
||||
#
|
||||
#echo "$APPS"
|
||||
#echo ${!APPS_NAME[@]}
|
||||
#echo ${APPS_NAME[xfce4-web-browser]}
|
||||
#echo ${APPS_ICON[xfce4-web-browser]}
|
||||
#echo ${APPS_EXEC[xfce4-web-browser]}
|
||||
#echo ${APPS_CAT[xfce4-web-browser]}
|
||||
#echo "$DESKTOPFILES"
|
||||
|
||||
# jwm config output
|
||||
|
||||
cat <<EOF
|
||||
<?xml version="1.0"?>
|
||||
<JWM>
|
||||
EOF
|
||||
|
||||
for category in $FREEDESKTOP_CATEGORIES
|
||||
do
|
||||
# test "$category" == "AudioVideo" && category="Multimedia"
|
||||
#echo -e "appname: $appname \nName: ${APPS_NAME[$appname]}\nIcon: ${APPS_ICON[$appname]}\nExec: ${APPS_EXEC[$appname]}\nCategories: ${APPS_CAT[$appname]}\n---"
|
||||
test -n "${CATEGORIES_APPS[$category]}" && cat <<EOF
|
||||
<Menu icon="applications-${category,,}" label="${category}">
|
||||
EOF
|
||||
|
||||
for app in ${CATEGORIES_APPS[$category]}
|
||||
do
|
||||
echo " <Program icon=\""${APPS_ICON[$app]}"\" label=\""${APPS_NAME[$app]}"\">"${APPS_EXEC[$app]}"</Program>"
|
||||
done
|
||||
|
||||
|
||||
test -n "${CATEGORIES_APPS[$category]}" && echo "</Menu>"
|
||||
|
||||
done
|
||||
|
||||
echo "</JWM>"
|
||||
|
Loading…
Reference in a new issue