You are not logged in.
Notice my little script does NOT use "pkill -9".
If running shut it down
If not running, start it up
The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!
Offline
...
I also have a SSC.sh file to Start|Stop Conky, various ones, that might help you, adapt it for your need:#!/bin/bash ## Original idea by: GrouchyGaijin ## This idea by: Stinkeye - Jan 2013 ## With another tweak by: arclance ## Final tweak by: Sector11 ## click to start, click to stop if pgrep -f "conky -q -c /media/5/Conky/easysid/MechClock/conkyrc_clock" then pkill -xf "conky -q -c /media/5/Conky/easysid/MechClock/conkyrc_clock" else conky -q -c "/media/5/Conky/easysid/MechClock/conkyrc_clock" fi
It checks to see if the conky is running:
if yes - it kills it
if no - it starts itWorth a try.
Remember the part inside the " " are the exact command to run the program.
Looks like the "pgrep" bit can be left out:
#!/bin/bash
pkill -xf "conky -c /path/to/conky" || conky -c "/path/to/conky"
Using the Openbox (3.5.2) session of Lubuntu 14.04 LTS but very interested in BL :)
Offline
What does the -9 do?
Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos
Offline
sleekmason wrote:What does the -9 do?
Ha! This is good:)
Offline
How do you manage the need to run as root or with sudo, when in conky?
// Regards rbh
Offline
How do you manage the need to run as root or with sudo, when in conky?
It comes down to being able to execute commands with superuser privileges without the need of entering a password (interactively).
Several approaches exist: with PAM I guess, or with adding certain commands to your sudoers config files under /etc.
For the latter, see: https://wiki.archlinux.org/index.php/Su … le_entries
Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos
Offline
I was playing around with using conky to display a visual notification from a shell script.
Conky can read config files from stdin! That opens a lot of possibilities...
Proof of concept: find your mouse cursor - displays a red square around your pointer for 2 seconds. Requires xdotool.
#!/bin/sh
showtime=2 # seconds
eval $(xdotool getmouselocation --shell)
cat <<EOF | conky -c - & conkypid=$!
conky.config = {
own_window = true,
own_window_transparent = false,
own_window_colour = '#ff0000',
own_window_hints = 'undecorated,skip_taskbar,skip_pager,sticky',
update_interval = 1,
double_buffer = true,
minimum_width = 20,
minimum_height = 20,
maximum_width = 20,
alignment = 'top_left',
gap_x = $X,
gap_y = $Y,
draw_borders = true,
draw_outline = false,
draw_shades = false,
border_width = 4,
border_outer_margin = 2,
default_color = '#ffffff',
};
conky.text = [[]];
EOF
# total_run_times is unreliable, therefore:
sleep "$showtime"
kill $conkypid
Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos
Offline
I was playing around with using conky to display a visual notification from a shell script.
Conky can read config files from stdin! That opens a lot of possibilities...
Nice find!
---
Other topic:
sh -c '...some code...'
is sometimes useful when you want to run a snippet of shell code from a menu item, Thunar custom action or tint2 or any other situation that doesn't support shell syntax. sh (or bash if you need the extra features) is the command to run, and everything after the -c is just a parameter, so the launcher doesn't have to interpret it at all, just send it to the shell. It's highly advisable to wrap that shell code in single quotes so it won't be touched by anything else.
But this is already well known. Possibly slightly less well known is that you can pass positional parameters to that code snippet, just as if it was a function or separate script in a file.
Try this in a terminal:
sh -c 'echo "First: $1, Second: $2"' _ one two
Just a minute, what's that _ doing? That gets passed as $0, which usually means the shell name or script name. Here it's a placeholder (still accessible as $0) that gets used in error messages:
sh -c 'ecko "First: $1, Second: $2"' mycode one two
So sometimes there is value in using a meaningful string in the zeroth place, but usually _ is enough.
More reading:
https://superuser.com/questions/1526229 … ll-code-sh
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )
Offline