The officially official Devuan Forum!

You are not logged in.

#1 2020-12-08 13:56:54

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

yad tips and tricks.

Having discovered the wonderful yad program awhile back i have revisited it and give you the following cool scripts. The calendar is mainly a good script to use for the dwm statusbar with the systray patch.

Yad exit menu with papirus icons, this needs elogind to work, you could swap out the commands with sudo though.
Xscreensaver for locking, all other locking programs dont quite compare to it.

#!/usr/bin/env bash

yad-cancel() {
	kill -USR1 $YAD_PID
}

export -f yad-cancel
	
yad --no-buttons --close-on-unfocus --width 200 --height 50 --form --columns 5 --borders=20 --center --on-top \
        --field=Lock!"$HOME/bin/exit-icons/lock.svg":fbtn "xscreensaver-command -l" \
        --field=Logout!"$HOME/bin/exit-icons/logout.svg":fbtn "pkill -U $USER" \
        --field=Reboot!"$HOME/bin/exit-icons/reboot.svg":fbtn "loginctl reboot" \
        --field=Poweroff!"$HOME/bin/exit-icons/poweroff.svg":fbtn "loginctl poweroff" \
        --field=Cancel!"$HOME/bin/exit-icons/close.svg":fbtn "bash -c yad-cancel"

Yad notification calendar using gsimplecal.

#!/usr/bin/env bash

yad --notification \
	--image="/usr/share/icons/Papirus-Dark/24x24/apps/office-calendar.svg" \
	--command="gsimplecal" --text="$(date)" \

Some scrots

2020-12-08-234940-1366x768-scrot.png 2020-12-08-235059-1366x768-scrot.png

EDIT: calendar tooltip --text="$(date)" needs a 60 second loop, not sure how to implement that alongside yad?

UPDATE 12/12/20 : for yad exit menu using a newer version of yad (on artixlinux), i can call the icons from /usr/share/icons/Papirus as per below.

#!/bin/bash

yad-cancel() {
	kill -USR1 $YAD_PID
}

export -f yad-cancel

yad --no-buttons --close-on-unfocus --width 500 --height 50 --form --columns=5 --borders=10 --center --on-top \
        --field='!database-lock!lock':fbtn "xscreensaver-command -l" \
        --field='!application-exit!logout':fbtn "loginctl kill-user $USER" \
        --field='!reload!reboot':fbtn "loginctl reboot" \
        --field='!system-shutdown-panel!poweroff':fbtn "loginctl poweroff" \
        --field='!button_cancel!cancel':fbtn "bash -c yad-cancel"

Last edited by dice (2020-12-12 10:16:34)

Offline

#2 2020-12-08 16:59:46

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: yad tips and tricks.

Nice, thanks for sharing.

Apologies if this is an irritating point to raise but your scripts do not use bashisms so they could (should?) have a /bin/sh shebang instead.

EDIT: and did you know that yad already has a calendar?

yad --calendar

Last edited by Head_on_a_Stick (2020-12-08 17:04:00)


Brianna Ghey — Rest In Power

Offline

#3 2020-12-09 00:46:36

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: yad tips and tricks.

Im very novice at scripts, i had thought that they could just be /bin/sh, thanks.

Ahh yes i forgot yad had a calendar function, i will have to incorporate that instead maybe, although does gsimplecal have a bit more functionality than yad calendar? i will have to find out.

Offline

#4 2020-12-09 08:49:40

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: yad tips and tricks.

as promised, the yad exit icons. They are just recolored #15539E papirus 24x24 action and panel icons done in inkscape, all credit to papirus icons.

https://notabug.org/dice_1/dotfiles/src … with-icons

no longer available, deleted repo. The idea was no good anyway, i cant figure out how to save svg file properly.

Last edited by dice (2020-12-12 10:11:49)

Offline

#5 2021-02-25 14:50:08

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: yad tips and tricks.

here is something i picked up today in regards to having a tray menu app to logout and shutdown, the first script calls the exit.sh menu similar to how gnome-desktop does it but with dwm statusbar systray and you can easily lock and logout the session here, then when the shutdown is pressed the exit menu appears with reboot or shutdown. The tray icon needs to be specified directly within yad. This is for dwm using the systray patch as shown in screens but could be used for any panel with tray app i think.

#!/bin/sh

PIPE="/tmp/.pipe.tmp"
rm          "$PIPE"
mkfifo      "$PIPE"
exec 3<>    "$PIPE"

yad --notification --listen <&3 &
echo "menu:\
Lock                    !i3lock-fancy!system-lock-screen-symbolic||\
Logout                  !loginctl kill-user "$USER"!exit||\
Shutdown                !exit.sh!system-shutdown-symbolic" >&3

echo "icon:$HOME/.icons/system-shutdown-symbolic.svg" >&3 
echo "tooltip:Right click to choose option" >&3

exit.sh script

#!/bin/bash

yad_cancel () {
        kill -USR1 "$YAD_PID"
}

export -f yad_cancel

yad --no-buttons --geometry=150x100+1300+0 --form --columns=1 --borders=10 --keep-icon-size --on-top \
        --field='!/usr/share/icons/Papirus-Dark/24x24/panel/system-restart-panel.svg!reboot':fbtn "loginctl reboot" \
        --field='!/usr/share/icons/Papirus-Dark/24x24/panel/system-shutdown-panel.svg!poweroff':fbtn "loginctl poweroff" \
        --field='!/usr/share/icons/Papirus-Dark/24x24/actions/button_cancel.svg!cancel':fbtn "bash -c 'yad_cancel'"

screens

2021-02-26-004145-1366x768-scrot.png 2021-02-26-004209-1366x768-scrot.png

Last edited by dice (2021-02-25 14:54:48)

Offline

#6 2021-07-08 07:20:23

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: yad tips and tricks.

messing about in yad again with my openbox/tint2 setup.

Here is a nice script you could use as a Places dialog button in tint2. I use spacefm as file manager, you could use pcmanfm etc etc.
What this does is bring up small yad dialog you can choose to open your file manager and cd into various directories.

#!/bin/sh	

dialog=$(yad --window-icon=gtk-directory --mouse --timeout=3 --title "Select Directory" --form --field=Choose:DIR)
path=$(echo $dialog | awk 'BEGIN {FS="|" } { print $1 }')

spacefm "$path"

Last edited by dice (2021-07-08 07:22:02)

Offline

#7 2021-09-27 12:32:13

alphalpha
Member
From: Germany
Registered: 2018-01-23
Posts: 146  

Re: yad tips and tricks.

this one uses yad, imagemagick and xwallpaper to quickly create an plain-colored wallpaper

#!/bin/sh
FILE="$HOME/.local/wallpaper.png"

# use yad to select color value
COLOR="$(yad --title="Set Wallpaper" --color)"

# use imagemagick to create the png file
if [ "$COLOR" ]; then
  [ -e "$FILE" ] && rm "$FILE"
  convert -size $(xdpyinfo | awk '/dimensions/ {print $2}') canvas:$COLOR "$FILE"

# use xwallpaper to set the wallpaper
  xwallpaper --zoom "$FILE"
fi
exit 0

Offline

#8 2022-04-16 18:45:02

Nili
Member
From: $HOME/♫♪
Registered: 2016-12-01
Posts: 230  
Website

Re: yad tips and tricks.

I had not paid very much attention to yad, thanks to this thread cames to help me having a better gui for logout, reboot and poweroff.

I used dialog for those stuff, but yad to a better rescue.

Last edited by Nili (2022-04-16 18:47:19)


Tumbleweed - KDE Plasma (Wayland) - Breeze (LeafDark) [Qt]
♪Mahara★Japaaan!

Offline

#9 2022-10-02 14:57:49

MiyoLinux
Member
Registered: 2016-12-05
Posts: 1,323  

Re: yad tips and tricks.

I'm not sure how I missed this thread. I've used YAD for various GUIs on MiyoLinux since I started it. I recently uploaded a lot of the scripts to the MiyoLinux Sourceforge page if anyone is interested. Some of them are very basic, and some of them are more involved. They all are licensed as Public Domain, so feel free to do with them what you want. smile

Here is a list of what I posted there...

Extra Software (a GUI to easily install some commonly used applications)
Live Keyboard Layout (a GUI to easily change keyboard layouts)
my-crappy-media-player-v2 (a crappy media player that uses ffplay)
my-crappy-music-player (a crappy music player that uses ffplay)
miyo-welcome (one version of the MiyoLinux Welcome Screen)
miyo-control-center (well, it's a basic Control Center)
miyo-touchpad (a GUI to temporarily turn certain touchpad controls on/off)
miyo-picom (temporarily turn picom on/off)
miyo-exit (an exit menu)
miyo-conky (temporarily turn conky on/off)
miyo-calendar (an edited version on the YAD Calendar that I use on MiyoLinux)

Download page - https://sourceforge.net/projects/miyoli … D-scripts/

Last edited by MiyoLinux (2022-10-02 14:59:35)


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

Board footer