You are not logged in.
I am using sxiv v1.1.1, how does this differ from:
'-r Search the given directories recursively for images to view.' ?
The only real difference would be that it only pulls from the dir you feed it and not any subdirs*. Mainly my goal was a single command that would take both a directory and an image file. [granted, I could've just added the r option to the Popen string in such a case, but I typically don't want to view the images in subdirs of a dir.]
*assuming I've actually understood `sxiv -r dir/` correctly and it collates all photos in dir and any subdirs for viewing.
Offline
If you want the images in a specific dir, try:
$ sxiv -q /path/to/images/*Last edited by steve___ (2014-08-27 17:52:13)
Offline
If you want the images in the current dir, try:
$ sxiv -q *
Functionally, that's what the script does, except you feed it 'dir' instead of 'dir/*', which is easier on the fingers with auto-completion 
Offline

EDIT: This has been superseded by makepkg-optimize, following the acceptance of my revised proposals for libmakepkg.
I've kept this to myself long enough; it's one of my favorites:
This wrapper works with makepkg and all aur-helpers!
qqbuild
#! /bin/bash
while (( "$#" )); do
  case "$1" in
    pgo) # Build with profile generation or rebuild using profile data
      if [ ! -d "$PWD/profile" ]; then
        mkdir "$PWD/profile"
        QQPGO="-fprofile-generate -fprofile-dir=$PWD/profile"
        QQPGOLDFLAGS="-lgcov"
      else
        [[ ! -d "$PWD/profile.used" ]] &&  mv "$PWD/profile" "$PWD/profile.used"
        QQPGO="-fprofile-correction -fprofile-use -fprofile-dir=$PWD/profile.used"
      fi
      shift
    ;;
    cflags) # inject a particular -cflag "-or -several -cflags"
      QQEXTRACFLAGS="$2"
      shift 2
    ;;
    ldflags) # inject a particular ,-ldflag ",-or,-several,-ldflags"
      QQEXTRALDFLAGS="$2"
      shift 2
    ;;
    makeflags) # inject a particular --makeflag "-or --several --makeflags"
      QQEXTRAMAKEFLAGS="$2"
      shift 2
    ;;
    nolto) # disable link-time-optimization
      QQNOLTO="yes"
      shift
    ;;
    graphite) # vector optimizations
      QQGRAPHITE="-fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize"
      shift
    ;;
    rice) # maximum tuning
      QQRICECFLAGS="-Ofast -fbranch-target-load-optimize2 -fcx-fortran-rules -fdata-sections -ffloat-store -fgcse-las -fgcse-sm -fipa-pta -floop-nest-optimize -fmodulo-sched -fmodulo-sched-allow-regmoves -fno-enforce-eh-specs -funsafe-math-optimizations -fno-threadsafe-statics -fnothrow-opt -fno-var-tracking-assignments -fomit-frame-pointer -fopenmp -fPIC -freg-struct-return -freschedule-modulo-scheduled-loops -fsched-pressure -fsched-spec-load -fsched-spec-load-dangerous -fsched-stalled-insns=0 -fsched2-use-superblocks -fselective-scheduling -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fshort-wchar -ftree-parallelize-loops=$(grep "^core id" /proc/cpuinfo | sort -u | wc -l) -ftree-lrs -ftree-vectorize -fvariable-expansion-in-unroller -maccumulate-outgoing-args -Wno-sizeof-pointer-memaccess" # -fmerge-all-constants
      QQRICELDFLAGS="-lpthread -lgomp" #,-shared
      shift
    ;;
    help|*)
      [[ ! "${1}" == "help" ]] && \
        break
      echo -e  "\nTweak build environment:\n"
               "$0 pgo - build with profile generation or rebuild using profile data\n"
               "$0 cflags - inject a particular -cflag \"-or -several -cflags\"\n"
               "$0 ldflags - inject a particular ,-ldflag \",-or,-several,-ldflags\"\n"
               "$0 makeflags - inject a particular --makeflag \"-or --several --makeflags\"\n"
               "$0 nolto - disable link-time optimization\n"
               "$0 graphite - enable vector optimizations\n"
               "$0 rice - maximum tuning\n"
               "\nOptions are stackable:\n"
               "\n$0 rice pgo makeflags -j1\n"
      exit
    ;;
  esac
done
#export QQCPPFLAGS #unimplemented
export QQCFLAGS="$QQEXTRACFLAGS $QQRICECFLAGS $QQPGO $QQGRAPHITE"
export QQCXXFLAGS="$QQCFLAGS"
export QQLDFLAGS="$QQEXTRALDFLAGS $QQRICELDFLAGS $QQPGOLDFLAGS"
export QQMAKEFLAGS="$QQEXTRAMAKEFLAGS"
[[ -n "${QQNOLTO}" ]] && export QQNOLTO
#printf "qqcxxflags:$QQCFLAGS\nqqldflags:$QQLDFLAGS\nqqmakeflags:$QQMAKEFLAGS\nqqnolto:$QQNOLTO\n" #debug
command -- "$@"Also append this to makepkg.conf, to enable LTO by default:
#-- Link-Time Optimization
if [ ! "$QQNOLTO" == "yes" ]; then
  CFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
  CXXFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
  LDFLAGS+=" $CFLAGS -fuse-linker-plugin"
  LTOPLUGIN="$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')"
  ARFLAGS+=" --plugin $LTOPLUGIN"
  RANLIBFLAGS+=" --plugin $LTOPLUGIN"
  NMFLAGS+=" --plugin $LTOPLUGIN"
fiUse qqbuild to wrap something that builds a package:
qqbuild nolto rice makepkgSee "qqbuild help" for details!
EDIT: I have proposed integrating the build options from qqbuild into makepkg itself on the pacman-dev mailing list.
EDIT again: But my proposal was rejected because makepkg is getting simplified; fork that!
Last edited by quequotion (2019-07-11 08:39:10)
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline

Hmm, the idea is quite similar to what I did in FFcast. One tip,
- $@
+ command -- "$@"First, you need to quote "$@" for word splitting to work properly.
Second, prefixing `command` will avoid e.g. internal functions from being run.
Last edited by lolilolicon (2014-08-28 07:39:09)
This silver ladybug at line 28...
Offline

First, you need to quote "$@" for word splitting to work properly.
Second, prefixing `command` will avoid e.g. internal functions from being run.
Thanks! I wasn't thinking about preventing internal functions; have to keep in mind someone will always be able to find some way to break something!
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline

Awk script to format iw scan output:
iwscan.awk
/^BSS/ {
        MAC = $2
        aps[MAC]["enc"] = "Open"
}
$1 == "SSID:" {
        aps[MAC]["SSID"] = $2
}
$1 == "freq:" {
        aps[MAC]["freq"] = $NF " MHz"
}
$1 == "signal:" {
        aps[MAC]["sig"] = $2 " " $3
}
$1 == "WEP:" {
        aps[MAC]["enc"] = "WEP"
}
$1 == "RSN:" {
        aps[MAC]["enc"] = "RSN"
}
$1 == "WPA:" {
        aps[MAC]["enc"] = "WPA"
}
END {
        printf "%-32s %-16s %-16s %-16s\n",
                "SSID", "Frequency", "Signal", "Encryption"
        for (ap in aps) {
                printf "%-32s %-16s %-16s %-16s\n",
                        aps[ap]["SSID"], aps[ap]["freq"], aps[ap]["sig"], aps[ap]["enc"]
        }
}output
dfr-laptop dev # iw wlan0 scan | awk -f ./iwscan.awk
SSID                             Frequency        Signal           Encryption
saitaOpen                        2412 MHz         -74.00 dBm       Open
oppilas                          2412 MHz         -77.00 dBm       RSN
NADIA                            2462 MHz         -89.00 dBm       RSN
SoneraGateway00-22-07-ED-79-95   2412 MHz         -89.00 dBm       WPA
wEKSOTE                          2412 MHz         -76.00 dBm       RSN
SaitaBYOD                        2412 MHz         -75.00 dBm       RSN
wULAPPA                          2412 MHz         -75.00 dBm       RSNLast edited by defer (2014-08-29 13:53:28)
Offline

Awk script to format iw scan output:
But be careful. Note the last line in the output of iw help
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline

You could just do it in C - wireless_tools's iwlib should do all that. Here's a starter extracted from swifer:
// compile: gcc -o this_file this_file.c -liw
#include <stdio.h>
#include <iwlib.h>
int main(int argc, const char **argv) {
	if (argc < 2 || (getuid() != 0)) return 1;
	wireless_scan_head context;
	wireless_config cur;
	int we_ver, skfd;
	we_ver = iw_get_kernel_we_version();
	skfd = iw_sockets_open();
	iw_get_basic_config(skfd, (char *) argv[1], &cur);
	iw_scan(skfd, (char *) argv[1],we_ver, &context);
	wireless_scan *ws;
	for (ws = context.result; ws; ws = ws->next) {
		if (ws->b.key_flags == 2048) printf("X ");
		else printf("o ");
		printf("%2d%% %s\n", 100 * ws->stats.qual.qual / 70, ws->b.essid);
	}
	iw_sockets_close(skfd);
	return 0;
}"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline

If you are using gawk, you can use the switch statement:
    {
    switch ($1) {
          case /SSID/:
             aps[MAC]["SSID"] = $2
             break
          case /freq/: 
             aps[MAC]["freq"] = $NF " MHz"
             break
          case /signal/: 
             aps[MAC]["sig"] = $2 " " $3
             break
          case /WEP/: 
             aps[MAC]["enc"] = "WEP"
             break
          case /RSN/: 
             aps[MAC]["enc"] = "RSN"
             break
          case /WPA/: 
             aps[MAC]["enc"] = "WPA"
            }
     }Offline

Or just use `wpa_cli scan` and `wpa_cli scan_results` which gives you much better information anyway.
Offline

Or just use `wpa_cli scan` and `wpa_cli scan_results` which gives you much better information anyway.
You're right. wpa_cli is better.
Offline
I always forget to clean up after pacman. This script can be run from a cron job or systemd service or standalone. It finds files left by pacman and emails a list of users set in the $recips variable.
The script writes directly to the $recips mail spool in mbox format. This allows receipt of reminder emails without requiring an mta.
#! /bin/bash
[[ $EUID -eq 0 ]] || { printf "%s \n" "ERROR: pac_find must be run as root"; exit 1; }
result_string=$(sudo /usr/bin/find /boot /etc /home /lib /opt /root /usr -regextype posix-egrep -regex '.*/.*\.pac(new|orig|save)' -print0 | /usr/bin/sed 's/\x0/\|/g')
declare -a recips=('chris' 'root')
if [[ -n "$result_string" ]]; then
	for i in "${recips[@]}"; do
		c_time=$(/usr/bin/env LC_ALL=C /usr/bin/date +%c)
		mbox="/var/spool/mail/$i"
		/usr/bin/flock $mbox echo -e "From systemd@${HOSTNAME} ${c_time}\nDate: $c_time \nFrom: systemd@${HOSTNAME} \nTo: ${i}@${HOSTNAME} \nRe: Pacman Files \nThe following pacman files have been found: \n\t$(echo $result_string | /usr/bin/sed 's/|/\n\t/g')\n" >> $mbox
	done
fiOnline
It's best to deal with pacnew files ASAP i.e. right after you updated your system.
Offline
I would like to share a script that can list the installed but renamed or removed AUR packages.
The following script intends to display a list of installed packages, but not found in either AUR or official repositories. They are either removed or renamed. package-query is required.
#!/bin/bash
#Get the packages
packages=(`pacman -Qmq | sort`)
#For each of the package, check with the AUR
packagesStr=''
for x in ${packages[@]} ; do
  packagesStr+="'$x' "
done
packagesOnAur=(`/bin/sh -c "package-query -A -f '%n' $packagesStr | sort"`)
#As the rule of thumb, the installed packages are more than packages checked in the AUR
for((i=0;i<${#packagesOnAur[@]};i++)) ; do
  j=0
  while [[ $j -lt ${#packages[@]} ]] ; do
    if [[ ${packagesOnAur[$i]} == ${packages[$j]} ]] ; then
      unset packages[$j]
      packages=("${packages[@]}")
      break
    fi
    ((j++))
  done
done
for x in ${packages[@]} ; do
  echo $x
doneLast edited by allencch (2014-09-05 05:18:23)
Offline

Merging with Command Line utilities...
Offline
#!/bin/bash
PARSE="`echo "$*" | sed s/" "/"+"/g`"
/usr/bin/links http://www.google.com/search?q=$PARSEA little macro to make links/lynx google something real quick.
#!/bin/bash
if [ "$1" == "" ]; then
	PARSE="ssh"
else
	PARSE="$1"
fi
i=0;
while [ ! "`screen -ls | grep $PARSE`" == "" ]; do
	i=`expr $i \+ 1`;
	if [ $i == 1 ]; then
		screen -S $PARSE -p 0 -X stuff ' ';
	fi;
	if [ $i == 60 ]; then
		i=0;
	fi;
	sleep 1;
doneRepeatedly type spaces into an ssh session run through screen, one per minute. If you like to use ssh and screen for tunneling and get the same issue I do, where ssh cuts itself off after a while, this is useful.
Last edited by Thisguy_ (2014-09-08 14:48:22)
Offline

Repeatedly type spaces into an ssh session run through screen, one per minute. If you like to use ssh and screen for tunneling and get the same issue I do, where ssh cuts itself off after a while, this is useful.
You need to look at ClientAlive{Interval,Countmax} and TCPKeepAlive in sshd_config 
Scott
Offline
Unfortunately, I don't have access to sshd on the servers that are cutting me off 
(In the case that you accidentally slipped the D into that file name and I'm just pointing out your mistake by one of my own, I'll check ssh_config.)
EDIT: Edited for clarity. I have an account, obviously. But I'm not root or powerful.
Last edited by Thisguy_ (2014-09-08 15:25:10)
Offline
I wanted a general-purpose script to run similar commands in parallel. I came up with this, and welcome people's suggestions for improvements.
#!/usr/bin/env zsh
set -ue
adding_to_command=1
argsets=( )
command=( )
for arg in "$@"; do
  if [[ "$arg" = "--" ]]; then
    adding_to_command=0
  elif [[ "$adding_to_command" -eq 1 ]]; then
    command+=( "$arg" )
  else
    argsets+=( "$arg" )
  fi
done
unset arg 
for argset in "${argsets[@]}"; do
  printf "%s\0" "$argset"
done | xargs -P4 -n1 -0 "${command[@]}"
unset argsetHere's how it works:
$ juxt echo hello, -- "world" "asynchronous processing"
hello, asynchronous processing
hello, worldOffline

dz, see GNU Parallel
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I wanted a general-purpose script to run similar commands in parallel. I came up with this, and welcome people's suggestions for improvements.
Here's how it works:
$ juxt echo hello, -- "world" "asynchronous processing" hello, asynchronous processing hello, world
The above could have been accomplished using
echo "world\nasynchronous processing" | parallel "echo hello, {}"Using GNU Parallel.
Offline

For another fun approach, you can abuse make as it naturally processes in parallel:
$ cat Makefile
%:
	@echo hello, $@
$ make world "asynchronous processing"
hello, world
hello, asynchronous processingEDIT: Even better:
$ cat Makefile 
CMD   ?= echo
%:
	@${CMD} $@
$ CMD="echo hello," make world "asynchronous processing"
hello, world
hello, asynchronous processing"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
dz wrote:I wanted a general-purpose script to run similar commands in parallel. I came up with this, and welcome people's suggestions for improvements.
Here's how it works:
$ juxt echo hello, -- "world" "asynchronous processing" hello, asynchronous processing hello, worldThe above could have been accomplished using
echo "world\nasynchronous processing" | parallel "echo hello, {}"Using GNU Parallel.
At least in bash, you have to use 'echo -e' to interpret the '\n':
$ echo "world\nasynchronous processing" | parallel "echo hello, {}"
hello, world\nasynchronous processing
$ echo -e "world\nasynchronous processing" | parallel "echo hello, {}"
hello, world
hello, asynchronous processingOffline
At least in bash, you have to use 'echo -e' to interpret the '\n':
$ echo "world\nasynchronous processing" | parallel "echo hello, {}" hello, world\nasynchronous processing $ echo -e "world\nasynchronous processing" | parallel "echo hello, {}" hello, world hello, asynchronous processing
...I should probably sit down and learn bash one day, since everybody seems to use it. Using zsh makes me lazy.
Also, a neater way of doing this using parallel is
parallel "echo hello, " ::: world "asynchronous processing"Offline