Bash script for switching wallpaper in XFCE4 - bash

Can you help me with writing a bash script for switching wallpaper between day and night version under XFCE? I want to set a cron job for running it so it will switch automatically based on the time of the day.

I wrote a script:
#!/bin/bash
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s /home/maciek/Pictures/day.jpg
It works when I run it from a terminal. But when I set it up in cron it doesn't work. I get an error:
Failed to init libxfconf: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead.
Some info:
Name : xfce4-session
Version : 4.12.1-7
Description : A session manager for Xfce
Architecture : x86_64
URL : http://www.xfce.org/
Licenses : GPL2
Groups : xfce4
Provides : None
Depends On : libxfce4ui libwnck libsm polkit xorg-iceauth xorg-xinit xorg-xrdb
polkit-gnome hicolor-icon-theme
Optional Deps : gnome-keyring: for keyring support when GNOME compatibility is enabled
xscreensaver: for locking screen with xflock4
gnome-screensaver: for locking screen with xflock4
xlockmore: for locking screen with xflock4
slock: for locking screen with xflock4
Required By : None
Optional For : None
Conflicts With : None
Replaces : xfce-utils
Installed Size : 1972.00 KiB
Packager : Evangelos Foutras <evangelos#foutrelis.com>
Build Date : Tue 27 Jun 2017 05:48:04 AM CEST
Install Date : Fri 21 Jul 2017 11:49:41 PM CEST
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

Related

yum and dnf install/update takes 5 minutes to start on RHEL8

If I run yum or dnf as root on most recent updated RHEL8 it works smoothly. As soon as I try running it with sudo users (added to wheel group) it takes up to 5 minutes.
Doing a yum clean did not help eiher.
I usually run updates using Ansible from a remote host but Ansible disconnects after several minutes of trying to run the yum module.
I set SELinux to disabled, just in case and checked proxy settings in dnf.conf - It all looks fine. Any input is very much appreciated.
This is the dnf.log
2020-02-20T15:33:13Z INFO Updating Subscription Management repositories.
2020-02-20T15:37:36Z DEBUG DNF version: 4.2.7
2020-02-20T15:37:36Z DDEBUG Command: yum update
2020-02-20T15:37:36Z DDEBUG Installroot: /
2020-02-20T15:37:36Z DDEBUG Releasever: 8
2020-02-20T15:37:36Z DEBUG cachedir: /var/cache/dnf
2020-02-20T15:37:36Z DDEBUG Base command: update
2020-02-20T15:37:36Z DDEBUG Extra commands: ['update']
2020-02-20T15:37:37Z DEBUG repo: using cache for: epel-modular
2020-02-20T15:37:37Z DEBUG epel-modular: using metadata from Sat Feb 15 03:19:39 2020.
2020-02-20T15:37:37Z DEBUG repo: using cache for: epel
2020-02-20T15:37:37Z DEBUG epel: using metadata from Thu Feb 20 06:38:22 2020.
2020-02-20T15:37:38Z DEBUG reviving: 'rhel-8-for-x86_64-baseos-rpms' can be revived - repomd matches.
2020-02-20T15:37:38Z DEBUG rhel-8-for-x86_64-baseos-rpms: using metadata from Thu Feb 13 10:30:57 2020.
2020-02-20T15:37:38Z DEBUG reviving: 'rhel-8-for-x86_64-appstream-rpms' can be revived - repomd matches.
2020-02-20T15:37:39Z DEBUG rhel-8-for-x86_64-appstream-rpms: using metadata from Thu Feb 20 11:06:31 2020.
2020-02-20T15:37:39Z DDEBUG timer: sack setup: 3550 ms
2020-02-20T15:37:39Z DEBUG Completion plugin: Generating completion cache...
2020-02-20T15:37:40Z DEBUG --> Starting dependency resolution
2020-02-20T15:37:40Z DEBUG --> Finished dependency resolution
2020-02-20T15:37:40Z DDEBUG timer: depsolve: 277 ms
2020-02-20T15:37:40Z INFO Dependencies resolved.
2020-02-20T15:37:40Z INFO Nothing to do.
2020-02-20T15:37:40Z INFO Complete!
2020-02-20T15:37:40Z DDEBUG Cleaning up.
I resolved the issue. The proxy was not correctly set in /etc/rhsm/rhsm.conf
I don't understand why running as root would not cause the same problem.

"Symbol not found" error, (possibly) due to recent upgrade to R2017b?

I'm getting an error when I try to use imerode() from the command line, e.g.
test=magic([100 100])>200;
imclose(test,strel('disk',10,0));
I get this error:
Error using images.internal.morphmex Invalid MEX-file
'/Applications/MATLAB_R2017b.app/toolbox/images/images/+images/+internal/morphmex.mexmaci64':
dlopen(/Applications/MATLAB_R2017b.app/toolbox/images/images/+images/+internal/morphmex.mexmaci64,
6): Symbol not found: _OSAtomicDecrement32Barrier Referenced from:
/Applications/MATLAB_R2017b.app/bin/maci64/./libcudart.8.0.dylib
Expected in: /usr/lib/libSystem.B.dylib in
/Applications/MATLAB_R2017b.app/bin/maci64/./libcudart.8.0.dylib.
Error in images.internal.morphop (line 103)
B = images.internal.morphmex(mex_method, B, nhood, height, unpacked_M);
Error in imdilate (line 135) B =
images.internal.morphop(A,se,'dilate',mfilename,varargin{:});
Error in imclose (line 82)
outputImage = imerode(imdilate(inputImage,se,packopt,M),se,packopt,M);
I'm on OS X 10.9.5, with MATLAB R2017b.
I've checked that morphmex.mexmaci64 is there in the given path (above).
Not sure where /./ refers to, but libcudart.8.0.dylib is in maci64 folder.
Not sure where /usr/lib/... is.
EDIT
I have uninstalled R2017b and installed R2017a (why not, just in case...) and when trying to run the same code, I now get this error (which seems worse...)
Segmentation violation detected at Mon Nov 13 13:44:29 2017
Configuration: Crash Decoding : Disabled - No sandbox or build
area path Crash Mode : continue (default) Current
Graphics Driver: Unknown hardware Current Visual : Quartz
Default Encoding : ISO-8859-1 Deployed : false Host
Name : eduroam-206-52.nomadic.bris.ac.uk MATLAB
Architecture : maci64 MATLAB Entitlement ID: 1803495 MATLAB Root
: /Applications/MATLAB_R2017a.app MATLAB Version : 9.2.0.556344
(R2017a) OpenGL : hardware Operating System :
Darwin 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST
2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64 Processor ID
: x86 Family 6 Model 69 Stepping 1, GenuineIntel Virtual Machine
: Java 1.7.0_75-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit
Server VM mixed mode Window System : Quartz
Fault Count: 2
Abnormal termination: Trace trap
Can upload error file for rest of message (too long to paste here).
Thanks in advance.
Looks like an installation problem or maybe it is due to the update.
Try to run the following commands in your console:
restoredefaultpath();
rehash toolboxcache;
If everything works without errors, then run:
savepath();
Turns out R2017a, b not compatible with OS Mavericks.
Rolled back to R2016a.

AWS EC2 User Data Not Decoding Correctly

I am experimenting with creating an EC2 instance to host a Perforce server. My instance is configured with the following user data:
#!/bin/bash
# Add a newline to the ec2-user prompt string
echo PS1=\"\\n\$PS1\" >> /home/ec2-user/.bashrc
# Update all packages
yum update –y
# Install Perforce packages
# The RHEL/7 part of the baseurl should be replaced with
# the latest RHEL version that both Amazon and Perforce support
rpm –import https://package.perforce.com/perforce.pubkey
cd /etc/yum.repos.d/
echo [perforce] > perforce.repo
echo name=Perforce >> perforce.repo
echo baseurl=http://package.perforce.com/yum/rhel/7/x86_64 >> perforce.repo
echo enabled=1 >> perforce.repo
echo gpgcheck=1 >> perforce.repo
yum install –y helix-p4d
# Make directories for the server, owned by new “perforce” user
cd /opt/perforce/servers/
mkdir danware
cd danware
mkdir danware-db danware-chkpts journal
chown –R perforce:perforce danware
I have tested each of the above commands, and know that they work when executed manually in this order. However, some aspect of Amazon's base64 encode/decode system seems to be getting in the way. When I go to "Actions > Instance Settings > View/Change User Data" from the EC2 Console after launching (and passing all system checks), I see the following user data. Note how almost every hyphen "-" has been replaced with some strange "a" character.
However, I'm not sure that this is the issue, because the log file at /var/log/cloud-init-output.log gives me the following output (I replaced some repetitive text with [...] to save space). Note the line that says Failed running /var/lib/cloud/instance/scripts/part-001 I have verified that this part-001 file actually does have the correctly displayed hyphen characters.
[...]
Cloud-init v. 0.7.6 running 'modules:final' at Fri, 09 Sep 2016 06:23:39 +0000. Up 86.66 seconds.
Loaded plugins: priorities, update-motd, upgrade-helper
No Match for argument: –y
No packages marked for update
RPM version 4.11.2
Copyright (C) 1998-2002 - Red Hat, Inc.
This program may be freely redistributed under the terms of the GNU GPL
Usage: rpm [-aKfgpqVcdLilsiv?] [-a|--all] [-f|--file] [-g|--group] [...]
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> [...]
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
helix-p4d x86_64 2016.1-1429894 perforce 24 k
Installing for dependencies:
helix-cli x86_64 2016.1-1429894 perforce 8.8 k
helix-cli-base x86_64 2016.1-1429894 perforce 1.4 M
helix-p4d-base x86_64 2016.1-1429894 perforce 3.1 k
helix-p4d-base-16.1 x86_64 2016.1-1429894 perforce 2.4 M
helix-p4dctl x86_64 2016.1-1429894 perforce 1.2 M
Transaction Summary
================================================================================
Install 1 Package (+5 Dependent packages)
Total download size: 5.0 M
Installed size: 13 M
Is this ok [y/d/N]: Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2016-09-09.06-23.dRP_r2.yumtx
/var/lib/cloud/instance/scripts/part-001: line 22: cd: /opt/perforce/servers/: No such file or directory
chown: invalid user: ‘–R’
Sep 09 06:23:41 cloud-init[2517]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
Sep 09 06:23:41 cloud-init[2517]: cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
Sep 09 06:23:41 cloud-init[2517]: util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
Cloud-init v. 0.7.6 finished at Fri, 09 Sep 2016 06:23:41 +0000. Datasource DataSourceEc2. Up 88.53 seconds
Even more annoying, I assumed that the early No Match for argument: –y line from the log file was referring to the yum update -y line from my user data. Sure enough, just running the example user data script from the EC2 documentation page, which also uses yum update -y, gives me this same error/warning! Amazon's own example script doesn't work!? So can anyone answer why A) AWS is not displaying the user data code correctly, and B) why my user data is yielding the errors shown above? The help is much appreciated!
For lines such as
yum update –y
The character you are using is a "EN DASH U+2013"
The usual character for a hyphen is "HYPHEN-MINUS U+002D"
Fix your user data source to use "hyphen minus" and have another go
I checked the character codes by cut n pasting into this online site http://www.fileformat.info/info/unicode/char/search.htm?q=-&preview=entity
Don't know if you can see the difference but this is your hyphen
yum update –y
and this is a "hyphen minus"
yum update -y

Single Column rpm command output

I have an application where I want to get the RPM info of several packages and format it in a pleasing and eye-catching way. *boom*.
My problem is that rpm wants to format the data into two columns, which is annoying.
Command
rpm -qi ruby
Result
Name : ruby Relocations: (not relocatable)
Version : 1.8.6.36 Vendor: (none)
Release : 2 Build Date: Thu 18 Sep 2008 10:50:30 AM EDT
Install Date: Thu 25 Sep 2008 12:12:53 PM EDT Build Host: kickbench
Group : Development/Languages Source RPM: ruby-1.8.6.36-2.src.rpm
Size : 1664035 License: Ruby License/GPL - see COPYING
Signature : (none)
URL : http://www.ruby-lang.org/
Summary : An interpreter of object-oriented scripting language.
Description : [truncated]
What I want
Name : ruby
Relocations : (not relocatable)
Version : 1.8.6.36
Vendor : (none)
Release : 2
Build Date : Thu 18 Sep 2008 10:50:30 AM EDT
Install Date: Thu 25 Sep 2008 12:12:53 PM EDT
Build Host : kickbench
Group : Development/Languages
Source RPM : ruby-1.8.6.36-2.src.rpm
Size : 1664035
License : Ruby License/GPL - see COPYING
Signature : (none)
URL : http://www.ruby-lang.org/
Summary : An interpreter of object-oriented scripting language.
Description : [truncated]
Is there any way to get this formatting without manually specifying a reaally long --queryformat?
Alternatively, any way to do this native to Ruby would be fine.
pairs = %x{rpm -qi ruby}
.split(/(?<!:)\s{2,}(?![\s:])|#$//)
.map{|line| line.split(/\s*:\s+/, 2)}
width = pairs.map{|pair| pair.first.length}.max
pairs.each{|k, v| puts "#{k.ljust(width)}: #{v}"}

Xcode 4 final - breakpoints on device (ipad) not working

I downloaded and installed final version of Xcode 4. I opened my iPad project and realised that breakpoint's doesn't work on the device. They work ok on simulator though.
Before I was using Xcode 3.2 and everything was working fine.
I also tried creating an empty view based iOS application from scratch and have exactly this same issue. I was googling on that issue, but all solutions were based on previous versions of Xcode.
Any suggestions what am I doing wrong ?
Here is output from a console when running application
Mar 10 14:34:44 unknown installd[547] : entitlement 'keychain-access-groups' has value not permitted by a provisioning profile
Mar 10 14:34:44 unknown installd[547] : entitlement 'application-identifier' has value not permitted by a provisioning profile
Mar 10 14:34:44 unknown SpringBoard[29] : Killing me.device-debugging-test activate: deactivate: for app installation
Mar 10 14:34:44 unknown installd[547] : entitlement 'keychain-access-groups' has value not permitted by a provisioning profile
Mar 10 14:34:44 unknown installd[547] : entitlement 'application-identifier' has value not permitted by a provisioning profile
Mar 10 14:34:44 unknown SpringBoard[29] : Reloading application state for 'me.device-debugging-test' as its modification date has changed
Mar 10 14:34:45 unknown SpringBoard[29] : Reloading and rendering all application icons.
Mar 10 14:34:46 unknown com.apple.debugserver-48[551] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved.
Mar 10 14:34:46 unknown com.apple.debugserver-48[551] : Connecting to com.apple.debugserver service...
Mar 10 14:34:47 unknown com.apple.launchd[1] : (UIKitApplication:me.device-debugging-test[0x4309]) Spawned and waiting for the debugger to attach before continuing...
Mar 10 14:34:47 unknown com.apple.debugserver-48[551] : Got a connection, waiting for debugger instructions for task "(null)".
Mar 10 14:34:47 unknown kernel[0] : lockbot[544] Builtin profile: debugserver (sandbox)
Mar 10 14:34:47 unknown kernel[0] : launchd[552] Builtin profile: container (sandbox)
Mar 10 14:34:47 unknown kernel[0] : launchd[552] Container: /private/var/mobile/Applications/(...) [69] (sandbox)
Reboot your device.
Short, sweet, and simple solution.
After hours spent digging through all the XCode options.

Resources