You are not logged in.

#1 2013-08-04 08:48:30

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 193

PKGBUILD with adjusting source code

Hi everyone.

The subject can be not so clear, but just have a look at dirty code below and my idea is obvious: I want to have PKGBUILD that has no "own" source files, but bases on code that belongs to another package. The main part is just to make some replacemet in files (in my case replace colors) to create new sets of GTK and icon themes:

# Mantainer: nBVCXz <nbvcxz@o2.pl>
# based on https://aur.archlinux.org/packages/gtk-theme-numix/ by Diego <cdprincipe@at@gmail@dot@com>

pkgname=numix-grey-theme
_theme=Numix
pkgver=1.9
pkgrel=1
pkgdesc="A flat and light theme with a modern look with grey look matching Lubuntu themes"
arch=('any')
url="http://satya164.deviantart.com/art/Numix-GTK3-theme-360223962"
license=('GPL3')
depends=('gtk-engine-murrine')
source=(https://github.com/shimmerproject/${_theme}/archive/v${pkgver}.tar.gz)

package() {
	
  install -d "$pkgdir/usr/share/themes/${_theme}-Grey"
  cp -rv ${srcdir}/${_theme}-${pkgver}/* "$pkgdir/usr/share/themes/${_theme}-Grey/"
  
  # change working dir
  cd $pkgdir/usr/share/themes/${_theme}-Grey/
  
  # change theme Name
  sed -i 's/Numix/Numix-Grey/g' ./index.theme
  
  # change some colors in GTK 2
  cd ./gtk-2.0/
  sed -i 's/base_color:#f9f9f9/base_color:#dddddd/I' ./gtkrc
  sed -i 's/bg_color:#dedede/bg_color:#dddddd/I' ./gtkrc
  sed -i 's/tooltip_fg_color:#f9f9f9/tooltip_fg_color:#2d2d2d/I' ./gtkrc
  sed -i 's/tooltip_bg_color:#2d2d2d/tooltip_bg_color:#dddddd/I' ./gtkrc
  sed -i 's/menubar_bg_color:#2d2d2d/menubar_bg_color:#dddddd/I' ./gtkrc
  sed -i 's/menubar_fg_color:#dcdcdc/menubar_fg_color:#2d2d2d/I' ./gtkrc
  sed -i 's/toolbar_bg_color:#dedede/toolbar_bg_color:#dddddd/I' ./gtkrc
  sed -i 's/menu_bg_color:#2d2d2d/menu_bg_color:#dddddd/I' ./gtkrc
  sed -i 's/menu_fg_color:#dcdcdc/menu_fg_color:#2d2d2d/I' ./gtkrc
  sed -i 's/panel_bg_color:#2d2d2d/panel_bg_color:#dddddd/I' ./gtkrc
  sed -i 's/panel_fg_color:#dcdcdc/panel_fg_color:#2d2d2d/I' ./gtkrc
  
  # now change some GTK 3
  cd ../gtk-3.0/
  sed -i 's/define-color bg_color #dedede/define-color bg_color #dddddd/I' ./gtk.css
  # sed -i 's/define-color tooltip_bg_color #2d2d2d/define-color tooltip_bg_color #2d2d2d/I' ./gtk.css
  sed -i 's/define-color tooltip_fg_color #f9f9f9/define-color tooltip_fg_color #dddddd/I' ./gtk.css
  sed -i 's/define-color light_shadow #fff/define-color light_shadow #dddddd/I' ./gtk.css
  sed -i 's/define-color dark_shadow #000/define-color dark_shadow #000000/I' ./gtk.css
  sed -i 's/define-color menubar_bg_color #2d2d2d/define-color menubar_bg_color @theme_bg_color/I' ./gtk.css
  sed -i 's/define-color menubar_fg_color #dcdcdc/define-color menubar_fg_color #2d2d2d/I' ./gtk.css
  sed -i 's/define-color toolbar_bg_color #dedede/define-color toolbar_bg_color @theme_bg_color/I' ./gtk.css
  sed -i 's/define-color menu_bg_color #2d2d2d/define-color menu_bg_color @theme_bg_color/I' ./gtk.css
  sed -i 's/define-color menu_fg_color #dcdcdc/define-color menu_fg_color #2d2d2d/I' ./gtk.css
  sed -i 's/define-color panel_bg_color #2d2d2d/define-color panel_bg_color @theme_bg_color/I' ./gtk.css
  sed -i 's/define-color panel_fg_color #dcdcdc/define-color panel_fg_color #2d2d2d/I' ./gtk.css
  sed -i 's/define-color osd_base #2d2d2d/define-color osd_base #dddddd/I' ./gtk.css
  sed -i 's/define-color osd_fg #dcdcdc/define-color osd_fg #2d2d2d/I' ./gtk.css
  sed -i 's/define-color wm_bg #2d2d2d/define-color wm_bg #dddddd/I' ./gtk.css
  sed -i 's/define-color wm_title_focused #dcdcdc/define-color wm_title_focused #2d2d2d/I' ./gtk.css
  sed -i 's/base_color:#f9f9f9/base_color:#dddddd/I' ./settings.ini
  sed -i 's/bg_color:#dedede/bg_color:#dddddd/I' ./settings.ini
  # sed -i 's/tooltip_bg_color:#2d2d2d/tooltip_bg_color:#2d2d2d/I' ./settings.ini
  sed -i 's/tooltip_fg_color:#f9f9f9/tooltip_fg_color:#dddddd/I' ./settings.ini
  sed -i 's/selected_fg_color:#f9f9f9/selected_fg_color:#dddddd/I' ./settings.ini
  sed -i 's/menubar_bg_color:#2d2d2d/menubar_bg_color:#dddddd/I' ./settings.ini
  sed -i 's/menubar_fg_color:#dcdcdc/menubar_fg_color:#2d2d2d/I' ./settings.ini
  sed -i 's/toolbar_bg_color:#dedede/toolbar_bg_color:#dddddd/I' ./settings.ini
  sed -i 's/menu_bg_color:#2d2d2d/menu_bg_color:#dddddd/I' ./settings.ini
  sed -i 's/menu_fg_color:#dcdcdc/menu_fg_color:#555555/I' ./settings.ini
  sed -i 's/panel_bg_color:#2d2d2d/panel_bg_color:#dddddd/I' ./settings.ini
  sed -i 's/panel_fg_color:#dcdcdc/panel_fg_color:#555555/I' ./settings.ini
  
  # now some for Openbox
  cd ../openbox-3
  sed -i 's/# Author: Satyajit Sahoo <satyajit.happy@gmail.com>/# Author: nbvcxz <nbvcxz@o2.pl>/I' ./themerc
  sed -i 's/menu.border.color: #2d2d2d/menu.border.color: #ccccccc/I' ./themerc
  sed -i 's/menu.title.bg.color: #2d2d2d/menu.title.bg.color: #dddddd/I' ./themerc
  sed -i 's/menu.title.text.color: #dcdcdc/menu.title.text.color: #333333/I' ./themerc
  sed -i 's/menu.items.bg.color: #2d2d2d/menu.items.bg.color: #dddddd/I' ./themerc
  sed -i 's/menu.items.text.color: #dcdcdc/menu.items.text.color: #333333/I' ./themerc
  sed -i 's/menu.items.disabled.text.color: #888888/menu.items.disabled.text.color: #c7c7c7/I' ./themerc
  sed -i 's/menu.items.active.text.color: #f9f9f9/menu.items.active.text.color: #dddddd/I' ./themerc
  sed -i 's/menu.separator.color: #262626/menu.separator.color: #cfcfcf/I' ./themerc
  sed -i 's/window.active.border.color: #484848/window.active.border.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.title.bg.color: #2d2d2d/window.active.title.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.title.separator.color: #2d2d2d/window.active.title.separator.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.label.text.color: #dcdcdc/window.active.label.text.color: #333333/I' ./themerc
  sed -i 's/window.active.handle.bg.color: #2d2d2d/window.active.handle.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.grip.bg.color: #2d2d2d/window.active.grip.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.button.unpressed.bg.color: #2d2d2d/window.active.button.unpressed.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.button.unpressed.image.color: #dcdcdc/window.active.button.unpressed.image.color: #333333/I' ./themerc
  sed -i 's/window.active.button.pressed.bg.color: #2d2d2d/window.active.button.pressed.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.button.disabled.bg.color: #2d2d2d/window.active.button.disabled.bg.color: #c7c7c7/I' ./themerc
  sed -i 's/window.active.button.disabled.image.color: #888888/window.active.button.disabled.image.color: #333333/I' ./themerc
  sed -i 's/window.inactive.border.color: #393939/window.inactive.border.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.title.bg.color: #2d2d2d/window.inactive.title.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.title.separator.color: #2d2d2d/window.inactive.title.separator.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.label.text.color: #888888/window.inactive.label.text.color: #c7c7c7/I' ./themerc
  sed -i 's/window.inactive.handle.bg.color: #2d2d2d/window.inactive.handle.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.grip.bg.color: #2d2d2d/window.inactive.grip.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.button.unpressed.bg.color: #2d2d2d/window.inactive.button.unpressed.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.button.unpressed.image.color: #888888/window.inactive.button.unpressed.image.color: #c7c7c7/I' ./themerc
  sed -i 's/window.inactive.button.pressed.bg.color: #2d2d2d/window.inactive.button.pressed.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.button.pressed.image.color: #d64937/window.inactive.button.pressed.image.color: #cf978f/I' ./themerc
  sed -i 's/window.inactive.button.disabled.bg.color: #2d2d2d/window.inactive.button.disabled.bg.color: #dddddd/I' ./themerc
  sed -i 's/window.inactive.button.disabled.image.color: #888888/window.inactive.button.disabled.image.color: #d0d0d0/I' ./themerc
  sed -i 's/osd.bg.color: #dedede/osd.bg.color: #dddddd/I' ./themerc
  sed -i 's/border.width: 1/border.width: 4/I' ./themerc
  sed -i 's/padding.height: 4/padding.height: 1/I' ./themerc
  sed -i 's/menu.separator.padding.height: 1/menu.separator.padding.height: 4/I' ./themerc
  
  # and xfce4
  sed -i 's/#dcdcdc/#2d2d2d/I' ./themerc
  sed -i 's/#888888/#c7c7c7/I' ./themerc
}

md5sums=('6adda96f008ebb36877e2f642484404f')

and second for icons:

# Mantainer: nBVCXz <nbvcxz@o2.pl>
# based on https://aur.archlinux.org/packages/gtk-theme-numix-git/ by Diego <cdprincipe@at@gmail@dot@com>

pkgname=numix-icon-theme-grey
pkgver=50.d21eec1
pkgrel=1
pkgdesc="A grey icon theme for Numix Theme matching for Lubuntu colors"
arch=('any')
url="https://github.com/cldx/numix"
license=('GPL3')
depends=()
makedepends=('git')
optdepends=()
# provides=('icons-theme-numix')
# conflicts=('icons-theme-numix')
source=('git://github.com/cldx/numix.git' 'spacefm.svg')
options=('!upx')

pkgver() {
  cd numix
  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd numix

  # create theme dirs
  install -d -m 755 "$pkgdir"/usr/share/icons/Numix-Grey

  # clean up
  rm -rf {.git,.gitignore,CREDITS,LICENSE,README}

  # install theme
  cp -r . "$pkgdir"/usr/share/icons/Numix-Grey/
  cd ..
  cp spacefm.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  cp "$pkgdir"/usr/share/icons/Numix-Grey/categories/gnome-system.svg "$pkgdir"/usr/share/icons/Numix-Grey/categories/48/
  cp xbmc.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  cp mplayer.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  cp smplayer.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  cp nerolinux.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  cp gtkam-camera.svg "$pkgdir"/usr/share/icons/Numix-Grey/apps/48/
  
  # change working dir
  cd $pkgdir/usr/share/icons/Numix-Grey
  
  # change icon theme Name
  sed -i 's/NUMIX/Numix-Grey/g' ./index.theme
  
  # change some colors
  find ./ -type f -exec sed -i 's/000000/555555/I' {} \;
  find ./ -type f -exec sed -i 's/c4905e/555555/I' {} \;
  find ./ -type f -exec sed -i 's/dfdbd2/555555/I' {} \; # transmission tray icon
  find ./ -type f -exec sed -i 's/919fa9/555555/I' {} \; # change new light gray for little darker
  
  # link some icons
  cd ./apps/48
  ln -s terminal.svg lxterminal.svg
  ln -s gpicview.svg geeqie.svg
  cd ../../
  
  # add preferences/48 desc. for index
  # sed '/[status/16]/ i\[preferences/48] \ Context=Preferences \ Size=48 \ Type=Scalable' ./index.theme # commented as need to be coded right
  rm -rf ./actions_bak
  if [ -f ./index.theme~ ]
  then
    rm ./index.theme~
  fi
  # make cache
  gtk-update-icon-cache -f ./
}

md5sums=('SKIP'
         '6d4a44ed8d9cc697501ad0d7ceaa9346')

The final efect is here: https://bbs.archlinux.org/viewtopic.php … 9#p1306969

My first question is - if it is OK according to AUR rules (I thing so). Second - more important for me. I don't know much about programming. Can you help me write the proper loops to replace all the lines with sed -i ?

Btw https://www.dropbox.com/sh/chfwm0woncxpoze/DTBpbr19cg here are full PKGBUILDS and some start icons for arch. Tested with Šaran - should work ok.


Lenovo G50 | LXQT-git | compton | conky

Offline

#2 2013-08-04 08:52:55

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD with adjusting source code

That's so ugly..... just create a patch instead.

Last edited by tomk (2013-08-04 08:54:16)

Offline

#3 2013-08-04 09:17:20

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 193

Re: PKGBUILD with adjusting source code

tomk wrote:

That's so ugly..... just create a patch instead.

I know it is "ugly", but patching is what I want to avoid. Patch replaces lines (or fragments) base on compared sources: original and changed (diff). So each new numix  release I need to make a new changed source code, compare them and then post the patch. Here the idea is not to duplicate tones of files (especially in icon set), but just to replace colors.


Lenovo G50 | LXQT-git | compton | conky

Offline

#4 2013-08-04 09:28:50

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,676

Re: PKGBUILD with adjusting source code

Old patches may still work for new versions, if the change is not too substantial to have the context messed up. In fact, in the case where the patch doesn't work any more, you should probably check your sed lines anyway.


This silver ladybug at line 28...

Offline

#5 2013-08-04 09:46:57

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 193

Re: PKGBUILD with adjusting source code

OK guys - hard to say, but patch is really not solution in this situation (especially for icon-theme based on git). I do understand that the most beautiful way would be create a nice patch (diff from source "Diego " and final "mine") and then apply it to source files. In fact I started from that. But during this time not only some colors changed in source code. The new icons are added (and they will be). So - patch will change only known files, but I would like to have it changed in all files - that's why I decided to use "the ugly code". I just want to have it working not only with whis version of source code - but also with next.
Any idea how to create proper loop in bash? I made some based on tutorials but none working :-(


Lenovo G50 | LXQT-git | compton | conky

Offline

#6 2013-08-04 10:25:35

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,676

Re: PKGBUILD with adjusting source code

I think with so many changes, it's probably a good idea to make a fork of the original project, manage it in git, merge changes from the original project periodically to keep it up to date. You may choose to host your fork on github and point the source in your PKGBUILD to the address of your fork.
As to how you update your fork, whether  by using sed or whatever, it's up to you. The thing is you can't  make 100% sure your sed lines will always work for new versions of the original source; the modification of the original source should be done and double checked by you, if you claim to be the new author of the new theme.


This silver ladybug at line 28...

Offline

#7 2013-08-04 10:38:45

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD with adjusting source code

nbvcxz wrote:

So each new numix  release I need to make a new changed source code, compare them and then post the patch

Well, yeah - that's one of the responsibilites you've just taken on.

nbvcxz wrote:

Here the idea is not to duplicate tones of files (especially in icon set), but just to replace colors.

Then you should not be doing this in a PKGBUILD IMO. Write a script for yourself to change the colours after installing the original package.

Offline

#8 2013-08-04 11:40:34

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,804
Website

Re: PKGBUILD with adjusting source code

I agree with all of the above - but if you don't take any of that advice, at the *very* least read the sed man page to avoid calling the program several dozen times.  Three of four invocations of sed should be plenty for the same effect.

Actually, on second look, this seems to be the perfect use for awk.

Last edited by Trilby (2013-08-04 11:41:14)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#9 2013-08-04 13:37:31

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 193

Re: PKGBUILD with adjusting source code

Trilby wrote:

I agree with all of the above - but if you don't take any of that advice, at the *very* least read the sed man page to avoid calling the program several dozen times.  Three of four invocations of sed should be plenty for the same effect.

That's why I would like to place it in bash loop - but no idea about proper construction.

Actually, on second look, this seems to be the perfect use for awk.

Could You give any example? I tried with awk but in fact it was more complicated for me ;-)


Lenovo G50 | LXQT-git | compton | conky

Offline

#10 2013-08-04 14:35:00

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,804
Website

Re: PKGBUILD with adjusting source code

Sed can take many 's//' commands in one invocation - so that would be the easiest change.

Awk would be something like the following:

awk '
   /item.to.edit.fg/ { gsub(/#[0-9A-Fa-f]{6}/,"#RRGGBB"); }
   /item.to.edit.bg/ { gsub(/#[0-9A-Fa-f]{6}/,"#RRGGBB"); }
   ... more of the same form ...
   // { print $0; }
' $file > ${file}.new && mv ${file}.new $file

This would allow for the original source to change their colors, and this would still override the selected ones with whatever you put in "RRGGBB" and you could put all the modifications for every file in one such awk script, and just loop through every file as $file.

But in doing this, all the content of your "package" that would go in the AUR is encoded in the aur tarball - this is wrong.

Make an awk script with that code, put it on github, and write a PKGBUILD to that.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#11 2013-08-04 15:50:03

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 193

Re: PKGBUILD with adjusting source code

@ Trilby - thx for clues - closer to the result I need. I try with awk and make a script.


Lenovo G50 | LXQT-git | compton | conky

Offline

Board footer

Powered by FluxBB