The officially official Devuan Forum!

You are not logged in.

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

dice
Member
Registered: 2020-11-22
Posts: 346  
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)


Do good things.  Share.  Be helpful.  Be decent.  Live large.

Offline

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

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 1,530  
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)


Black Lives Matter

Offline

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

dice
Member
Registered: 2020-11-22
Posts: 346  
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.


Do good things.  Share.  Be helpful.  Be decent.  Live large.

Offline

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

dice
Member
Registered: 2020-11-22
Posts: 346  
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)


Do good things.  Share.  Be helpful.  Be decent.  Live large.

Offline

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

dice
Member
Registered: 2020-11-22
Posts: 346  
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)


Do good things.  Share.  Be helpful.  Be decent.  Live large.

Offline

Board footer