Pipe file containing list of images to sxiv and reflect changes immediadly

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















Suppose I have a file images.txt which contains for example



image1.jpg
image2.jpg
image3.jpg


Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. I tried this one:



watch -n 0.1 'cat images.txt | sxiv -i -t'



But if I change the images.txt and save it (for example by adding or removing an image-filename), the thumbnail view in sxiv doesn't update.



I guess that there is something wrong with my pipe construction. What would be the correct way to do this?










share|improve this question






















  • Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

    – icarus
    Dec 31 '18 at 23:04











  • Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

    – student
    Dec 31 '18 at 23:22
















0















Suppose I have a file images.txt which contains for example



image1.jpg
image2.jpg
image3.jpg


Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. I tried this one:



watch -n 0.1 'cat images.txt | sxiv -i -t'



But if I change the images.txt and save it (for example by adding or removing an image-filename), the thumbnail view in sxiv doesn't update.



I guess that there is something wrong with my pipe construction. What would be the correct way to do this?










share|improve this question






















  • Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

    – icarus
    Dec 31 '18 at 23:04











  • Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

    – student
    Dec 31 '18 at 23:22














0












0








0








Suppose I have a file images.txt which contains for example



image1.jpg
image2.jpg
image3.jpg


Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. I tried this one:



watch -n 0.1 'cat images.txt | sxiv -i -t'



But if I change the images.txt and save it (for example by adding or removing an image-filename), the thumbnail view in sxiv doesn't update.



I guess that there is something wrong with my pipe construction. What would be the correct way to do this?










share|improve this question














Suppose I have a file images.txt which contains for example



image1.jpg
image2.jpg
image3.jpg


Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. I tried this one:



watch -n 0.1 'cat images.txt | sxiv -i -t'



But if I change the images.txt and save it (for example by adding or removing an image-filename), the thumbnail view in sxiv doesn't update.



I guess that there is something wrong with my pipe construction. What would be the correct way to do this?







command-line pipe cat watch






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 31 '18 at 22:45









studentstudent

6,9931763121




6,9931763121












  • Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

    – icarus
    Dec 31 '18 at 23:04











  • Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

    – student
    Dec 31 '18 at 23:22


















  • Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

    – icarus
    Dec 31 '18 at 23:04











  • Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

    – student
    Dec 31 '18 at 23:22

















Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

– icarus
Dec 31 '18 at 23:04





Maybe add a -p to tell sxiv not to cache the images? It would make a lot more sense to only run sxiv when something changes rather than 10 times a second.

– icarus
Dec 31 '18 at 23:04













Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

– student
Dec 31 '18 at 23:22






Ah, I just noticed that I have to close the sxiv window to update the changes in the images.txt file (then immediately a new window pops up with the updated content) if I use my pipe construct, but that's not exactly what I wanted.

– student
Dec 31 '18 at 23:22











1 Answer
1






active

oldest

votes


















1














Your existing construction will attempt to run cat images.txt | sxiv -i -t every tenth of a second. If sxiv takes longer than that to do whatever it does, things could get quite messy. You might be better off looking at a hash of a checksum of all of the images:



$ md5sum *.jpg | md5sum
4a009e73fb133d2d103dd2e65ef8c605 -


This takes a hash of all of the .jpg files, and makes a hash of that. This means that the sur-checksum will change if any of the images are changes, as well as if any are added or removed.



So we can do something like this:



#!/bin/bash
old_checksum="$(md5sum *.jpg | md5sum)"
while /bin/true; do
new_checksum="$(md5sum *.jpg | md5sum)"
if [[ "$new_checksum" != "$old_checksum" ]]; then
old_checksum="$new_checksum"
find . -maxdepth 1 -name *.jpg -print0 | xargs -0 sxiv -i -t
fi
sleep 1
done


Anytime anything changes, take a note of the new checksum, and re-run sxiv.



If you still want to keep your catalog of .jpg files in images.txt, this can be easily modified to use the contents of that file for creating the checksum and for providing arguments to xargs in lieu of find.






share|improve this answer

























  • Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

    – student
    Dec 31 '18 at 23:25












  • I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

    – student
    Dec 31 '18 at 23:34












  • I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

    – DopeGhoti
    Jan 1 at 21:44










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491834%2fpipe-file-containing-list-of-images-to-sxiv-and-reflect-changes-immediadly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your existing construction will attempt to run cat images.txt | sxiv -i -t every tenth of a second. If sxiv takes longer than that to do whatever it does, things could get quite messy. You might be better off looking at a hash of a checksum of all of the images:



$ md5sum *.jpg | md5sum
4a009e73fb133d2d103dd2e65ef8c605 -


This takes a hash of all of the .jpg files, and makes a hash of that. This means that the sur-checksum will change if any of the images are changes, as well as if any are added or removed.



So we can do something like this:



#!/bin/bash
old_checksum="$(md5sum *.jpg | md5sum)"
while /bin/true; do
new_checksum="$(md5sum *.jpg | md5sum)"
if [[ "$new_checksum" != "$old_checksum" ]]; then
old_checksum="$new_checksum"
find . -maxdepth 1 -name *.jpg -print0 | xargs -0 sxiv -i -t
fi
sleep 1
done


Anytime anything changes, take a note of the new checksum, and re-run sxiv.



If you still want to keep your catalog of .jpg files in images.txt, this can be easily modified to use the contents of that file for creating the checksum and for providing arguments to xargs in lieu of find.






share|improve this answer

























  • Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

    – student
    Dec 31 '18 at 23:25












  • I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

    – student
    Dec 31 '18 at 23:34












  • I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

    – DopeGhoti
    Jan 1 at 21:44















1














Your existing construction will attempt to run cat images.txt | sxiv -i -t every tenth of a second. If sxiv takes longer than that to do whatever it does, things could get quite messy. You might be better off looking at a hash of a checksum of all of the images:



$ md5sum *.jpg | md5sum
4a009e73fb133d2d103dd2e65ef8c605 -


This takes a hash of all of the .jpg files, and makes a hash of that. This means that the sur-checksum will change if any of the images are changes, as well as if any are added or removed.



So we can do something like this:



#!/bin/bash
old_checksum="$(md5sum *.jpg | md5sum)"
while /bin/true; do
new_checksum="$(md5sum *.jpg | md5sum)"
if [[ "$new_checksum" != "$old_checksum" ]]; then
old_checksum="$new_checksum"
find . -maxdepth 1 -name *.jpg -print0 | xargs -0 sxiv -i -t
fi
sleep 1
done


Anytime anything changes, take a note of the new checksum, and re-run sxiv.



If you still want to keep your catalog of .jpg files in images.txt, this can be easily modified to use the contents of that file for creating the checksum and for providing arguments to xargs in lieu of find.






share|improve this answer

























  • Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

    – student
    Dec 31 '18 at 23:25












  • I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

    – student
    Dec 31 '18 at 23:34












  • I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

    – DopeGhoti
    Jan 1 at 21:44













1












1








1







Your existing construction will attempt to run cat images.txt | sxiv -i -t every tenth of a second. If sxiv takes longer than that to do whatever it does, things could get quite messy. You might be better off looking at a hash of a checksum of all of the images:



$ md5sum *.jpg | md5sum
4a009e73fb133d2d103dd2e65ef8c605 -


This takes a hash of all of the .jpg files, and makes a hash of that. This means that the sur-checksum will change if any of the images are changes, as well as if any are added or removed.



So we can do something like this:



#!/bin/bash
old_checksum="$(md5sum *.jpg | md5sum)"
while /bin/true; do
new_checksum="$(md5sum *.jpg | md5sum)"
if [[ "$new_checksum" != "$old_checksum" ]]; then
old_checksum="$new_checksum"
find . -maxdepth 1 -name *.jpg -print0 | xargs -0 sxiv -i -t
fi
sleep 1
done


Anytime anything changes, take a note of the new checksum, and re-run sxiv.



If you still want to keep your catalog of .jpg files in images.txt, this can be easily modified to use the contents of that file for creating the checksum and for providing arguments to xargs in lieu of find.






share|improve this answer















Your existing construction will attempt to run cat images.txt | sxiv -i -t every tenth of a second. If sxiv takes longer than that to do whatever it does, things could get quite messy. You might be better off looking at a hash of a checksum of all of the images:



$ md5sum *.jpg | md5sum
4a009e73fb133d2d103dd2e65ef8c605 -


This takes a hash of all of the .jpg files, and makes a hash of that. This means that the sur-checksum will change if any of the images are changes, as well as if any are added or removed.



So we can do something like this:



#!/bin/bash
old_checksum="$(md5sum *.jpg | md5sum)"
while /bin/true; do
new_checksum="$(md5sum *.jpg | md5sum)"
if [[ "$new_checksum" != "$old_checksum" ]]; then
old_checksum="$new_checksum"
find . -maxdepth 1 -name *.jpg -print0 | xargs -0 sxiv -i -t
fi
sleep 1
done


Anytime anything changes, take a note of the new checksum, and re-run sxiv.



If you still want to keep your catalog of .jpg files in images.txt, this can be easily modified to use the contents of that file for creating the checksum and for providing arguments to xargs in lieu of find.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 1 at 11:13









student

6,9931763121




6,9931763121










answered Dec 31 '18 at 23:02









DopeGhotiDopeGhoti

43.8k55382




43.8k55382












  • Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

    – student
    Dec 31 '18 at 23:25












  • I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

    – student
    Dec 31 '18 at 23:34












  • I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

    – DopeGhoti
    Jan 1 at 21:44

















  • Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

    – student
    Dec 31 '18 at 23:25












  • I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

    – student
    Dec 31 '18 at 23:34












  • I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

    – DopeGhoti
    Jan 1 at 21:44
















Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

– student
Dec 31 '18 at 23:25






Thanks. Yes indeed I want to keep the "catalog" in "images.txt". The file will be auto updated in another step. How would your solution look like using "images.txt"? Just calculate the md5sum of images.txt and replace the find command with cat images.txt?

– student
Dec 31 '18 at 23:25














I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

– student
Dec 31 '18 at 23:34






I think you need a killall sxiv before the find line to prevent that a new instance of sxiv is started and also a & after -t?

– student
Dec 31 '18 at 23:34














I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

– DopeGhoti
Jan 1 at 21:44





I don't use a & to ensure that only one instance of find and therefore only one instance of sxiv is ever running at a time, which means a kill should not be needed.

– DopeGhoti
Jan 1 at 21:44

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491834%2fpipe-file-containing-list-of-images-to-sxiv-and-reflect-changes-immediadly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay