The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Run a command with i3-nagbar , that has apostrophes in it..

asked 2015-09-17 17:04:20 +0000

a_flamethrowing_duck gravatar image

updated 2015-09-17 17:48:37 +0000

If I were to run a command with i3-nagbar, that contains apostrophes itself, how would I validate those apostrophes?

e.g. i3-nagbar -t warning -m 'Selection or active window (4 sec. delay)' -b 'selection' 's crot -s \'/home/user/Pictures/screenshots/%H%M_%d%m%Y_$wx$h.png\'' -b 'active window' 'scrot -u -d 4 \'/home/user/Pictures/screenshots/%H%M_%d%m%Y_$wx$h.png\''

edit: For instance I were to use bindsym to run i3-nagbar, which will then run a command that requires quoting again (example below). Can I validate the apostrophes with a backslash?

bindsym Shift+Print exec "i3-nagbar -t warning -m 'Selection or active window (4 sec. delay)' -b 'selection' 'scrot -s \'/home/user/Pictures/screenshots/%s_%H%M_%d%m%Y_$wx$h.png\'' -b 'active window' 'scrot -u -d 4 \'/home/user/Pictures/screenshots/%H%M_%d%m%Y_$wx$h.png\''"

edit 2: I've tried to use " for the directory used for scrot and \' both doesn't seem to work for me.

edit retag flag offensive close merge delete

Comments

Why not just use double quotes to quote the command and single quotes to quote the command inside?

Airblader gravatar imageAirblader ( 2015-09-17 17:14:51 +0000 )edit

Also, feel free to use i3-nagbar for this, but using a binding mode might be a bit more "friendly".

Airblader gravatar imageAirblader ( 2015-09-17 17:15:44 +0000 )edit

I am planning to bind Shift + Printscreen for this.. I'll try to use the double quotes, thank you!

a_flamethrowing_duck gravatar imagea_flamethrowing_duck ( 2015-09-17 17:20:57 +0000 )edit

I meant use a binding mode (not a binding) to choose whether the active window or selection should be used. Then it would integrate into i3bar and not launch i3-nagbar, which is a fairly ugly tool we only use for errors.

Airblader gravatar imageAirblader ( 2015-09-17 21:16:20 +0000 )edit

How could I use i3bar in this case?

a_flamethrowing_duck gravatar imagea_flamethrowing_duck ( 2015-09-18 09:17:24 +0000 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2015-09-18 09:46:27 +0000

Airblader gravatar image

updated 2015-09-22 18:33:57 +0000

Since this doesn't fit into a comment:

set $mode_scrot [s]election | [a]ctive window
mode "$mode_scrot" {
    bindsym --release s mode "default", exec --no-startup-id scrot -s /home/user/Pictures/screenshots/screenshot-$(date +%Y-%m-%d_%H-%M-%S).png
    bindsym --release a mode "default", exec --no-startup-id scrot -u -d 4 /home/user/Pictures/screenshots/screenshot-$(date +%Y-%m-%d_%H-%M-%S).png
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+Shift+s mode "$mode_scrot"
edit flag offensive delete link more

Comments

looks really good, but doesn't seem to work for me. The question pops up but on selection of either `s` or `a` nothing happens..

a_flamethrowing_duck gravatar imagea_flamethrowing_duck ( 2015-09-18 19:05:27 +0000 )edit

@a_flamethrowing_duck Does the target folder exist?

Airblader gravatar imageAirblader ( 2015-09-18 20:45:41 +0000 )edit

I've tried the scrot commands by themselves to test if they work and they do..

a_flamethrowing_duck gravatar imagea_flamethrowing_duck ( 2015-09-19 10:24:46 +0000 )edit

If the folder exists, this works fine for me. Can you provide a log file please?

Airblader gravatar imageAirblader ( 2015-09-19 14:32:10 +0000 )edit

the only problem i seem to have is with the `date` command.. The active window seems to work, but the selection doesn't. I'll try to work that out.. will report if I have a solution

a_flamethrowing_duck gravatar imagea_flamethrowing_duck ( 2015-09-19 18:15:00 +0000 )edit
0

answered 2015-09-22 13:37:14 +0000

a_flamethrowing_duck gravatar image

I've been trying to get the suggestion by Airblader to work for me, as well as I tried with my initial intention..

I've come to the conclusion that I don't even need the apostrophes in scrot.. but it still won't work. The active window screenshot works fine, just the selection won't.

set $mode_scrot [s]election | [a]ctive window
mode "$mode_scrot" {
    bindsym s mode "default", exec --no-startup-id scrot -s /home/user/Pictures/screenshots/%s_%H%M_%d%m%Y_$wx$h.png
bindsym a mode "default", exec --no-startup-id scrot -u -d 4 /home/user/Pictures/screenshots/%s_%H%M_%d.%m.%Y_$wx$h.png 
    bindsym Return mode "default"
    bindsym Escape mode "default"
    }   

bindsym $mod+Shift+s mode "$mode_scrot"
edit flag offensive delete link more

Comments

I have fixed my answer.

Airblader gravatar imageAirblader ( 2015-09-22 18:33:32 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-17 17:04:20 +0000

Seen: 153 times

Last updated: Sep 22