You are not logged in.
I haven't tried it yet, I'm supposed to be working too and the pdfs I had problems with are already converted.
Offline
I haven't tried it yet, I'm supposed to be working too and the pdfs I had problems with are already converted.
Okay, my thinking is that you'll still need the intermediate step as sed will try each command on every line - though address patterns may help. I think there's a command to skip to the next line, but can't remember it. So I can possibly think of 2 or 3 ways to get round it, but as I say I don't have time. I'll have a crack later, if I get a chance - it's been a while since I needed to do any sed, and I need a refresher.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
EDIT: sorry, I think I made a big mistake and rather than confuse people, it's better to delete what I wrote.
Now I have no idea what you guys are talking about.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
skanky wrote:EDIT: sorry, I think I made a big mistake and rather than confuse people, it's better to delete what I wrote.
Now I have no idea what you guys are talking about.
Sorry, I did try to go back and undo that but had lost it - I was too busy really to try an answer, but quickly fired one off, then thought better of it, then changed my mind and the whole thing was a mess.
I thought the sed line could be shortened to:
sed -i 's/0 0 0 sc/1 1 1sc/g; s/1 1 1 sc/0 0 0 sc/g' /tmp/pdfinvtmp
But see my above post for why I think that won't work.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
@parchd - right, I've had a chance to look at this properly. Sorry about the earlier debacle.
To summarise:
* You can amalgamate all the sed commands into one set of '...' (script).
* You can embed un-escaped new lines into the script, or use ;'s
* You are able to remove the intermediate step (see below)
* In GNU sed you can edit the tmp file in place
Here's the sed line taking all into account, and tested on a *very* simple test file:
sed 's/0 0 0 sc/1 1 1 sc/g;t; s/1 1 1 sc/0 0 0 sc/g' /tmp/pdfinvtmp
Note the "t" in there. That says that if the current line has been substituted, branch to the label, and if there is no label, to the end of the script.
Thus if we make a substitution on the current line we don't then substitute it back on the next command. If both settings are on the same line, it will fail to do the second substitution. I don't have pdftk installed so haven't checked. If that is the case, you could use one command to do both at the same time.
Again, sorry for the noise.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
I wrote this bash / zsh script for mass file numbering:
#!/bin/sh
#########
##
## Script for: Mass numbering of files
##
## It SHOULD prevent files from being destroyed. Try at your own risk.
## Use -t flag to just echo.
## Use -b d to print dir name
##
#########
usage () {
printf " Usage:\n"
printf " \e[1;36mnumb -b photo *.*\e[0m\n"
printf " ... will number all files in current dir Pics as photo_001, photo_002, preserving extensions\n"
printf " \e[1;36mnumb -c 12 -p 2 *.*\e[0m\n"
printf " ... will number all files in current dir Pics as Pics_12, Pics_13, preserving extensions\n"
}
PAD=3
COUNTER=1
RANGE=1
BASE=
while getopts "c::p::b::r::tsm" OPTIONS; do
case "${OPTIONS}" in
c)
COUNTER=${OPTARG}
;;
p)
PAD=${OPTARG}
;;
b)
if [ ${OPTARG} = d ]; then
BASE=${PWD##*/}
else
BASE=${OPTARG}
fi
;;
r)
RANGE=${OPTARG}
;;
t)
TRY=y
;;
s)
SWITCH=y
;;
m)
MANTAIN=y
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -lt 2 ]; then
usage
exit 1
fi
IFS=$'\n\t'
for OLDNAME in "$@"; do
if [ -n "$SWITCH" ]; then
NEWBASE=$(printf "%0${PAD}d_${BASE}" ${COUNTER})
elif [ -z "$SWITCH" ]; then
NEWBASE=$(printf "${BASE}_%0${PAD}d" ${COUNTER})
fi
if [ "$BASE" = "" ]; then
NEWBASE=$(printf "%0${PAD}d" ${COUNTER})
fi
if [ -n "$MANTAIN" ]; then
NEWNAME=${NEWBASE}_${OLDNAME}
else
NEWNAME=${NEWBASE}.${OLDNAME#*.}
fi
if [ -n "$TRY" ]; then
echo "mv --backup=nil ${OLDNAME} ${NEWNAME}"
else
mv --backup=nil ${OLDNAME} ${NEWNAME}
fi
let COUNTER=COUNTER+${RANGE}
done
######
## TODO:
## !!!! let it be recursive:
# MAXDIRDEPTH=1
# PAD=3
# for PATHSUBDIR in $(find -maxdepth ${MAXDIRDEPTH} -type d \( ! -name '.*' \)); do
# i=1;
# for PATHFILE in $(find "${PATHSUBDIR}" -maxdepth 1 -type f -name '*.*' | sort); do
# NEWBASE=$(printf "$(basename ${PATHFILE%/*})_%0${PAD}d" $i);
# echo "mv --backup=nil ${PATHFILE} ${PATHFILE%/*}/${NEWBASE}.${PATHFILE#$PATHSUBDIR/*.}";
# let i=i+1;
# done;
# done
##
##
## !!!! exit 1 when arguments are missing, etc
## !!!! update usage
######
Edit: removed bashisms (thanks @jasonwryan)
Edit 2: added options
Last edited by andya (2014-11-01 13:00:37)
Offline
You have a POSIX shebang, but are using bashisms (`echo -e`, `[[` and `$(..)`)...
Offline
Hey Jason, is "$(..)" not POSIX compliant?
Offline
Here's a quick watchdog script I made to emulate the functionality of the "Borderless Gaming" app on Windows. Just add it to your session and create a ~/.fullscreen.lst file with the titles of games you wish to be borderless fullscreen'd; one per line:
#!/bin/bash
#"Borderless Fullscreen" automatic toggling script
#By Xaero252 @ OCN (overclock.net)
#Distributed with the "don't be a douche" license
#Just don't try and claim you thought this up or whatever
#First, let's start a container loop with a sleep command to keep it from eating CPU.
while true; do
sleep 1 #We'll use 1 second, we don't want users to wait forever.
while read title; do
if ! xprop -name "$title" 2>/dev/null | grep -q _NET_WM_STATE_FULLSCREEN; then
wmctrl -r "$title" -b toggle,fullscreen
fi
done < ~/.fullscreen.lst #This way it's per-user.
done
The game must be run in Windowed mode for this to function as intended, but it fills the gap for a lot of games that don't have this functionality on Linux by default. (Stepmania, Minecraft, etc.)
Offline
I tend to have a bunch of 'screen' sessions running on a headless system. When I want to resume the 3rd session this alias in /etc/profile.bash let's me do that with minimal typing:
scr 2
Without arguments it just lists active sessions.
function scr(){
if [[ $# == 0 ]]
then
screen -list
else
var_screen_num="${1}"
arr_screen_id=($(screen -list | grep -Pzo '(\d+\.[a-z0-9-]+\.\S+)'))
screen -r "${arr_screen_id[$var_screen_num]}"
fi
}
Last edited by rwd (2014-11-09 21:30:24)
Offline
Hi all,
I'm creating a tool to use tcplay, I would like to add a keymaker too.
Because of the chmod 400 command, it could become a potential demolition tool.
I like to now if this is safe enough?
This tool is being sourced.
#!/usr/bin/env bash
# keymaker
# create a key file
# creator qinohe ed gmail
# Experimental, if you do not understand the tool, please don't use it.
# give name, location & byte! size for the keyfile
# keysize 32 byte=256 bit, 256 byte=2048 bit, ygtp ;-)
read -p "Give a path, where to create the keyfile? : " pathkey
if [ ! "$pathkey" ]; then
dialog --title "Message" --msgbox "No input, closing" 6 20
exit 1
fi
read -p "Name for the keyfile? e.g: tcplay_key : " namekey
if [ ! "$namekey" ]; then
dialog --title "Message" --msgbox "No input, closing" 6 20
exit 1
fi
read -p "Key size in bytes, e.g:32 byte = 256 bit keysize : " sizekey
if [ ! "$sizekey" ]; then
dialog --title "Message" --msgbox "No input, closing" 6 20
exit 1
fi
# If the dir. in pathkey doesn't exist, create it.
[ -d "$pathkey" ] || mkdir "$pathkey"
dd if=/dev/urandom of="$pathkey"/"$namekey" bs=1 count="$sizekey"
chmod 400 "$pathkey"/"$namekey"
dialog --title "Message" --msgbox "Your key is made" 6 20
exit 0
Edit: changed to a working one.
Last edited by qinohe (2014-11-18 18:35:49)
Offline
Create motivational word wallpaper every login.
#!/bin/bash
flat_colors() {
echo '
D24D57
F22613
FF0000
D91E18
96281B
EF4836
D64541
C0392B
CF000F
E74C3C
DB0A5B
FFECDB
F64747
F1A9A0
D2527F
E08283
F62459
E26A6A
DCC6E0
663399
674172
AEA8D3
913D88
9A12B3
BF55EC
BE90D4
8E44AD
9B59B6
446CB3
E4F1FE
4183D7
59ABE3
81CFE0
52B3D9
C5EFF7
22A7F0
3498DB
2C3E50
19B5FE
336E7B
22313F
6BB9F0
1E8BC3
3A539B
34495E
67809F
2574A9
1F3A93
89C4F4
4B77BE
5C97BF
4ECDC4
A2DED0
87D37C
90C695
26A65B
03C9A9
68C3A3
65C6BB
1BBC9B
1BA39C
66CC99
36D7B7
C8F7C5
86E2D5
2ECC71
16a085
3FC380
019875
03A678
4DAF7C
2ABB9B
00B16A
1E824C
049372
26C281
F5D76E
F7CA18
F4D03F
FDE3A7
F89406
EB9532
E87E04
F4B350
F2784B
EB974E
F5AB35
D35400
F39C12
F9690E
F9BF3B
F27935
E67E22
ececec
6C7A89
D2D7D3
EEEEEE
BDC3C7
ECF0F1
95A5A6
DADFE1
ABB7B7
F2F1EF
BFBFBF
'
}
motivational_words() {
echo '
COURAGE
FAITH
DEDICATION
DISCIPLINE
LOVE
FOCUS
SPIRIT
DETERMINATION
DO IT NOW!
DREAM
THINK
ACTION
HAPPINESS
I CAN
BELIEVE IN YOURSELF
NO FEAR
NO REGRET
WISE
TAKE RISK
AMBITION
INTELLIGENCE
DIGNITY
GET THINGS DONE
WORK HARD
SUCCESS
DO NOT WAIT
VISION
NO EXCUSE
'
}
rand_color=$(sort -R <(flat_colors) | head -1)
rand_word="$(sort -R <(motivational_words) | head -1)"
huruf=$(kata="$rand_word" ; echo "${#kata}")
awal_kata=$(let "n=800-(43*$huruf)" ; echo $n)
print_wall() {
cat<<EOF > $HOME/Pictures/motivational-wallpaper.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="1600"
height="900"
id="svg3088">
<defs
id="defs3090" />
<metadata
id="metadata3093">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-152.36218)"
id="layer1">
<rect
width="1600"
height="900"
rx="1"
ry="1"
x="0"
y="0"
transform="translate(0,152.36218)"
id="rect3102"
style="fill:#$rand_color" />
<text
x="$awal_kata"
y="650"
id="text3123"
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"><tspan
x="$awal_kata"
y="650"
id="tspan3125"
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans">$rand_word</tspan></text>
</g>
</svg>
EOF
}
print_wall "$@"
Offline
[Deleted]
Last edited by ackt1c (2014-11-19 20:13:26)
Offline
Pushed my tool, tcplay-dialog, to GitHub
It's not perfect, but does a nice job I think.
Have fun with it.
Offline
I really like remind, but not the gui frontends for it, so I decided to make something, wich does all I want it to do. It can only add or delete a reminder, or list all of them, it has a decent looking calendar in a xterm window. When a reminder activates it bees, and a xterm pops up whit the message and time of the reminder. cakwindow.sh spawns the calendar.
edit.sh
function new {
read -e -p "DATE: " -i "$(date +%Y) " date;
read -e -p "AT: " day;
read -e -p "body: " -i "MSG " body;
if [ -n "$day" ]; then
reminder="REM $date AT $day $body";
else
reminder="REM $date $body";
fi
echo "$reminder"
read -e -p "Ok?(Y,n)" ok;
if [ -z $ok ]; then
echo "$reminder" >> $1;
echo \""$reminder"\" added to $1;
reminder="$reminder - %a %3";
echo "$reminder" >> $2;
echo \""$reminder"\" added to $2;
fi
}
function del {
read -e -p "Delete what: " wut;
sed "/$wut/ c\\" $1 >> $1.tmp;
sed "/$wut/ c\\" $2 >> $2.tmp;
echo "Will delete:";
diff $1 $1.tmp;
echo ---------;
diff $2 $2.tmp;
read -e -p "Ok?(y,N)" ok;
if [ $ok == "y" ]; then
rm $1 $2;
mv $1.tmp $1;
mv $2.tmp $2
fi
rm $1.tmp $2.tmp;
}
function diffunc {
sed "s/ - %a %3//g" $2 >> $2.tmp;
diff $1 $2.tmp|less;
rm $2.tmp;
}
export COLUMNS
while [ -z "$quit" ]; do
clear;
remind -c+al4 -w$(tput cols) $1;
read -e -n 1 -p "(n)ew (d)el (l)ist di(f)f (q)uit - " thing;
case $thing in
n) new $1 $2;;
d) del $1 $2;;
l) cat $1|less;;
f) diffunc $1 $2;;
q) exit;;
esac
done
popup.sh
notify-send "$@";
xterm -class "remind-popup" -e "echo -e \\\\a \"$@\" ; read"
calwindow.sh
dir=`dirname $0`;
xterm -name remterm -class remterm -e "remind -z1 '-k./$dir/popup.sh %s' $dir/popup.rem & ./$dir/edit.sh $dir/cal.rem $dir/popup.rem"
Offline
Started working on implementing the features of the Windows puush client:
#!/bin/bash
scrot -u /tmp/puushscrot.png
puush /tmp/puushscrot.png | grep http | tr -d '\n' | xclip -selection c.
wait
notify-send "Puush Complete!"&
aplay -D default ~/.sounds/chime.wav
rm /tmp/puushscrot.png
Obviously you can change this however you like, this one emulates the functionality of capturing the current window, uploading the capture and placing the resulting url in your clipboard, as well as the "chime" feature (change the sound path to whatever sound you prefer, or remove it altogether. This also sends a libnotify alert when the upload is complete so the audible alarm is not needed.
Last edited by Xaero252 (2014-11-20 23:02:49)
Offline
Here's another puush script, this one notifies you on start and stop, and toggles all in one. It's for recording the current window.
Dependencies:
puush script
ffmpeg
xdotool
xorg-xwininfo
libnotify
Keybind this script to whatever key you wish to toggle recording. When you press that key, the script will let you know it has started recording video. It'll continue to record video until you press that key again, at which point it will let you know that it has stopped recording video, and then alert you one more time to let you know when the URL is ready to be pasted for viewing.
Example output video: http://puu.sh/cZqiI/d67dbd6c94.mp4
#!/bin/bash
EXISTS=0
if [ -f ~/.record ]; then
EXISTS=1
fi
echo $EXISTS
if [ $EXISTS -eq 0 ];then
touch ~/.record
#Below Snippet taken from:
#http://ur1.ca/iu5rm
# Get the coordinates of the active window's
# top-left corner, and the window's size.
# This excludes the window decoration.
unset x y w h
eval $(xwininfo -id $(xdotool getactivewindow) |
sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
-e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
-e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
-e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
echo -en "$x $y $w $h" "\r\n"
#End Snippet
#Now that we know where the current window is, and how big it is
#we can use this to record the window - but only if it doesn't move
##FIXME - DOES NOT FOLLOW ACTIVE WINDOW##
TMP_MP4=$(mktemp /tmp/outXXXXXXXXX.mp4)
size=$(echo $w"x"$h)
echo $size
notify-send -i gtk-media-record "Started Recording"
ffmpeg -y -video_size $size -framerate 30 -f x11grab -i $DISPLAY+$x,$y -vcodec libx264 -preset ultrafast $TMP_MP4&
FFMPEG_PID=$!
while [ -f ~/.record ];do
sleep 0.05
done
kill $FFMPEG_PID #kill ffmpeg, the .record file has been removed.
wait
puush $TMP_MP4 | grep http | tr -d '\n' | xclip -selection c. #push and copy to clipboard
wait
notify-send -i media-playlist-shuffle "Puush Complete!"& #Visual Notification
mpg123 ~/.sounds/puush.mp3 #Audible Notification
rm $TMP_MP4 #cleanup
else
notify-send -i gtk-media-stop "Stopped Recording"
rm ~/.record
fi
EDIT1: Fixed video output URL (I deleted it from Puush unintentionally when clearing out old things) I'll be revising this with Jason's input on using more quotes as well as some new features that made sense as I used it more. I'll also be using more variables and such.
Last edited by Xaero252 (2014-11-21 06:55:15)
Offline
Offline
Made myself a little script which adds current cover to my desktop wallpaper leaving the previous one intact, so it creates a playlist history on my wallpaper.
Code is ugly, but works:
#!/bin/bash
source $HOME/.config/kava/config
main () {
feh --bg-scale "$image"
cp "$image" $HOME/.config/kava/wally_temp.jpg
image_temp="$HOME/.config/kava/wally_temp.jpg"
while true; do
current="$(mpc current --format '%artist% - %album%')"
for ((i=0; i < ${#coordinates[@]}; i++)); do
mpc idle player>/dev/null 2>&1
sleep 1
if [[ -z $(mpc current) ]]; then
:
elif [[ $(mpc current --format '%artist% - %album%') == "$current" ]]; then
:
else
dir="$(dirname "$(mpc current --format %file%)")"
cd "$mpdpath"/"$dir"
if [[ -a cover.png ]]; then
echo "Cover for \""$(mpc current -f '%artist% - %album%')"\" found, setting wallpaper..."
cp cover.png /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black +polaroid /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
rm /tmp/cover.png
elif [[ -a folder.jpg ]]; then
convert folder.jpg /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black +polaroid /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
elif [[ -a cover.jpg ]]; then
convert cover.jpg /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black +polaroid /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
else
getCover
fi
fi
done
done
}
getCover () {
if [[ $1 == "noset" ]]; then
cover=$(get-cover "$(mpc current -f %artist%)" "$(mpc current -f %album%)")
cd "$mpdpath"/"$dir"
if [[ $cover == "Fetch error." ]]; then
echo "...could not download cover for \""$(mpc current -f '%artist% - %album%')"\""
else
echo "...found cover, saving"
wget "$cover" -O cover>/dev/null 2>&1
fi
if [[ $(file --mime-type cover | awk '{ print $NF }') == "image/png" ]]; then
mv cover cover.png
elif [[ $(file --mime-type cover | awk '{ print $NF }') == "image/jpeg" ]]; then
mv cover cover.jpg
fi
else
cover=$(get-cover "$(mpc current -f %artist%)" "$(mpc current -f %album%)")
cd "$mpdpath"/"$dir"
if [[ $cover == "Fetch error." ]]; then
echo "...could not download cover for \""$(mpc current -f '%artist% - %album%')"\", setting placeholder image..."
convert -resize "$size" "$noimage" -bordercolor snow -background black -polaroid "$angle" /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
else
echo "...found cover, setting wallpaper"
wget "$cover" -O cover>/dev/null 2>&1
fi
if [[ $(file --mime-type cover | awk '{ print $NF }') == "image/png" ]]; then
mv cover cover.png
cp cover.png /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black -polaroid "$angle" /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
rm /tmp/cover.png
elif [[ $(file --mime-type cover | awk '{ print $NF }') == "image/jpeg" ]]; then
mv cover cover.jpg
convert cover.jpg /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black -polaroid "$angle" /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$i]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
rm /tmp/cover.png
fi
fi
}
reset () {
if [[ -z $(mpc current) ]]; then
echo "no song is playing, skipping..."
else
dir="$(dirname "$(mpc current --format %file%)")"
cd "$mpdpath"/"$dir"
mv folder.jpg cover.jpg>/dev/null 2>&1
mv folder.png cover.png>/dev/null 2>&1
mv cover.png cover.png.bak>/dev/null 2>&1
mv cover.jpg cover.jpg.bak>/dev/null 2>&1
getCover noset
if [[ -a cover.png ]]; then
rm -f cover.png.bak
else
rename .png.bak '.png' *.bak
fi
if [[ -a cover.jpg ]]; then
rm -f cover.jpg.bak
else
rename .jpg.bak '.jpg' *.bak
fi
fi
}
if [[ $1 == reset ]]; then
reset
else
main
fi
config file:
#!/bin/bash
# music directory has to match setting in mpd.conf
mpdpath=/path/to/music
# where to save wallpaper
wallpaper="$HOME/.config/kava/wallpaper"
# resolution of wallpaper
res="1920x1080"
# main image to embedded cover into
image="xc:black"
# size of cover image
size="300x300"
# image to use, if no cover is found
noimage="xc:black"
# placement of images, if defining several values kava will itterate through
# them with each new song.
# this example should be fine on a 1920x1080 monitor
coordinates=( "+1500+30" "+1500+150" "+1500+280" "+1500+410" "+1500+540" "+1500+670" "+1400+700" "+1270+700" "+1140+700" "+1010+700" "+880+700"
"+750+700" "+620+700" "+490+700" "+360+700" "+230+700" "+100+700" "+30+600" "+30+430" "+30+300" "+30+170"
"+100+30" "+230+30" "+360+30" "+490+30" "+620+30" "+750+30" "+880+30" "+1010+30" "+1140+30" "+1270+30" "+1400+30" )
Here is how it looks after a while:
Last edited by Rasi (2014-11-24 00:25:25)
He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.
Douglas Adams
Offline
@Rasi, very nice
Just a question, why this script, and not conky?
Offline
Rasi, you still have many redundant `if` checks. You're calling mpc and then doing nothing with the result.
Also using awk on the output of `file` instead of basic globs seems confused.
Edit: Although I think you haven't updated your post since you last tweaked it so it may not be representitive of the current code.
Last edited by Earnestly (2014-12-04 15:18:10)
Offline
I wanted to share this one-liner I use to list the certain properties of all packages installed:
function pkgprop(){ pacman -Qi | grep -E "^Name|^$*" | cut -d: -f2 | while read n ; do read v; echo -e "$n:\t$v"; done | column -ts $'\t' | sort -nk 2; }
It accepts any of the keys from `pacman -Qi` as key; for example pkgprop Installed Size lists
ca-certificates: 1.00 KiB
dnssec-anchors: 1.00 KiB
mozilla-common: 1.00 KiB
xorg-utils: 1.00 KiB
java-environment-common: 2.00 KiB
pambase: 2.00 KiB
xorg-font-utils: 4.00 KiB
systemd-sysvcompat: 5.00 KiB
...
while pkgprop Packager lists
a52dec: Allan McRae <allan@archlinux.org>
aalib: Eric Belanger <eric@archlinux.org>
abiword: Jan de Groot <jgc@archlinux.org>
acl: Thomas Bächler <thomas@archlinux.org>
acpid: Sébastien Luttringer <seblu@seblu.net>
adwaita-icon-theme: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
alsa-lib: Tobias Powalowski <tpowa@archlinux.org>
...
Sorting is attempted but unless you somehow make that configurable you'd have to choose between sorting numerical or alphabetically
Last edited by Spider.007 (2014-12-06 12:42:59)
Offline
Have a look at expac.
Offline
% expac -H M '%n: %m' # -H, human format: M = MiB. %n = name, %m = install size.
aalib: 0.31 MiB
acl: 0.28 MiB
acpi: 0.03 MiB
adwaita-icon-theme: 13.66 MiB
alsa-lib: 1.58 MiB
alsa-plugins: 0.25 MiB
alsa-utils: 1.81 MiB
antimicro-git: 2.85 MiB
apitrace: 12.13 MiB
[...]
You can add `-S` to get sync repo information as well. Very handy tool.
Last edited by Earnestly (2014-12-06 14:46:18)
Offline