The time now is Sat 23 Jan 2021, 00:10
All times are UTC - 4 |
Page 46 of 56 [838 Posts] |
Goto page: Previous 1, 2, 3, ..., 44, 45, 46, 47, 48, ..., 54, 55, 56 Next |
Author |
Message |
achim
Joined: 13 Apr 2017 Posts: 48 Location: Germany
|
Posted: Wed 21 Aug 2019, 18:49 Post subject:
Create a continuous digital clock |
|
Hello, I would like to insert a continuous digital clock into a YAD title with --text-info. Can somebody help me with it?
Thanks in advance
achim
Last edited by achim on Wed 21 Aug 2019, 21:42; edited 1 time in total
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Wed 21 Aug 2019, 19:00 Post subject:
|
|
hi Fred
yandex isnt working for me. Google not working for you. Script must have a bug!
|
Back to top
|
|
 |
fredx181

Joined: 11 Dec 2013 Posts: 4481 Location: holland
|
Posted: Thu 22 Aug 2019, 04:09 Post subject:
|
|
Nice work stemsee, working fine for me !!
Quote: | yandex isnt working for me. Google not working for you. Script must have a bug! |
Google works again for me now, yes yandex often fails for me too.
I assume you mean the 'trans' script must have a bug ? (or maybe it's because of recent changes at the yandex end).
Hopefully it gets updated soon so yandex works again.
Fred
_________________ Dog Linux website
Tinylinux blog by wiak
|
Back to top
|
|
 |
misko_2083

Joined: 08 Nov 2016 Posts: 114
|
Posted: Thu 22 Aug 2019, 05:51 Post subject:
Re: Create a continuous digital clock |
|
achim wrote: | Hello, I would like to insert a continuous digital clock into a YAD title with --text-info. Can somebody help me with it?
Thanks in advance
achim |
Install/use wmctrl
Code: | #!/bin/bash
win_class="Achim"
yad --text-info --class="${win_class}" --title="Achim: $(date '+%T')" --width=300 & achims_pid=$!
trap "kill -s SIGUSR1 $achims_pid" EXIT
declare achim_xid
# need some time to register window class with X
while [[ ${achim_xid} == "" ]]; do
# get Xwindow id
achim_xid="$(wmctrl -lx | grep -e "yad.${win_class}" | grep -oE "[0-9a-z]{10}")"
done
# convert to decimal number
achim_xid="$(echo $((${achim_xid})))"
while true
do
wmctrl -i -r "${achim_xid}" -N "Achim: $(date '+%T')" 2>/dev/null || break
sleep 1
done |
Last edited by misko_2083 on Thu 22 Aug 2019, 07:55; edited 1 time in total
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Thu 22 Aug 2019, 06:59 Post subject:
|
|
Hi Fred et al
yes, trans script might have bug.
I want to implement another version which uses yad --notebook with tabs for each engines' result. My first effort failed! would be nice is all.
Also in the engine loop newline after do, by adding Code: | echo "icon:/usr/share/pixmaps/$ex.png >$PIPE" | tray icon can show which engine is translating....of course need icons first.
Also the Code: | echo -----^$ex $i^----- | should be at the head instead of underlining each translation in case of a large body of text.
Code: | echo -----$ex $i----- |
regards
stemsee
EDIT hi Misko
wouldn't
be better?
|
Back to top
|
|
 |
achim
Joined: 13 Apr 2017 Posts: 48 Location: Germany
|
Posted: Thu 22 Aug 2019, 08:36 Post subject:
Create a continuous digital clock |
|
Hello misko_2083,
your code works great.
Thank you for your help!
achim
|
Back to top
|
|
 |
fredx181

Joined: 11 Dec 2013 Posts: 4481 Location: holland
|
Posted: Thu 22 Aug 2019, 08:37 Post subject:
|
|
Hi stemsee, good luck with the notebook version, don't think I can help, didn't do much with that.
Quote: | Also the
Code:
echo -----^$ex $i^-----
should be at the head instead of underlining each translation in case of a large body of text.
Code:
echo -----$ex $i----- |
Yes, would be much better, also I like showing the full language names, so made the "trans_paste" function this(see pic):
Code: | trans_paste () {
#set -x
export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null)
export _TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null | awk '{print $1}' | tr '\n' '+' | sed 's/.$//')
[ -z "$TLANG" ] && export TLANG="English - en"
export ENGINE=$(cat /tmp/_trans_engine_ 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google
echo "Using $ENGINE for translating"
ICON="/tmp/trans-paste.svg"
if [ ! -e "$ICON" ]; then
SVG="<""svg height='100' width='100'>
<path style='fill:red;stroke:darkred;stroke-width:3;'
d='M 93,62 C 83,82 65,96 48,96 32,96 19,89 15,79 L 5,90 5,53
40,53 29,63 c 0,0 5,14 26,14 16,0 38,-15 38,-15 z'/>
<path style='fill:red;stroke:darkred;stroke-width:3;'
d='M 5,38 C 11,18 32,4 49,4 65,4 78,11 85,21 L 95,10 95,47
57,47 68,37 C 68,37 63,23 42,23 26,23 5,38 5,38 z'/>
</svg>"
echo "$SVG" > /tmp/trans-paste.svg
fi
HELP=" Translating to $_TLANG... \n Press <b>ESC</b> key or click <b>EXIT</b> to dismiss."
MYTITLE="Trans"
BUT="<span color='darkblue'><b>Exit</b></span>"
FONT="Mono 12"
TWIDTH=$(xdpyinfo | grep 'dimensions:' | cut -d' ' -f7 | cut -d'x' -f1)
SWIDTH=$(( $TWIDTH - 600 ))
#echo $SWIDTH
for ex in $ENGINE
do
while read i; do
echo " > $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG"; done | tee >(yad \
--window-icon="$ICON" \
--text-align=center \
--title="$MYTITLE" \
--geometry=600x600+$SWIDTH+100 \
--fore="black" --back="#fef1e0" \
--margins=5 \
--button="$BUT" \
--text="$HELP" \
--fontname="$FONT" \
--text-info --wrap)
}
export -f trans_paste |
Fred
Description |
|
Filesize |
61.75 KB |
Viewed |
375 Time(s) |

|
_________________ Dog Linux website
Tinylinux blog by wiak
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Thu 22 Aug 2019, 10:15 Post subject:
|
|
Hi Fred
Is it possible to make the headings a different text color? If not I prefer the previous style!
The new code is difficult to understand, for me!
However _ _ _ _ _ Each to their own_ _ _ _ _
stemsee
EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
|
Back to top
|
|
 |
fredx181

Joined: 11 Dec 2013 Posts: 4481 Location: holland
|
Posted: Thu 22 Aug 2019, 10:28 Post subject:
|
|
stemsee wrote: | Is it possible to make the headings a different text color? If not I prefer the previous style! |
I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.
What exactly do you prefer then as "previous style" ?
EDIT:
Quote: | EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly? |
Mmm.. that's a pity, not sure yet how to handle that.
BTW, I think it's better to remove Yandex from the translator choices, it really doesn't work well.
Fred
_________________ Dog Linux website
Tinylinux blog by wiak
|
Back to top
|
|
 |
misko_2083

Joined: 08 Nov 2016 Posts: 114
|
Posted: Thu 22 Aug 2019, 10:45 Post subject:
|
|
stemsee wrote: |
EDIT hi Misko
wouldn't
be better? |
Depends on the moment.
fredx181 wrote: | stemsee wrote: | Is it possible to make the headings a different text color? If not I prefer the previous style! |
I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.
What exactly do you prefer then as "previous style" ?
EDIT:
Quote: | EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly? |
|
how about html?
Code: | echo "<h3>heading</h3><font color=red>some text</font>" | yad --html |
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Thu 22 Aug 2019, 11:14 Post subject:
|
|
Hi Fred, Misko et al
yad --html sounds like an interesting development!
by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.
Indeed remove yandex ... maybe replace?? ... DeepL...?
stemsee
|
Back to top
|
|
 |
fredx181

Joined: 11 Dec 2013 Posts: 4481 Location: holland
|
Posted: Thu 22 Aug 2019, 11:18 Post subject:
|
|
misko wrote: | how about html? Smile
Code:
echo "<h3>heading</h3><font color=red>some text</font>" | yad --html |
Ok, thanks, never did anything with the yad --html option, I think the compiled yad has to be configured with that, most yad packages (for e.g. Puppy or others) don't have this option by default, I think.
@stemsee
Quote: | The new code is difficult to understand, for me! |
Not so difficult in fact, to explain:
At start of function:
Code: | export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null) |
$TLANG will output the full contents of $HOME/.trans_target_lang2
And further on:
Code: | while read i; do
echo " > $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG"; |
Will extract the full language name, e.g. Spanish : $ex translation to $(echo $i | awk '{print $1}')
and the locale code to be used by trans, e.g. es : trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
EDIT:
Quote: | by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience. |
Ok, but how would you prefer exactly then as header, something like (or.. ?):
----- google translate to Bulgarian -----
I think deepl isn't supported by trans anymore.
Fred
_________________ Dog Linux website
Tinylinux blog by wiak
Last edited by fredx181 on Thu 22 Aug 2019, 11:44; edited 1 time in total
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Thu 22 Aug 2019, 11:39 Post subject:
|
|
fredx181 wrote: |
Ok, but how would you prefer exactly then as header, something like (or.. ?):
----- google translate to Bulgarian -----
Fred |
Yes that's clearer!
EDIT 'tee >' is not needed
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2572 Location: In The Way
|
Posted: Thu 22 Aug 2019, 13:00 Post subject:
|
|
I found the bug for google.
And I know why yandex is problematic.
|
Back to top
|
|
 |
fredx181

Joined: 11 Dec 2013 Posts: 4481 Location: holland
|
Posted: Thu 22 Aug 2019, 13:17 Post subject:
|
|
stemsee wrote: | I found the bug for google.
And I know why yandex is problematic. |
So... what did you find then ?
_________________ Dog Linux website
Tinylinux blog by wiak
|
Back to top
|
|
 |
|
Page 46 of 56 [838 Posts] |
Goto page: Previous 1, 2, 3, ..., 44, 45, 46, 47, 48, ..., 54, 55, 56 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|