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

exec: long string

asked 2013-06-08 09:50:13 +0000

nichtleiter gravatar image

updated 2013-06-08 09:52:42 +0000

Hi there,

i simply want to open an ebook via i3-msg. To do so, i tried to execute the following command

i3-msg exec "xdg-open \"/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf\""

unfortunately it doesn't work and the command returns

ERROR: Your command: exec xdg-open "/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf"
ERROR:                                                                                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode'
[{"success":true},{"success":false,"parse_error":true,"error":"Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode'","input":"exec xdg-open \"/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf\"","errorposition":"                                                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}]

However if i execute a comparable command

i3-msg exec "xdg-open \"/home/johannes/Calibre Library/D. J. Amit/Statistical Physics an Introductory Course (164)/Statistical Physics an Introductory Course - D. J. Amit.pdf\""

the specified ebook is opened flawlessly. Of course both files exist.

Does anybody know how to successfully execute both commands with i3-msg exec?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-06-08 10:35:59 +0000

Michael gravatar image

As always in shell, problems can be solved by adding more quotes ;-).

i3-msg 'exec "xdg-open \"/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf\""'

Is what you want.

In the command you tried, you were quoting the second argument (xdg-open "/home…), but your shell is the thing which interprets that. Therefore, the shell ran

exec("i3-msg", "exec", "xdg-open \"…\"")

And therefore, i3 received

2013-06-08 12:31:46 - commands_parser.c:parse_command:209 - COMMAND: *exec xdg-open "/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf"*

Whereas with my command, the shell runs

exec("i3-msg", "exec \"xdg-open \\"…\\"\"")

Therefore, i3 receives

2013-06-08 12:31:56 - commands_parser.c:parse_command:209 - COMMAND: *exec "xdg-open \"/home/johannes/Calibre Library/Robert Faludi/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing (597)/Building Wireless Sensor Networks_ With ZigBee, XBee, Arduino, and Processing - Robert Faludi.pdf\""*

Which is properly quoted. The error message highlighted that the comma (,) in your filename is the problem — it separates i3 commands, which is why one filename worked and the other one did not.

edit flag offensive delete link more

Comments

Thanks a lot for your quick reply and the thorough explanation! You just made my day...

nichtleiter gravatar imagenichtleiter ( 2013-06-08 10:42:48 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-08 09:50:13 +0000

Seen: 253 times

Last updated: Jun 08 '13