If YAD is a fork of Zenity why is there no --imagelist? - zenity

Zenity is used in many of my bash projects, but looking at the advanced features of YAD there are many reasons to switch. After some testing unfortunately I discovered there is no --imagelist option for the list type dialog. This is a major problem as most of my projects use imagelists.
The below example runs on zenity version 3.28.1
#!/bin/bash
table=(~/image.png " " "Title1" " " "description1" "output1" ~/image.png " " "Title2" " " "description2" "output2" ~/image.png " " "Title3" " " "description3" "output3")
zenity --list --title="page title" --text="some random text" --imagelist --ok-label=Open --cancel-label=Home --print-column=6 --hide-column=6 --separator=' ' --width=600 --height=400 \
--column="Cover image" \
--column=" " \
--column="Name" \
--column=" " \
--column="details" \
--column="Folder" \
"${table[#]}"
the dialog should look like this:
In this example ${table[#]} is an array that contains all the data for each row including the file-path to the image in column 1. Is there a way to do this in YAD?
I installed YAD and looked at all the help pages provided in terminal, also tried to run similar imagelist examples, but it seems to be not supported (syntax is mostly the same as YAD is a fork of zenity)

With yad the columns can have a type associated with them. In your case you want to use the :IMG type for the first column, and the other two can remain as plain text.
table=(
~/image.png "" "Title1" "" "description1" "output1"
~/image.png "" "Title2" "" "description2" "output2"
~/image.png "" "Title3" "" "description3" "output3"
)
yad \
--list \
--title="page title" \
--text="some random text" \
--imagelist \
--print-column=6 \
--hide-column=6 \
--separator=' ' \
--width=600 \
--height=400 \
--column="Cover image:IMG" \
--column=" " \
--column="Name" \
--column=" " \
--column="details" \
--column="Folder" \
--button="Home":1 \
--button="Open":20 \
--response=20 \
"${table[#]}"
The output, missing your images
That will set the exit code to 20 if you press Enter or click Open on a list item, as well as outputting "output1" or "output2" etc.
That said, I have been experiencing issues with the exit codes or output text not appearing correctly. The above example works fine for me, but if I change the the Open exit code to "25" instead of "20" it stops working. No idea why it behaves inconsistently.

Related

Activating distro layer in Yocto

What are the required steps to use a distro layer in Yocto?
Currently, I have the following setup:
meta-my-distro-layer/conf/distro/mydistro.conf:
DISTROOVERRIDES =. "poky:"
require conf/distro/poky.conf
DISTRO = "mydistro"
DISTRO_NAME = "MyDistro"
DISTRO_VERSION = "1.0"
DISTRO_CODENAME = "one"
INIT_MANAGER = "systemd"
meta-my-distro-layer/conf/layer.conf
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-my-distro-layer"
BBFILE_PATTERN_meta-my-distro-layer = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-my-distro-layer = "6"
LAYERDEPENDS_meta-my-distro-layer = "core"
LAYERSERIES_COMPAT_meta-my-distro-layer = "kirkstone"
meta-my-distro-layer/recipes-core/images/console-image.bb
DESCRIPTION = "A console-only image"
IMAGE_FEATURES += "ssh-server-openssh"
IMAGE_INSTALL = "\
packagegroup-core-boot \
packagegroup-core-full-cmdline \
${CORE_IMAGE_EXTRA_INSTALL} \
"
inherit core-image
IMAGE_INSTALL += "curl"
build/conf/bblayers.conf:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/my-work-dir/poky/meta \
/my-work-dir/poky/meta-poky \
/my-work-dir/poky/meta-yocto-bsp \
/my-work-dir/poky/meta-my-distro-layer \
"
I can build the console image defined in that layer, but nothing set in mydistro.conf seems to have any effect on bitbake. According to bitbake -e, DISTRO and INIT_MANAGER never get set to my values and (consequently) trying to set INIT_MANAGER to systemd never takes effect. I can set INIT_MANAGER in conf/local.conf and it takes effect then, but I'd like to do that in a distro layer.
You need to set DISTRO to mydistro in local.conf

Yocto:How to use meta-intel to generate iso images that can be started in vmware?

I want to use the meta intel layer to generate an ISO image of core image minimal.Although the image is generated normally, I cannot use vmware to start it. The picture is as follows:
enter image description here
This is my local.conf.
MACHINE ?= "intel-corei7-64"
#
# This sets the default machine to be qemux86-64 if no other machine is selected:
MACHINE ??= "qemux86-64"
DISTRO ?= "poky"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats"
IMAGE_FSTYPES += "live"
NOISO = "0"
PREFERRED_PROVIDER_virtual/kernel = "linux-intel"
DEPENDS:append:${MACHINE} = " cdrtools-native"
IMAGE_FSTYPES:append = " ext4"
IMAGE_TYPEDEP_wic = "ext4"
do_image_wic[depends] += "${INITRD_IMAGE_LIVE}:do_image_complete"
do_rootfs[depends] += "virtual/kernel:do_deploy"
IMAGE_BOOT_FILES:append = "\
${KERNEL_IMAGETYPE} \
microcode.cpio \
${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}.ext4;rootfs.img \
${#bb.utils.contains('EFI_PROVIDER', 'grub-efi', 'grub-efi- bootx64.efi;EFI/BOOT/bootx64.efi', '', d)} \
${#bb.utils.contains('EFI_PROVIDER', 'grub-efi', '${IMAGE_ROOTFS}/boot/EFI/BOOT/grub.cfg;EFI/BOOT/grub.cfg', '', d)} \
${#bb.utils.contains('EFI_PROVIDER', 'systemd-boot', 'systemd-bootx64.efi;EFI/BOOT/bootx64.efi', '', d)} \
${#bb.utils.contains('EFI_PROVIDER', 'systemd-boot', '${IMAGE_ROOTFS}/boot/loader/loader.conf;loader/loader.conf ', '', d)} \
${#bb.utils.contains('EFI_PROVIDER', 'systemd-boot', '${IMAGE_ROOTFS}/boot/loader/entries/boot.conf;loader/entries/boot.conf', '', d)} "
This is my bblayer.conf.
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/brain/poky/meta \
/home/brain/poky/meta-poky \
/home/brain/poky/meta-yocto-bsp \
/home/brain/poky/meta-intel\
"
Now how can I generate an iso image that can be started normally?
This one should work with VMWare:
IMAGE_FSTYPES = wic.vmdk

Generate many files with wildcard, then merge into one

I have two rules on my Snakefile: one generates several sets of files using wildcards, the other one merges everything into a single file. This is how I wrote it:
chr = range(1,23)
rule generate:
input:
og_files = config["tmp"] + '/chr{chr}.bgen',
output:
out = multiext(config["tmp"] + '/plink/chr{{chr}}',
'.bed', '.bim', '.fam')
shell:
"""
plink \
--bgen {input.og_files} \
--make-bed \
--oxford-single-chr \
--out {config[tmp]}/plink/chr{chr}
"""
rule merge:
input:
plink_chr = expand(config["tmp"] + '/plink/chr{chr}.{ext}',
chr = chr,
ext = ['bed', 'bim', 'fam'])
output:
out = multiext(config["tmp"] + '/all',
'.bed', '.bim', '.fam')
shell:
"""
plink \
--pmerge-list-dir {config[tmp]}/plink \
--make-bed \
--out {config[tmp]}/all
"""
Unfortunately, this does not allow me to track the file coming from the first rule to the 2nd rule:
$ snakemake -s myfile.smk -c1 -np
Building DAG of jobs...
MissingInputException in line 17 of myfile.smk:
Missing input files for rule merge:
[list of all the files made by expand()]
What can I use to be able to generate the 22 sets of files with the wildcard chr in generate, but be able to track them in the input of merge? Thank you in advance for your help
In rule generate I think you don't want to escape the {chr} wildcard, otherwise it doesn't get replaced. I.e.:
out = multiext(config["tmp"] + '/plink/chr{{chr}}',
'.bed', '.bim', '.fam')
should be:
out = multiext(config["tmp"] + '/plink/chr{chr}',
'.bed', '.bim', '.fam')

Compile a static version of pngquant

I'm trying to create a statically linked version of pngquant in Oracle Linux Server release 7.1. I've compiled the static version of zlib and the static version of libpng.
Then, when I configure pngquant, I always get the information that it will be linked with a shared version of zlib.
$ ./configure --with-libpng=../libpng-1.6.21 --extra-cflags="-I../zlib-1.2.8" --extra-ldflags="../zlib-1.2.8/libz.a"
Compiler: gcc
Debug: no
SSE: yes
OpenMP: no
libpng: static (1.6.21)
zlib: shared (1.2.7)
lcms2: no
If I execute make, in the output it seems that the options are correctly passed to the compiler. However, the resulting binary requires libz.so to be executed. It seems that my directives are ignored or that the installed version always takes precedence.
Is there any way of forcing pngquant to be compiled with the static version of zlib?
I'm not sure, if I got it right, but here's a patch to pngquant's configure that worked for me. configure now accepts --with-zlib=<dir> as parameter. Store it to pngquant.patch and apply it with patch -uN -p1 -i pngquant.patch.
diff -ur pngquant-2.9.0/configure pngquant-2.9.0.fixed/configure
--- pngquant-2.9.0/configure 2017-03-06 09:37:30.000000000 +0100
+++ pngquant-2.9.0.fixed/configure 2017-03-07 09:57:20.246012152 +0100
## -48,6 +48,7 ##
help "--with-cocoa/--without-cocoa use Cocoa framework to read images"
fi
help "--with-libpng=<dir> search for libpng in directory"
+ help "--with-zlib=<dir> search for zlib in directory"
echo
help "CC=<compiler> use given compiler command"
help "CFLAGS=<flags> pass options to the compiler"
## -97,6 +98,9 ##
--with-libpng=*)
LIBPNG_DIR=${i#*=}
;;
+ --with-zlib=*)
+ ZLIB_DIR=${i#*=}
+ ;;
--prefix=*)
PREFIX=${i#*=}
;;
## -238,6 +242,19 ##
echo "${MAJ}${MIN}"
}
+# returns full zlib.h version string
+zlibh_string() {
+ echo "$(grep -m1 "define ZLIB_VERSION" "$1" | \
+ grep -Eo '"[^"]+"' | grep -Eo '[^"]+')"
+}
+
+# returns major minor version numbers from png.h
+zlibh_majmin() {
+ local MAJ=$(grep -m1 "define ZLIB_VER_MAJOR" "$1" | grep -Eo "[0-9]+")
+ local MIN=$(grep -m1 "define ZLIB_VER_MINOR" "$1" | grep -Eo "[0-9]+")
+ echo "${MAJ}${MIN}"
+}
+
error() {
status "$1" "error ... $2"
echo
## -420,11 +437,42 ##
error "libpng" "not found (try: $LIBPNG_CMD)"
fi
-# zlib
-if ! find_library "zlib" "z" "zlib.h" "libz.a" "libz.$SOLIBSUFFIX*"; then
- error "zlib" "not found (please install zlib-devel package)"
+# try if given flags are enough for zlib
+HAS_ZLIB=0
+if echo "#include \"zlib.h\"
+ int main(){
+ uLong test = zlibCompileFlags();
+ return 0;
+}" | "$CC" -xc -std=c99 -o /dev/null $CFLAGS $LDFLAGS - &> /dev/null; then
+ status "zlib" "custom flags"
+ HAS_ZLIB=1
fi
+if [ "$HAS_ZLIB" -eq 0 ]; then
+ # try static in the given directory
+ ZLIBH=$(find_h "$ZLIB_DIR" "zlib.h")
+ if [ -n "$ZLIBH" ]; then
+ ZLIBH_STRING=$(zlibh_string "$ZLIBH")
+ ZLIBH_MAJMIN=$(zlibh_majmin "$ZLIBH")
+ if [[ -n "$ZLIBH_STRING" && -n "$ZLIBH_MAJMIN" ]]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz${ZLIBH_MAJMIN}.a")
+ if [ -z "$ZLIBA" ]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz.a")
+ fi
+ if [ -n "$ZLIBA" ]; then
+ cflags "-I${ZLIBH%/*}"
+ lflags "${ZLIBA}"
+ status "zlib" "static (${ZLIBH_STRING})"
+ HAS_ZLIB=1
+ fi
+ fi
+ fi
+fi
+# zlib
+if ! find_library "zlib" "z" "zlib.h" "libz.a" "zlib.$SOLIBSUFFIX*"; then
+ error "zlib" "not found (please install zlib-devel package)"
+fi
+
# lcms2
if [ "$LCMS2" != 0 ]; then
if find_library "lcms2" "lcms2" "lcms2.h" "liblcms2.a" "liblcms2.$SOLIBSUFFIX*"; then
Sorry, the configure script does not support it. It shouldn't be too hard to modify configure to pass appropriate flags to pkg-config or do the same workaround it does for libpng.

zenity only displays odd lines when used with cat

I'm have problems using zenity.
Here's the script:
CHECKED=`cat /tmp/1 | \
zenity --width=500 --height=450 --list --radiolist --separator=' ' \
--title="Select Results." \
--text="show lines" --column="" --column="Files"`
The file /tmp/1:
1
2
3
4
5
6
7
8
9
When I run this script it only displays lines 1,3,5,7,9
What am I doing wrong?
1 line in the input file equals 1 column in the dialogue. Because you are adding radio buttons, your dialogue has 2 columns (hence your two --column arguments) so your input doesn't match what is to be displayed. In other words, Zenity expects something like this:
FALSE
1
FALSE
2
FALSE
3
TRUE
4
...where TRUE/FALSE signifies whether the radio button is pre-selected when the dialogue opens.
To fix your script without modification of the input file, you can simply prefix each line with an extra line:
CHECKED=`cat /tmp/1 | \
sed 's/^/FALSE\n/g' | \
zenity --width=500 --height=450 --list --radiolist --separator=' ' \
--title="Select Results." \
--text="show lines" --column="" --column="Files"`