You are not logged in.

#2926 2017-03-01 06:18:37

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: Post your handy self made command line utilities

Lock screen on lid close. ( I had tried xss-lock from aur in past, but it appeared cpu intensive, at list on my laptop)

#!/bin/bash

xlock() {
    ( slock && xset dpms 0 0 300 ) &
    xset dpms 0 0 2
    xset dpms force off
}

while true;
do 
    if [[ $(< /proc/acpi/button/lid/LID0/state) = *closed ]] 
    then
	case $(< /sys/class/power_supply/AC/online) in
	    1)  ( [[ ! "$(pidof slock)" ]] && xlock ) ;;
	    0)	systemctl suspend ;;
	esac
    fi
    sleep 2;
done

This script needs to be run at startup.
Function xlock is inspired from user jakobm https://bbs.archlinux.org/viewtopic.php?id=114993

EDIT: change xlock to check pidof slock to avoid unnecessory calling slock every 2sec when lid is closed.
EDIT2: now suspend when lid close and no power_supply

Last edited by Docbroke (2017-03-13 05:33:23)

Offline

#2927 2017-03-02 06:15:12

cpdevlist
Member
Registered: 2016-09-24
Posts: 4

Re: Post your handy self made command line utilities

A little script to set up project file structure for a python data-crunching project. 
 
Inspired by the cookiecutter package in Python, but done in Bash, and modified a bit.
 
It will create some standard directories and files, then display what was created.

Everything is blank - you have to go in and start writing the files - but the aim is to get a project off the ground in an organized manner, and with some kind of plan.
 

#! /usr/bin/bash

# This script will set up a general folder structure for a python data project,
# and then display the structure for inspection or modification.

# Optional git initialization is available - including first commit and push to
# establish remote repo.

# Usage:  cd into folder that you want the project to be in, and run 
# $ mkproj <projectname>
 

mkdir $1 && cd $1           # Name of project
touch LICENSE               # Optional - useful for Github. 
touch README.md             # Github description, info, etc.
touch Makefile              # Regenerate only what is needed. 
touch devlog                # Development log and  TODO ... 
mkdir data
mkdir data/external         # Non-primary data - corroborating, external sources, etc.
mkdir data/interim          # Munged, cleaned, but not done
mkdir data/processed        # Data in final state
mkdir data/raw              # Immutable, original data (may need to be http links if large, etc.)
mkdir notebooks             # IpyNB's for literate step-throughs of reasoning and processing
mkdir reports               # finished output
mkdir reports/figures       # final saved figures, etc.
touch requirements.txt      # Python module requirements for pip
mkdir src               
touch src/__init__.py
touch src/acquire_data.py
touch src/process_data.py
mkdir src/visualizations
mkdir src/queries           # SQL, HiveQL, etc.
echo "Makefile" > .gitignore
echo "devlog" >> .gitignore
echo "bin/" >> .gitignore   # virtualenv stuff - don't backup to git
echo "lib/" >> .gitignore   # virtualenv stuff
echo "include/" >> .gitignore   # virtualenv stuff
echo "data/" >> .gitignore   # Don't commit all data to github (?)  (may be large, or may be link to S3, etc.) 

echo "Establish Git repo?: [y/N]"
read answer
if 
    [ -z $answer ] || [ $answer == 'n' ] || [ $answer == 'N' ]
then
    echo "Skipping git initialization."
else if
    [ $answer == 'y' ]
then
    echo "Initializing and pushing git repo"
    git init
    git remote add origin https://<username>@bitbucket.org/<username>/$1.git
    git commit -m "initial commit, repo setup"
    git push -u origin master
fi
fi

cd ..
echo "The following structure has been set up:"
printf "\n"
tree $1
printf "\n"
ls -lah --color=auto $1
printf "\n"

 
 
The output looks like this: 
 
 

$ mkproj example_project
Establish Git repo?: [y/N]
y
Initializing and pushing git repo
The following structure has been set up:

example_project
|-- LICENSE
|-- Makefile
|-- README.md
|-- data
|   |-- external
|   |-- interim
|   |-- processed
|   `-- raw
|-- devlog
|-- notebooks
|-- reports
|   `-- figures
|-- requirements.txt
`-- src
    |-- __init__.py
    |-- acquire_data.py
    |-- process_data.py
    |-- queries
    `-- visualizations

11 directories, 8 files

total 28K
drwxr-xr-x  6 lx lx 4.0K Mar  2 00:46 .
drwx------ 25 lx lx 4.0K Mar  2 00:46 ..
-rw-r--r--  1 lx lx   41 Mar  2 00:46 .gitignore
-rw-r--r--  1 lx lx    0 Mar  2 00:46 LICENSE
-rw-r--r--  1 lx lx    0 Mar  2 00:46 Makefile
-rw-r--r--  1 lx lx    0 Mar  2 00:46 README.md
drwxr-xr-x  6 lx lx 4.0K Mar  2 00:46 data
-rw-r--r--  1 lx lx    0 Mar  2 00:46 devlog
drwxr-xr-x  2 lx lx 4.0K Mar  2 00:46 notebooks
drwxr-xr-x  3 lx lx 4.0K Mar  2 00:46 reports
-rw-r--r--  1 lx lx    0 Mar  2 00:46 requirements.txt
drwxr-xr-x  4 lx lx 4.0K Mar  2 00:46 src

Offline

#2928 2017-03-02 07:10:10

parchd
Member
Registered: 2014-03-08
Posts: 421

Re: Post your handy self made command line utilities

Nice one, cpdevlist!

Offline

#2929 2017-03-02 20:03:32

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: Post your handy self made command line utilities

I finally got around to this one, on-board battery indicators for SIXAXIS controllers:

#!/bin/bash

# Show DualShock and SIXAXIS battery level using controller leds

for modid in $(ls /sys/class/leds/ | grep sony1 | sed 's/::.*//g'); do

  # USB connected controllers misreport as 100% and don't have "uniq" set to correlate to their module id.
  [[ -n $(cat /sys/module/hid_sony/drivers/hid\:sony/${modid}/input/input*/phys | grep usb) ]] && continue

  # Correlate between the part of sysfs that uses their bluetooth MAC and the part that uses their module id.
  power=$(cat "/sys/class/power_supply/sony_controller_battery_$(cat /sys/module/hid_sony/drivers/hid\:sony/${modid}/input/input*/uniq)/capacity")

  # Animated: Blank leds, count up to battery level, blink it twice
  case "$power" in
    100)
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      for i in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 1 > "${i}"; sleep 0.2; done
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      for i in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 1 > "${i}" & done
      sleep 0.2
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      for i in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 1 > "${i}" & done
      sleep 0.2
    ;;
    75)
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 4 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness"; ((i++)); sleep 0.2; done
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 4 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness" & ((i++)); done
      sleep 0.2
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 4 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness" & ((i++)); done
      sleep 0.2
    ;;
    50)
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 3 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness"; ((i++)); sleep 0.2; done
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 3 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness" & ((i++)); done
      sleep 0.2
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      i=1; while [ "${i}" -lt 3 ]; do printf 1 > "/sys/class/leds/${modid}::sony${i}/brightness" & ((i++)); done
      sleep 0.2
    ;;
    25)
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      printf 1 > "/sys/class/leds/${modid}::sony1/brightness"; sleep 0.2
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      printf 1 > "/sys/class/leds/${modid}::sony1/brightness" &
      sleep 0.5 # A little longer, as a warning.
      for n in $(ls /sys/class/leds/${modid}::sony*/brightness); do printf 0 > "${n}" & done
      sleep 0.1
      printf 1 > "/sys/class/leds/${modid}::sony1/brightness" &
      sleep 0.5 # A little longer, as a warning.
    ;;
  esac

  # Reset leds to display their controller's index
  player=$(("$(cat /sys/module/hid_sony/drivers/hid\:sony/${modid}/input/input*/js*/dev | sed 's/.*://g')"+1))

  for led in $(ls /sys/class/leds/${modid}::sony*/brightness); do
    if [ "$(printf "${led}" | grep -o sony[1-4] | sed 's/sony//g')" == "${player}" ]; then
      printf 1 > "${led}"
    else
      printf 0 > "${led}"
    fi
  done

done

Each controller connected by bluetooth will display its battery level with a utilitarianistically cute animation and then go back to its controller number.

Normally /sys/class/leds/${ModID}::sony[1-4]/brightness can only be written by root. This udev rule allows any user to set them:

KERNEL=="*sony[1-4]", SUBSYSTEM=="leds" RUN+="/usr/bin/chmod go+w /sys/class/leds/%k/brightness"

Last edited by quequotion (2017-03-03 07:43:22)

Offline

#2930 2017-03-02 20:55:09

cpdevlist
Member
Registered: 2016-09-24
Posts: 4

Re: Post your handy self made command line utilities

parchd wrote:

Nice one, cpdevlist!

Thanks, parchd - it will probably have to be adjusted for each project, but should serve as a decent starting point. wink

Offline

#2931 2017-03-02 21:12:09

parchd
Member
Registered: 2014-03-08
Posts: 421

Re: Post your handy self made command line utilities

cpdevlist wrote:

Thanks, parchd - it will probably have to be adjusted for each project, but should serve as a decent starting point. wink

Yeah, it has given me some new ideas about structuring such projects, which is great!

Offline

#2932 2017-03-05 21:28:41

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

Znotes, zenity based - memo/notes

Day before yesterday, I was totally bored, didn't knew what to do, so I fired up Geany *(wait a second.. Geany is always opened on my machine big_smile ) and crafted: znotes.

There are many variants of stcky notes for Linux. Each and every DE has it's own + million of independant. Somehow, xfce4-notes is most suitable to me, but, from time to time, it simply won't listen and by xsession startup, notes automatically appear on screen *(no matter if I told it to just place it self into tray/notification area) .. and that was a trigger for me to make something alike. 

This, however doesn't have anything to do with tray/notification area, nor with daemons of any kind, but it is all about one simple and small bash script that interracts with zenity dialog-box framework.

Script has only one argument and it is either new or list.

1) znotes new - will open up small (--forms) dialog where one can provide name for new file (blank spaces will be automatically replaced with underscore.) that shows in the list later on.

2) znotes list - will open up (--list) list of previously created files. Just for the record, `znote files` are ordinary extensionless plain text files.
Once when file is being selected from the list, than clicked on LOAD SELECTED, new text dialog (--text-info) where one can write/edit memo will appear. Both buttons BACK/MEMORIZE on that dialog will throw one back on the list with mere difference where MEMORIZE will save changes, while BACK - won't (logic for a Pulitzer D: ). If one want's to exit script, that's the list dialog window, and EXIT button. However, if nothing is selected from the list, LOAD SELECTED will do the same - exit. And that's not me, but impossibility to make desired button disabled unitl some list item is not being selected. It appears that Zenity don't have that implemented or I didn't payed enough attention regarding that.

Regarding configuration, there are three lines (19, 20, 21) in the script file.

19 - The directory where files are placed. The directory will be created automatically. Default one is ~/.local/share/znotes. If not appropriate - change it.
20 i 21 are for default width and height.

So.. copy all from code tag below into a new file under name znotes into $HOME/bin (or any of your primary `bin` ), than do chmod a+x ~/bin/znotes and that's it.
After that, commands znotes new and znotes list should give some screen result.

Note that notify-send is used on some places inside script, therefore libnotify, alongside main zenity package should be ready/installed as well. 

Here's the entire code:

#!/bin/bash

## Memos and notes based on Zenity; aka - `znotes`
#
# Licence: This file is restricted as much as openbox is. Go figure that.
# Author: Srđan Vukić <tux.lector@gmail.com>
# Date: 03.03.2017
#
# Program name
declare -r bsn=$(basename $0)

# Allow only one instance of znotes
bsnrun=$(ps h -C $bsn | grep -v $$ | wc -l);
[[ $bsnrun > 1 ]] && exit;

## Basic config
# Directory where znote files reside
# $bsn is this very script name
declare -r zn_work_loc=$HOME/.local/share/$bsn
declare -r zn_lw=400; # Default width
declare -r zn_lh=600; # Default height
## End of basic config

[[ -d $zn_work_loc ]] || mkdir -p $zn_work_loc
declare -a all_notes="$(ls -i ${zn_work_loc})"

# Display list of memo/notes
function zn_list
{
     local note;
     if [[ -z $all_notes ]]
     then zenity --info \
          --text="There are no memo/notes to view/edit.\
          \nYou may want to try with <b>$bsn new</b> command." 2> /dev/null

     else
          local zty=$(zenity --list \
          --radiolist --width=$zn_lw --height=$zn_lh \
          --title="Choose the note/memo to view/edit" \
          --column="Select" --column="Existing memo/note" $all_notes \
          --cancel-label="EXIT" --ok-label="LOAD SELECTED" 2> /dev/null)

          if [[ -z $zty ]]
          then
               if pgrep -x "$bsn" > /dev/null
               then pkill -f "$bsn"; fi
          else
               zn_view_edit $zty 2> /dev/null
          fi
     fi

}

# Make new znote
function _new
{
     local fnpath
     zty=$(zenity --forms \
     --show-header --width=400 \
     --title="Create new note" \
     --text="Provide a name for your note" \
     --add-entry="Name:" 2> /dev/null)

     case $? in
          0)
               if [[ -z $zty ]]
               then
                    notify-send \
                    --icon=face-worried \
                    --expire-time=500 'Name for new memo/note cannot be empty'
               else
                    zty=${zty// /_}; fnpath="$zn_work_loc/$zty"
                    if [[ -f $fnpath ]]
                    then
                         notify-send \
                         --icon=face-monkey \
                         --expire-time=500 'This memo/note already exists. Nothing happened.'
                    else
                         touch $fnpath
                         notify-send --icon=face-cool 'New memo/note successfully added!'
                    fi
               fi
          ;;
          1)
               notify-send \
                    --icon=face-sad \
                    --expire-time=500 "No memo/note has been added." ;;
          -1)
               notify-send \
                    --icon=face-devilish \
                    --expire-time=500 "Kung-fu error has occurred!" ;;
     esac
}

# View/edit selected note
function zn_view_edit
{
     local file=$zn_work_loc/$1
     local t_file="$file.$(date +%s%N).tmp"
     local act="--text-info \
     --title=$1 --filename=$file \
     --width=$zn_lw --height=$zn_lh \
     --editable --ok-label=MEMORIZE \
     --cancel-label=BACK"

     [[ ! -f $t_file ]] || rm -f $t_file
     zenity $act > $t_file

     if [[ $? -eq 0 ]]
     then
          cat $t_file > $file
          notify-send \
               --icon=face-smile-big \
               --expire-time=1000 "Memo/note '$1' saved"
          rm -f $t_file && sleep 0.1s
          zn_list
     elif [[ $? -eq 1 ]]
          then
          rm -f $t_file && sleep 0.1s
          zn_list
     else
          sleep 0.1s && rm -f $t_file
          fi

}

# Do `this` or `that`
case $1 in
     new)_new; ;;
     list) zn_list; ;;
     *)
          zenity --info \
          --text="Unknown parameter <b>'$1'</b>.\
          \n\nYou may want to try with\
          \n<b>$bsn new</b> or <b>$bsn list</b>\ncommands." 2> /dev/null
     ;;
esac

Last edited by tux.lector (2017-03-05 21:30:30)


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2933 2017-03-05 22:23:50

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: Post your handy self made command line utilities

tux.lector wrote:

Day before yesterday, I was totally bored, didn't knew what to do, so I fired up Geany ... and crafted: znotes.

Am confused: why choose the same name as the zNotes program which is part of XFCE?
It's an AUR package.

Last edited by ninian (2017-03-05 22:25:05)

Offline

#2934 2017-03-06 00:00:36

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

Because I didn't knew it exists. big_smile Also, main player is Zenity and memo/notes.. so I followed my own logic.

Note that that name of program I wrote depends on name of the script.

If you paste code content in a file called yabbadabbadooya and You chmod it... then, by calling yabbadabbadooya new or yabbadabbadooya list will produce the expected. `znotes`.

I have no emotions over that script, really. If that's a problem (because I know that I didn't wrote anything spectacular ) I can think of some other name.

Zenity_notes or even better zmemo ..

Now, someone should tell me that there already is zmemo .. hmm

Last edited by tux.lector (2017-03-06 00:05:15)


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2935 2017-03-06 10:19:57

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: Post your handy self made command line utilities

^ thanks for znotes, cool little script smile
the word "memorize" was not totally clear what it meant, I just think of it as "save note".
When you create a new note with  znote new, I would prefer that it makes the note after you type it the title AND opens it immediately to add stuff, instead of having to give it a title then type, znote list.

Edit: and thanks for the info below on what to change, didn't want to post a new reply in case someone complains about bumping the thread.

Last edited by chickenPie4tea (2017-03-07 15:52:47)


You can like linux without becoming a fanatic!

Offline

#2936 2017-03-06 13:45:04

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

Thnx chickenPie4tea! big_smile

Regarding memorize, yes. That's exactly what You've think of it. `save changes`. I simply love to goof with casual everyday expressions, can't help my self.
.. and You can change that >> line 103 >> --editable --ok-label=MEMORIZE

If You want your notes to load immediately after creating new, two simple steps are needed:

Step 1)

- MOVE (cut/paste) whole line 25 declare -a all_notes="$(ls -i ${zn_work_loc})" inside function zn_list just right below local note; (line 30)

# Display list of memo/notes
function zn_list
{
	local note;
	declare -a all_notes="$(ls -i ${zn_work_loc})"
	if [[ -z $all_notes ]]
...
...
...

Step 2)

- Line 79.

Add  && zn_view_edit $zty right after touch $fnpath so it looks like this:

touch $fnpath && zn_view_edit $zty

And that should do it. smile

Last edited by tux.lector (2017-03-06 13:45:24)


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2937 2017-03-08 11:54:50

greyltc
Member
Registered: 2015-04-15
Posts: 5

Re: Post your handy self made command line utilities

Hey Everyone,
Here's a script I've written to put a bootable Arch install into various media:

https://raw.githubusercontent.com/greyl … to-disk.sh

Offline

#2938 2017-03-08 12:57:14

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

^^

I don't want to say that there is no reason one should try your code above, but what's wrong with simple dd if/of/sync or maybe even better easy2boot ?

ps: don't get me wrong, I think the same for my `notes` over any other official sticky-notes application.


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2939 2017-03-08 13:19:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Post your handy self made command line utilities

Tux.lector, the purpose of that script is to install an arch linux system, not just write a live iso to a medium.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#2940 2017-03-08 13:26:41

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

Well, that's not an arch anymore. That's maybe the first step towards new distro based on Arch with him as a proud - founder. wink
Nevermind, I got the point.

Last edited by tux.lector (2017-03-08 13:28:00)


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2941 2017-03-08 13:37:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Post your handy self made command line utilities

How is that not arch?  Arch linux is meant to be installed, not just run from a live usb created with `dd` as you seem to be suggesting.  The right alternative would not be `dd` but would be the installation guide on the wiki.

I'd discourage anyone else from using that script for several reasons.  One of them certainly is that if they use someone else's script to install arch then we can't really help them here.  But many arch users have their own scripts used on their own system: sharing such things is exactly what this thread is for.

By all means provide feedback on the script.  I could start with noting a couple uses of `pacman -Sy <package>` which is dangerous.  Also it seems to depend on pacaur and does not check whether pacaur is actually available.  This later point however reinforces my previous point: this is not meant to be used by others, but is greyltc's own tool.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#2942 2017-03-08 14:43:43

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

The right alternative would not be `dd` but would be the installation guide on the wiki.

... ??!? ... USB flash installation media

Using dd
Note: This method is recommended due to its simplicity. If it does not work, switch to the alternative method #Using manual formatting below.

Should I maybe re-check my English as it really isn't my native, nor primary .. ? You are free to be the judge. Ok. Just forget about my first sentence in previous post (I will delete it if needed).
Concerning greyltc effort, I didn't had anything negative on my mind. greyltc is probably quite profound programmer/scripting architect I might guess, and I have nothing against new and well crafted distros.

And this `scripty` greyltc posted, just makes me think that one new and possibly good little distro is cooking. smile

Last edited by tux.lector (2017-03-08 14:44:10)


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2943 2017-03-08 14:47:49

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Post your handy self made command line utilities

tux.lector wrote:

The right alternative would not be `dd` but would be the installation guide on the wiki.

... ??!? ... USB flash installation media

I think Trilby means this: https://wiki.archlinux.org/index.php/In … _a_USB_key

Offline

#2944 2017-03-08 14:57:55

tux.lector
Member
From: Serbia
Registered: 2017-02-19
Posts: 17

Re: Post your handy self made command line utilities

^^

well.. If that's the case, maybe I really should re-check my English... roll


Did You knew that there are more airplanes in the oceans, than submarines in the sky .. ?
PHP powered applications pipe-menu for Openbox Window Manager

Offline

#2945 2017-03-08 17:50:37

greyltc
Member
Registered: 2015-04-15
Posts: 5

Re: Post your handy self made command line utilities

Trilby wrote:

How is that not arch?  Arch linux is meant to be installed, not just run from a live usb created with `dd` as you seem to be suggesting.  The right alternative would not be `dd` but would be the installation guide on the wiki.

I'd discourage anyone else from using that script for several reasons.  One of them certainly is that if they use someone else's script to install arch then we can't really help them here.  But many arch users have their own scripts used on their own system: sharing such things is exactly what this thread is for.

By all means provide feedback on the script.  I could start with noting a couple uses of `pacman -Sy <package>` which is dangerous.  Also it seems to depend on pacaur and does not check whether pacaur is actually available.  This later point however reinforces my previous point: this is not meant to be used by others, but is greyltc's own tool.

Thanks for the feedback!

You're right. There is one place I assume pacaur is installed, that's when the user requests an alarm (Arch Linux ARM) target (a lightly tested use case I must admit). I use pacaur to install qemu-user-static and binfmt-support so that when I chroot into the install I can use qemu to run the arm binaries that are in there. This should be fixed up now. AUR helpers like pacaur are only put into the install when the `ENABLE_AUR` variable is true (but it's true by default).

Also, I very much agree with your discouraging other people from just using this the way it is. There are a number of undocumented/unconfigurable "goodies" in my script that some may be unhappy to find in their install. For example, you might not want sshd running immediately on the first boot. I do though. This script represents how *I* like *my* Arch and I use it to help me quickly get a new machine to that point.

I posted my script here to get feedback and so that maybe others could borrow various bits from it and tailor it to their needs.

Offline

#2946 2017-03-08 19:10:43

escondida
Package Maintainer (PM)
Registered: 2008-04-03
Posts: 157

Re: Post your handy self made command line utilities

The following oneliner takes advantage of sam's structural (as opposed to line-based) regular expressions to replace my older, infinitely more complicated addressbook script. For those unfamiliar with rc, ^ is the string concatenation operator, and $"* means "the variable $*'s contents, as a single string"; $* contains the script's arguments.

#!/usr/bin/env rc

ssam -n 'x/(.+\n)+/ g/'^$"*^'/ p' $home/notes/addressbook

Given an addressbook that looks something like this,

name: J. Random Friend
phone: 555.555.5555
email: nobody@nowhere.com

name: Foobie Bletch
email: foobieb@nowhere.com
birthday: 31st February, 2038

place: Pizza Land
phone: 555.555.5554

it simply prints out the full stanza(s) matching whatever text I typed in ("J.", for instance, or "Pizza". If I want to get more complicated (e.g., extract emails to pass on to mail), that's trivially accomplished by piping to further text tools.

Offline

#2947 2017-03-09 10:08:31

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: Post your handy self made command line utilities

@escondida
what the hell is rc !


You can like linux without becoming a fanatic!

Offline

#2948 2017-03-09 10:27:08

Ambrevar
Member
Registered: 2011-08-14
Posts: 212
Website

Re: Post your handy self made command line utilities

A better shell...
Find it in the plan9port package.
https://en.wikipedia.org/wiki/Rc

Offline

#2949 2017-03-10 02:37:50

escondida
Package Maintainer (PM)
Registered: 2008-04-03
Posts: 157

Re: Post your handy self made command line utilities

chickenPie4tea: It's a shell developed by Tom Duff. It's Bourne-descended, but unlike sh itself or sh's other descendents, it has a simple and well-defined grammar (even created using lex!). Top-notch for scripting, and I find it very serviceable for interactive use.

As Ambrevar pointed out, it's available from plan9port. Its complete specifcation is here: http://doc.cat-v.org/plan_9/4th_edition/papers/rc

Share & enjoy!

Offline

#2950 2017-03-10 08:49:02

Awebb
Member
Registered: 2010-05-06
Posts: 6,611

Re: Post your handy self made command line utilities

Yay, another shell! Infinite diversity in infinite combinations. Surak is pleased.

Offline

Board footer

Powered by FluxBB